Home > harper.js > Linter

Linter interface

An interface for an object that can perform linting actions.

Signature:

export declare interface Linter 

Methods

Method

Description

applySuggestion(text, lint, suggestion)

Apply a suggestion from a lint to text, returning the changed text.

clearIgnoredLints()

Clear records of all previously ignored lints.

contextHash(source, lint)

Produce a context-sensitive hash that represents a lint.

exportIgnoredLints()

Export the ignored lints to a JSON list of privacy-respecting hashes.

exportWords()

Export all added words from the dictionary. Note that this will NOT export anything from the curated dictionary, only words from previous calls to this.importWords.

generateStatsFile()

Generate a statistics log file you can save to permanent storage.

getDefaultLintConfig()

Get the default (unset) linter configuration. This method does not effect the caller’s lint configuration, nor does it return the current one.

getDefaultLintConfigAsJSON()

Get the default (unset) linter configuration as JSON. This method does not effect the caller’s lint configuration, nor does it return the current one.

getDialect()

Get the dialect of English this linter was constructed for.

getLintConfig()

Get the linter’s current configuration.

getLintConfigAsJSON()

Get the linter’s current configuration as JSON.

getLintDescriptions()

Get the linting rule descriptions as an object, formatted in Markdown.

getLintDescriptionsAsJSON()

Get the linting rule descriptions as a JSON map, formatted in Markdown.

getLintDescriptionsHTML()

Get the linting rule descriptions as an object, formatted in HTML

getLintDescriptionsHTMLAsJSON()

Get the linting rule descriptions as a JSON map, formatted in HTML.

ignoreLint(source, lint)

Ignore future instances of a lint from a previous linting run in future invocations.

ignoreLintHash(hash)

Ignore future instances of a lint from a previous linting run in future invocations using its hash.

importIgnoredLints(json)

Import ignored lints from a JSON list to the linter. This function appends to the existing lints, if any.

importStatsFile(statsFile)

Import a statistics log file.

importWords(words)

Import words into the dictionary. This is a significant operation, so try to batch words.

isLikelyEnglish(text)

Determine if the provided text is likely to be intended to be English. The algorithm can be described as “proof of concept” and as such does not work terribly well.

isolateEnglish(text)

Determine which parts of a given string are intended to be English, returning those bits. The algorithm can be described as “proof of concept” and as such does not work terribly well.

lint(text, options)

Lint the provided text.

setDialect(dialect)

Get the dialect of English this linter was constructed for.

setLintConfig(config)

Set the linter’s current configuration.

setLintConfigWithJSON(config)

Set the linter’s current configuration from JSON.

setup()

Complete any setup that is necessary before linting. This may include downloading and compiling the WebAssembly binary. This setup will complete when needed regardless of whether you call this function. This function exists to allow you to do this work when it is of least impact to the user experiences (i.e. while you’re loading something else).

summarizeStats(start, end)

Summarize the linter’s usage statistics. You may optionally pass in a start and/or end time.

If so, the summary with only include data from _after_ the start time but _before_ the end time.

toTitleCase(text)

Convert a string to Chicago-style title case.