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.
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
To use, add these lines to your .jscsrc
configuration file:
{
"plugins": [ "jscs-spellcheck" ],
"requireDictionaryWords": {
"dictionaries": [ "english", "english/american" ]
}
}
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
"requireDictionaryWords": true
"requireDictionaryWords": {
"dictionaries": [ "english", "english/american" ],
"allowWords": [ "transclude" ],
"allowWordsInProperties": [ "chmod" ],
"allowNamesAsIdentifiers": [ "$stateParams", "util" ],
"allowNamesAsProperties": [ "src" ],
"excludeWords": [ "i" ]
}
var number = 1;
object['source'] = 2;
object.source = 3;
fileDirectory = 4;
var num = 1;
obj['src'] = 2;
obj.src = 3;
fileDir = 4;
var color = 'papayawhip';
var colour = 'papayawhip';
var transclude = function() {};
var transcludeFunction = function() {};
return { transclude: function() {} };
var mode = 0777;
fs.chmod('/', mode, function(error) {});
fs.chmodSync('/', mode);
var chmod = 0777;
var util = require('util');
function Controller($stateParams) {}
var stringUtil = {};
var params = {};
element.src = 'https://youtu.be/dQw4w9WgXcQ';
var data = { videoSrc: 'youtube' };
for (var i = 0; i < array.length; i++) {}
You can also allow (and later disallow) words on a per-file (or per-line) basis:
// jscs:allowWords concat, dest, dist, src
grunt.initConfig({
concat: {
dist: {
src: ['src/*.js'],
dest: 'dist/scripts.js'
}
}
});
// jscs:allowWords mx
dsn.resolveMx('example.com', function (error, addresses) {
var mx = addresses[0];
});
// jscs:disallowWords mx
var mx = Math.max(5, 0); // invalid