Library to spell check variables and identifiers on javascript
npm install lintspelljs
npm install lintspelljs
``Usage
lintspelljs works from the comm and line using a simple CLI interface
``
lintspelljs
``
$3
``
Checking Spelling on: spellchecklint-cli.js
You have a mispelled Identifier JsSpellChecker mispelled: Js On Line: 4
You have a misspelled word on a String spellcheckvars On Line: 23
You have a misspelled word on a Comment spellcheckvars On Line: 24
``
Usage as a module
lintspelljs could be used as a module to check js files. Check lintint (https://www.npmjs.com/package/lintint) for an example of usage.
``javascript
var spellCheckerLib = require('lintspelljs');
var options = {
color: false
};
var spellChecker = new spellCheckerLib.JsSpellChecker(options);
var results = spellChecker.checkString('var variavle_fisrt = 1 + funktionKall(); // Tetsing');
``
Results will contain an Array of Objects with the following format:
``javascript
{
type: <>, // The type of the parsed string (one of 'identifier', 'string', 'comment')
message: <>, // There are three possible messages
line: <>, // The line number for the parsed string
word: <>, // The word which is checked
misspelled: <> // The result of the spell check (true if the word is misspelled)
}
``
Default options
``javascript
{
checkers: ['identifier', 'string', 'comment'], // locations where to check words
color: true, // If true, return colored and bold messages
hideSuccessful: true, // If true, return only the misspelled results
skipWords: [] // Additional words to ignore and do not mark as misspelled
}
``
Test
lintspelljs uses mocha for testing and chai for assertions.
You should have mocha installed globally to run tests.
``
npm install -g mocha
``
And to run the test you can use:
``
npm test
```