npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-speller

v0.3.1

Published

Spell checker for JS files

Downloads

640

Readme

eslint-plugin-speller

Spell checker for code, eg. Literals, Identifiers, Template Literals and Comments

The rule validates the names of variables and functions. Validates the content of strings and comments. It is very useful in detecting potential typos, often unconscious and difficult to detect organoleptically, which unfortunately often lead to errors in code evaluation (once you use the correct name, a few lines later you make a typo). Applying this rule also increases code quality.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-speller:

$ npm install eslint-plugin-speller --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-speller globally.

The plugin uses nspell (hunspell compatible spell checker). By default, dictionary-en-us is used. If you want use other language you must install additional dictionaries from https://github.com/wooorm/dictionaries. For example, if you want to use Polish, you should install the dictionary-pl package:

$ npm install dictionary-pl --save-dev

Usage

Add speller to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["speller"]
}

This plugin has only one rule. Enter the following configuration:

{
  "rules": {
    "speller/speller": "warn"
  }
}

Rule details

Examples of incorrect code for this rule:

var incorrrectVariable = "This is incorrect variable name";
var incorrectLiteral = "This is incorrect littteerall";
var incorrectComment = "This is incorrect comment"; // Incorrrecct commment

Examples of correct code for this rule:

var correctVariable = "This is correct variable";
var correctLiteral = "This is correct literal";
var correctComment = "This is correct comment"; // correct comment

Options

This rule accepts a single options argument:

  • Set the comments option to false if you want disable linting a comments (line or block). Default is true.
  • Set the literals option to false if tou want disable linting a literals (simple Literals or Template Literals). Default is true
  • Set the identifiers option to false if you want disable linting a identifiers (eg. name of variables or functions). Default is true.
  • Set the dictionary option to the name of the npm dictionary package that is compatible with nspell. A list of dictionaries is available here -> https://github.com/wooorm/dictionaries. You must install the additional package on your own. The default is dictionary-en-us - you don't have to install it separately. It accepts Array or String.
  • Set the customDictionary option to a list of your own words that do not appear in the dictionary.
  • Set the attachItWords option to false if you want disable attach IT words from speller-it-words package
  • Set the suggest option to false if you want disable suggest similar word
  • Set the cache option to false if you want disable cache result of word spelling and suggest similar word

Example option:

{
  "comments": true,
  "literals": true,
  "identifiers": true,
  "dictionary": ["dictionary-en-us", "dictionary-pl"],
  "customDictionary": ["yourcustomword"],
  "attachItWords": true,
  "suggest": true,
  "cache": true
}

Example configuration:

"plugins": [
   "speller"
],
"rules": {
   "speller/speller": ["warn",
       {
            "comments": true,
            "literals": true,
            "identifiers": true,
            "dictionary": ["dictionary-en-us", "dictionary-pl"],
            "customDictionary": ["yourcustomword"],
            "attachItWords": "true",
            "suggest": true,
            "cache": true
        }
    ]
}

When Not To Use It

If you like typos or incomprehensible variable names, don't use this rule.

Further Reading

The rule uses the nspell package, which is responsible for checking the existence of a word in the dictionary. Thanks to wooorm.