Giter VIP home page Giter VIP logo

textlint-rule-spellchecker's Introduction

textlint-rule-spellchecker

textlint rule npm Build Status Dependency Status devDependency Status

A textlint rule to check spellings with an available native spellchecker, i.e. NSSpellChecker, Hunspell, or the Windows 8 Spell Check API, depending on your platform.

Installation

$ yarn add textlint textlint-rule-spellchecker

Usage

$ yarn run textlint --rule textlint-rule-spellchecker text-to-spellcheck.txt

Ignoring Words

Global Settings

As this rule uses the native spellchecker in your computer, you can ignore specific words by adding them to your computer's/IME's dictionary.

Per-project Settings

You can also prevent some words from being spellchecked by writing configurations in .textlintrc like:

{
  "rules": {
    "spellchecker": {
      skipWords: ['JavaScript', 'ECMAScript'],
      skipRegExps: ['(?:[a-z]+)Script'],
      skipNodeTypes: ['Comment'],
    }
  }
}

skipWords

Default: []

Words in the skipWords list will not be checked and put no errors.

skipRegExps

Default: []

Words that match with one of the regular expressions in skipRegExps are ignored. Please note that they should be specified as an array of string, not RegExp object, and thus you need to do some extra escaping when using \.

skipNodeTypes

Default: ['Link', 'Image', 'BlockQuote', 'Emphasis', 'Code']

textlint traverses an TxtAST tree while linting the input text.

This option changes which types of node should be skipped from the spellchecks. Any texts under an ignored node will not be checked.

By default, links, images, blockquotes, emphasised texts and code blocks are ignored.

The valid node types are defined in @textlint/ast-node-types and you should pass them as a string to this option.

Please note that adding this option overrides the default behaviour so if you want to add another node type, you must redefine all types in the default settings.

Tests

npm test

Contribution

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT License (http://nodaguti.mit-license.org/)

textlint-rule-spellchecker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mmyjona

textlint-rule-spellchecker's Issues

Need clarification on spellchecker source

The doc mentions the following:

Global Settings

As this rule uses the native spellchecker in your computer, you can ignore specific words by adding them to your computer's/IME's dictionary.

Doesn't this mean that it might be inconsistent from one dev to another depending on what type of computer he/she is using? Also, the CI environment might be completely different from developers machines. So, can I say that this lint rule will probably produce inconsistent results. Is that correct? I'd appreciate if you could clarify this. Thanks

skipNodeTypes with "Code" not working for inline code blocks

Example textlint config:

{
  "rules": {
    "spellchecker": {
      "skipNodeTypes": ["Code"]
    }
  }
}

Example markdown:

### Here are some example files

- `.bash_profile` is used by Bash for my shell configuration.
- `.gitconfig` is used by Git for my version control configuration.
- `.vimrc` is used by Vim for my editor configuration.
...

Running textlint on this lead to errors like:

error  gitconfig ->                                             spellchecker
error  vimrc -> vimdc, vimcc, vimlc, vimmc, vimvc, vimxc, vimc  spellchecker

The docs that are linked to show Code as the option for this:
https://github.com/textlint/textlint/blob/master/docs/txtnode.md#type

image

Allow passing ignored words/patterns

I'm considering using this rule as a complementary to eslint-plugin-spellcheck and I wonder if it's possible to define skipped words exception list.

Use case: The project may have its own set of words that have domain-related meaning and I don't want them to be considered errors although they don't fit the general dictionary.

How about introducing configuration similar to what ESLint plugin has: skipWords and skipIfMatch (names may off course be different)

What I'd like to achieve is to make it possible to maintain one and only one set of words that are excluded.

v2.2.0 doesn't recognize "skipWords" option

Issue

[email protected] doesn't recognize "skipWords" option.

I run textlint with this .textlintrc, but got errors with "funciton" and "errror".

{
  "rules": {
    "spellchecker": {
        "skipWords": ["funciton", "errror"]
    }
  }
}

My Rough Investigation

I think the cause of this issue is in the building or publishing process.

Please install with yarn add textlint-rule-spellchecker then see/compare these two files.

  • node_modules/textlint-rule-spellchecker/src/spellchecker.js
  • node_modules/textlint-rule-spellchecker/lib/spellchecker.js

lib/spellchecker.js seems to be old (no logic for skipWords option).

Environment

  • node : v9.2.0
  • npm: 5.6.0
  • yarn: 1.3.2

Thank you.

Error message Cannot find module '../build/Release/spellchecker.node'

Suspicious state from syntax checker textlint: Flycheck checker textlint returned 1, but its output contained no errors: ✖ Error
Cannot find module '../build/Release/spellchecker.node'
Require stack:
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint-rule-spellchecker/node_modules/spellchecker/lib/spellchecker.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint-rule-spellchecker/lib/spellchecker.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/lib/textlint/src/engine/textlint-module-loader.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/lib/textlint/src/engine/textlint-engine-core.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/lib/textlint/src/textlint-engine.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/lib/textlint/src/cli.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/bin/textlint.js

✖ Stack trace
Error: Cannot find module '../build/Release/spellchecker.node'
Require stack:
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint-rule-spellchecker/node_modules/spellchecker/lib/spellchecker.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint-rule-spellchecker/lib/spellchecker.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/lib/textlint/src/engine/textlint-module-loader.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/lib/textlint/src/engine/textlint-engine-core.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/lib/textlint/src/textlint-engine.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/lib/textlint/src/cli.js
- /home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint/bin/textlint.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint-rule-spellchecker/node_modules/spellchecker/lib/spellchecker.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/home/user/.nvm/versions/node/v12.16.2/lib/node_modules/textlint-rule-spellchecker/lib/spellchecker.js:9:21)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)

Try installing a more recent version of textlint, and please open a bug report if the issue persists in the latest release.  Thanks!

Do I need to install spellchecker or other dependencies from npm individually? (I tried but that failed - probably atom/node-spellchecker#111)

Not seeming to find misspelled words

I'm using a Markdown file with this in the first paragraph:

As you can tell, I'm on somewhatxssdsddssd of an Alexa thing lately (["Adding Ice Bear to Alexa, Because Why Not?"](https://www.raymondcamden.com/2018/11/28/adding-ice-bear-to-alexa-because-why-not)), mainly because now I've gotten it to a point where I can deploy an (admittedly simple) skill in
 about thirty minutes. Also, certification seems to have gotten quite a bit simpler too. That could also be
 tied to me building incredibly simple skills but I'm not going to complain. For today's <strike>waste of
 time</strike>incredibly useful Alexa example, I've built a little skill for the sole purpose of messing with
 my kids during this wonderful Christmas season.

And the misspelled word in the first sentence is not being picked up. I'm using this in my .textlintrc:

{
  "filters": {},
  "rules": {
    "no-start-duplicated-conjunction":true,
    "no-dead-link":true,
    "terminology":true,
    "@textlint-rule/no-unmatched-pair": true,
    "alex":true,
    "spellchecker":true
  }
}

Any idea what I'm missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.