Home

Awesome

<!-- This file is built by build-readme.js. Do not edit it directly; edit README.md.template instead. -->

eslint-plugin-no-jquery

Disallow jQuery functions, with suggestions for native equivalents where possible.

Originally a fork of eslint-plugin-jquery.

⬇️ Installation

You'll first need to install ESLint:

npm install eslint --save-dev

Next, install eslint-plugin-no-jquery:

npm install eslint-plugin-no-jquery --save-dev

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

🛠️ Usage

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

{
  "extends": "plugin:no-jquery/deprecated",
  "plugins": [
    "no-jquery"
  ]
}

📋 Configs

The config plugin:no-jquery/recommended includes the recommended rule no-jquery/variable-pattern which is required for method rules to work correctly.

The config plugin:no-jquery/deprecated includes all known deprecated and removed code, and is updated as new releases of jQuery come out. You can instead use configs targeting specific versions of jQuery if you know the environment in which your code will operate. There is a config for all minor versions from 1.0 to 3.6 (deprecated-1.0, ..., deprecated-3.7). Deprecation configs are cumulative, so they include all the rules for jQuery versions below them.

The config plugin:no-jquery/slim includes all features excluded from the official "slim" build of jQuery, specifically the ajax and effects modules.

The config plugin:no-jquery/all includes all methods and utilies and should be used when you are aiming to remove all jQuery usage from your code.

Alternatively, you can pick out rules individually (see below).

⚙️ Settings

The following global settings can be used under the no-jquery property to configure the linter:

{
  "settings": {
    "no-jquery": {
        "constructorAliases": [ "$", "jQuery" ],
        "variablePattern": "^\\$.|^element$",
        "collectionReturningPlugins": {
          "datePicker": "always"
        }
    }
  },
  "plugins": [
    "no-jquery"
  ]
}

📖 Rules

Rules with options are indicated with ⚙️. Rules which are fixable are indicated with 🔧.

Where rules are included in the configs recommended, slim, all or deprecated-X.X it is indicated below. Where rules are included in a config with non-default options this is indicated with a .

⚠️ Deprecated

🤖 Development

npm install
npm test

To update documentation after modifying a rule or its tests, use

npm run doc

To run a specific test or tests:

npm run testpath tests/rules/no-ajax

⚖️ License

Distributed under the MIT license. See LICENSE for details.