Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

yaspeller

hcodes13kMIT10.0.1

Search tool typos in the text, files and websites

typo, typos, text, опечатки, текст, yandex, speller, Яндекс.Спеллер, Yandex.Speller

readme

yaspeller

NPM version NPM Downloads Coverage Status install size

This README is also available in Russian.

Search tool typos in the text, files and websites.

Used API Yandex.Speller.

yaspeller

Installation

npm install yaspeller -g

Using CLI

yaspeller [options] <file-or-directory-or-link...>

Using with pre-commit

Add this to your .pre-commit-config.yaml:

- repo: https://github.com/hcodes/yaspeller.git
  rev: '' # Use the sha / tag you want to point at
  hooks:
    - id: yaspeller

Examples

  • yaspeller README.md — search typos in the file.
  • yaspeller "*.md" — node glob syntax for Windows.
  • yaspeller -e ".md,.html,.txt" ./texts/ — finding typos in files in the folder.
  • yaspeller https://ru.wikipedia.org/wiki/%D0%9E%D0%BF%D0%B5%D1%87%D0%B0%D1%82%D0%BA%D0%B0 — search typos in the page.
  • yaspeller http://bem.info/sitemap.xml — search typos at the addresses specified in the sitemap.xml.
  • echo "Hello, world!" | yaspeller --stdin
  • echo "Hello, world!" | yaspeller --stdin --stdin-filename hello.txt

Options

-f, --format <value>

Formats: plain, html, markdown or auto.
Default: auto.

-l, --lang <value>

Languages: en, ru or uk.
Default: en,ru.

-c, --config <path>

Configuration file path.

-e, --file-extensions <value>

Set file extensions to search for files in a folder.
Example: .md,.htm,.txt.

--dictionary <file>

JSON file for own dictionary.

[
    "someword1", // someword1 = someword1 and Someword1
    "Someword2", // Someword2 = Someword2
    "someword3"
]

Regular expressions are supported:

[
    "unknownword",
    "unknown(W|w)ord[12]?", // unknown(W|w)ord[12]? = unknown(W|w)ord[12]? and Unknown(W|w)ord[12]?
    "Unknown(W|w)ord[34]?" // Unknown(W|w)ord[34]? = Unknown(W|w)ord[34]?
]

Examples:
yaspeller --dictionary my_dict.json .
yaspeller --dictionary my_dict.json:my_dict2.json .

If you have tons of markdown and introduce this linter, you're likely to want generation of initial dictionary with yaspeller-dictionary-builder, so one line will cover all word's forms.

--report <type>

Set type of report: console, html, markdown, junit or json.
Default: console
Example: console,html,custom_report.js

--check-yo

Check the correctness of using the letter “Ё” (Yo) in Russian texts.

--find-repeat-words

Highlight repetitions of words, consecutive. For example, I flew to to to Cyprus.

--ignore-tags <tags>

Ignore HTML tags.
Default: code,kbd,object,samp,script,style,var
Option to formats html andmarkdown.

--ignore-text <regexp>

Remove the text from the scan using regular expressions.

--ignore-capitalization

Ignore the incorrect use of UPPERCASE / lowercase letters, for example, in the word moscow.

--ignore-digits

Ignore words with numbers, such as avp17h4534.

--ignore-urls

Ignore Internet addresses, email addresses and filenames.

--max-requests <value>

Max count of requests in parallel.
Default: 2.

--no-color

Clean output without colors.

--only-errors

Output only errors.

--stdin

Process files on <STDIN>. Default: false

--stdin-filename <file>

Specify filename to process <STDIN> as. Used in reports.

--debug

Debug mode.

Configuration

npm install yaspeller --save-dev

Add the text in package.json / scripts:
"yaspeller": "yaspeller .",

To run the linter:
npm run yaspeller

yaspeller is configured using JSON file at the root of the project:

  • .yaspellerrc
  • .yaspellerrc.js
  • .yaspellerrc.json
  • .yaspeller.json
  • package.json, field yaspeller
{
  "excludeFiles": [
    ".git",
    "libs",
    "node_modules",
    "yaspeller"
  ],
  "lang": "ru",
  "fileExtensions": [
    ".md",
    ".css"
  ],
  "dictionary": [
    "someword1"
  ]
}

Advanced example:

{
  "excludeFiles": [
    ".git",
    "yaspeller",
    "node_modules",
    "libs"
  ],
  "format": "html",
  "lang": "en",
  "fileExtensions": [
    ".md",
    ".css"
  ],
  "report": ["console", "html"],
  "dictionary": [
    // JSON comments
    "someword1", // someword1 = someword1 and Someword1
    "Someword2", // Someword2 = Someword2
    "some(w|W)ord[23]", // some(w|W)ord[23] = some(w|W)ord[23] and Some(w|W)ord[23]
    "Some(w|W)ord" // Some(w|W)ord = Some(w|W)ord
  ],
  "ignoreText": [
    "<php\?[^]*?\?>", // Shortly
    ["<php\?[^]*?\?>", "g"] // Longly
  ],
  "ignoreTags": ["code", "script"],
  "ignoreUrls": true,
  "findRepeatWords": true,
  "maxRequests": 5
}
Property Type Details
format String --format
lang String --lang
excludeFiles Array
fileExtensions Array --file-extension
dictionary Array --dictionary
report Array --report
checkYo Boolean --check-yo
findRepeatWords Boolean --find-repeat-words
ignoreTags Array --ignore-tags
ignoreText Array --ignore-text
ignoreCapitalization Boolean --ignore-capitalization
ignoreDigits Boolean --ignore-digits
ignoreUrls Boolean --ignore-urls
maxRequests Number --max-requests

Ignore text from checking

Ignore a line

var re = /a-z/; // yaspeller ignore
var re = /a-z/; /* yaspeller ignore */
<span>a-z</span> <!-- yaspeller ignore -->

Ignore a block

/* yaspeller ignore:start */
const reUpper = /A-Z/;
const reLower = /a-z/;
/* yaspeller ignore:end */
<!-- yaspeller ignore:start -->
<span>A-Z</span>
<div>a-z</div>
<!-- yaspeller ignore:end -->

Gulp plugin

const gulp = require('gulp');
const run = require('gulp-run'); // npm install gulp-run --save-dev

gulp.task('yaspeller', function (cb) {
    run('./node_modules/.bin/yaspeller .').exec()
        .on('error', function (err) {
            console.error(err.message);
            cb();
        })
        .on('finish', cb);
});

Grunt plugin

module.exports = function(grunt) {
    grunt.loadNpmTasks('grunt-shell'); // npm install grunt-shell --save-dev
    grunt.initConfig({
        shell: {
            yaspeller: {
                options: {stderr: false},
                command: './node_modules/.bin/yaspeller .'
            }
        }
    });
    grunt.registerTask('lint', ['shell:yaspeller']);
};

Restrictions API Yandex.Speller

License

MIT License

changelog

Changelog

v10.0.1

  • Fix TypeError: Cannot read properties of undefined (reading 'length') #199

v10.0.0

  • Update major yandex-speller package.
  • Remove unsupported options of new API Yandex Speller: flagLatin, ignoreLatin, byWords, ignoreRomanNumerals and ignoreUppercase.

v9.1.0

  • Update yandex-speller package.

v9.0.0

  • Update deps in package.json.
  • Yaspeller requires Node.js 16 or higher.

v8.0.1

Update deps in package.json.

v8.0.0

  • Yaspeller requires Node.js 12 or higher.
  • Reducing the size of dependencies #178 @alchazov.
  • CLI no-colors option replaced with no-color.

v7.2.1

  • --ignore-tags Not work properly in Markdown files with HTML #176

v7.2.0

  • Update deps in package.json
  • Fixed sitemap bug #169

v7.1.0

Added junit report #171 @Lootjs.

v7.0.0

  • Drop support for Node.js < 10.
  • Add .yaspellerrc.js and .yaspellerrc.json for project config #153, #150

v6.1.0

  • Fix lost symlink #145, #128.
  • Print row:col for repeated words #142, #134.
  • Fix repeated words with code for markdown files #141, #134.

v6.0.4

  • Fix: print a typo warning at the end if there are typos #121.

v6.0.3

  • Updated deps in package.json.

v6.0.2

  • Updated deps in package.json.

v6.0.1

  • Updated deps in package.json.

v6.0.0

  • Drop support for old Node.js < 8.
  • Update deps in package.json

v5.1.0

  • Updated deps in package.json.
  • Add warning where to fix a typo #115.

v5.0.1

  • FIX: sitemap.xml - TypeError: Cannot read property 'replace' of undefined #113.

v5.0.0

  • FIX: Breaking changes: Incorrect work of dictionary words in substrings #106.
  • FIX: Comments in JSON #108.

v4.2.1

FIX: TypeError: Cannot destructure property config of 'undefined' or 'null' #103.

v4.2.0

yaspeller field in package.json #100 (@thepocp), #101 (@shashkovdanil).

v4.1.0

  • Updated deps in package.json.
  • Warnings for unknown properties in config files #94.

v4.0.3

Fixed exit code #87.

v4.0.2

Fixed SyntaxError #83.

4.0.1

  • Fixed error handling for Yandex.Speller API #84.
  • Updated deps in package.json.

4.0.0

  • Add --init CLI option #77
  • Add --stdin and --stdin-filename CLI options #76

Before: echo "Hello, world!" | yaspeller

After: echo "Hello, world!" | yaspeller --stdin or echo "Hello, world!" | yaspeller --stdin --stdin-filename hello.txt

3.3.0

  • Glob patterns for Windows
  • Updated deps in package.json

3.2.0

  • File extension with multiple dots #66, #67 @levonet

3.1.0

  • Remove acute accent, shy and other symbols #65
  • Updated deps in package.json

Bugs:

  • Can't read options --config #61 @pavelpower
  • Fix the error message in the dictionary.js #60 @vessd
  • Fix(readme): translate 'или' to 'or' #57 @JLHwung

3.0.0

  • Added line number in reports
  • Removed support for old format of words in the dictionary
  • A support for old Node version is dropped
  • Updated deps in package.json

2.9.1

  • Small fixes in README.md for npmjs.org

2.9.0

  • Ability to ignore the text using regular expressions (--ignore-text for CLI or ignoreText for .yaspellerrc)
  • Updated deps in package.json

2.8.2

  • Small fix for stdin #48
  • Updated deps in package.json

2.8.1

  • Updated deps in package.json

2.8.0

  • Added support for stdin
  • Updated deps in package.json

2.7.0

  • Separate module for Yandex.Speller API
  • Updated deps in package.json

2.6.0

  • Added filter “Show only errors” in HTML report
  • Updated deps in package.json

2.5.1

  • Updated deps in package.json

2.5.0

  • Replace npm module eyo to eyo-kernel
  • Output warnings of duplicate words in dictionaries
  • Update deps in package.json
  • Simplified regular expressions in words in the dictionary

Before (<= 2.4.0):

[
  "someword1", // someword1 = someword1
  "Someword2", // Someword2 = Someword2
  "/some(w|W)ord[23]/", // some(w|W)ord[23] = some(w|W)ord[23]
  "/Some(w|W)ord/" // Some(w|W)ord = Some(w|W)ord
]

After (2.5.0):

[
  "someword1", // someword1 = someword1 and Someword1
  "Someword2", // Someword2 = Someword2
  "some(w|W)ord[23]", // some(w|W)ord[23] = some(w|W)ord[23] and Some(w|W)ord[23]
  "Some(w|W)ord" // Some(w|W)ord = Some(w|W)ord
]

2.4.0

  • Ability to ignore text when checking

Bug fixes

  • Fix JSON comments in dictionaries and config's

2.3.0

  • JSON comments in dictionaries and config's #35
  • Ability to specify multiple dictionaries in option --dictionary #33
  • Markdown report #31
  • Update deps in package.json

2.2.0

  • Exit code for error loading in API #29.
  • Update deps in package.json.

2.1.0

  • Ability to use an empty parameter --file-extensions from CLI.

Bug fixes

  • Error with an unknown site.

2.0.1

Bug fixes

  • Load config after args is parsed #27

2.0.0

  • Support for checking the letter Ё (--check-yo or checkYo: true).
  • Dictionary of .yaspellerrc and specified on the command line are used together.
  • Setting fileExtensions is not used for checking one file (yaspeller -l ru my_file.txt).
  • Added report error_dictionary for the collection of typos in files.

1.1.0

  • Use settings excludeFiles and fileExtensions for checking one file.
  • Support for regular expressions #18.
  • Fixed detection format #19.

1.0.6

  • Update deps in package.json.
  • Added changelog.

1.0.5

Bug fixes

  • Fix file protocol in html report.

1.0.4

Bug fixes

  • npm: Fix LF.

1.0.3

Bug fixes

  • Crash of Yaspeller when try Habrahabr url #22.

1.0.2

Initial public release.