JSCS Spellcheck — Spellcheck plugin for JSCS.
This JSCS plugin checks for words that can't be found in a dictionary, and tells you where they are so that you can spell them correctly. You can choose which dictionaries and languages to use. You can add more words and ignore existing ones. You can define exceptions for names used by 3rd parties. You can even restrict a word's usage to identifiers or property names only.
Installation
jscs-spellcheck
can be installed using NPM and requires
jscs.
Install it globally if you are using globally installed jscs
:
npm install jscs-spellcheck --global
But better install it into your project:
npm install jscs-spellcheck --save-dev
Usage
To use, add these lines to your .jscsrc
configuration file:
Rules
requireDictionaryWords
Only allow words defined in a dictionary or by you.
English language support is installed by default. To add additional
languages, go to the installation directory of JSCS and run npm install wordlist-LANGUAGE
, where LANGUAGE is the name of your language.
Type: Boolean
or Object
Values:
true
: use the"english"
dictionaryObject
:dictionaries
: (default["english"]
) array of dictionary names including"english"
,"english/american"
,"english/british"
and"english/canadian"
allowWords
: additional words allowed anywhereallowWordsInIdentifiers
: additional words allowed only in identifiersallowWordsInProperties
: additional words allowed only in propertiesallowNames
: whole names ignored by spellcheckallowNamesAsIdentifiers
: whole names ignored by spellcheck when used as identifiersallowNamesAsProperties
: whole names ignored by spellcheck when used as propertiesexcludeWords
: words to exclude from the dictionaries
Example
"requireDictionaryWords": true "requireDictionaryWords": "dictionaries": "english" "english/american" "allowWords": "transclude" "allowWordsInProperties": "chmod" "allowNamesAsIdentifiers": "$stateParams" "util" "allowNamesAsProperties": "src" "excludeWords": "i"
true
Valid for mode var number = 1;object'source' = 2;objectsource = 3;fileDirectory = 4;
true
Invalid for mode var num = 1;obj'src' = 2;objsrc = 3;fileDir = 4;
"dictionaries": [ "english/american" ]
, invalid for "english/british"
Valid for mode var color = 'papayawhip';
"dictionaries": [ "english/british" ]
, invalid for "english/american"
Valid for mode var colour = 'papayawhip';
"allowWords": [ "transclude" ]
Valid for mode var {};var {};return {} ;
"allowWordsInProperties": [ "chmod" ]
Valid for mode var mode = 0777;fs;fs;
"allowWordsInProperties": [ "chmod" ]
Invalid for mode var chmod = 0777;
"allowNamesAsIdentifiers": [ "$stateParams", "util" ]
Valid for mode var util = ; {}
"allowNamesAsIdentifiers": [ "$stateParams", "util" ]
Invalid for mode var stringUtil = {};var params = {};
"allowNamesAsProperties": [ "src" ]
Valid for mode elementsrc = 'https://youtu.be/dQw4w9WgXcQ';
"allowNamesAsProperties": [ "src" ]
Invalid for mode var data = videoSrc: 'youtube' ;
"excludeWords": [ "i" ]
Invalid for mode for var i = 0; i < arraylength; i++ {}
Error Suppression
You can also allow (and later disallow) words on a per-file (or per-line) basis:
// jscs:allowWords concat, dest, dist, srcgrunt;
// jscs:allowWords mxdsn;// jscs:disallowWords mx var mx = Math; // invalid