jscs-spellcheck
v1.0.0
Published
JSCS Spellcheck Plugin
Downloads
1
Maintainers
Readme
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:
{
"plugins": [ "jscs-spellcheck" ],
"requireDictionaryWords": {
"dictionaries": [ "english", "english/american" ]
}
}
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" ]
}
Valid for mode true
var number = 1;
object['source'] = 2;
object.source = 3;
fileDirectory = 4;
Invalid for mode true
var num = 1;
obj['src'] = 2;
obj.src = 3;
fileDir = 4;
Valid for mode "dictionaries": [ "english/american" ]
, invalid for "english/british"
var color = 'papayawhip';
Valid for mode "dictionaries": [ "english/british" ]
, invalid for "english/american"
var colour = 'papayawhip';
Valid for mode "allowWords": [ "transclude" ]
var transclude = function() {};
var transcludeFunction = function() {};
return { transclude: function() {} };
Valid for mode "allowWordsInProperties": [ "chmod" ]
var mode = 0777;
fs.chmod('/', mode, function(error) {});
fs.chmodSync('/', mode);
Invalid for mode "allowWordsInProperties": [ "chmod" ]
var chmod = 0777;
Valid for mode "allowNamesAsIdentifiers": [ "$stateParams", "util" ]
var util = require('util');
function Controller($stateParams) {}
Invalid for mode "allowNamesAsIdentifiers": [ "$stateParams", "util" ]
var stringUtil = {};
var params = {};
Valid for mode "allowNamesAsProperties": [ "src" ]
element.src = 'https://youtu.be/dQw4w9WgXcQ';
Invalid for mode "allowNamesAsProperties": [ "src" ]
var data = { videoSrc: 'youtube' };
Invalid for mode "excludeWords": [ "i" ]
for (var i = 0; i < array.length; i++) {}
Error Suppression
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