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-no-jquery

v3.0.2

Published

Disallow jQuery functions with native equivalents.

Downloads

572,344

Readme

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:

  • constructorAliases - An array of aliases for the jQuery constructor. Defaults to [ "$", "jQuery" ].
  • variablePattern - Regular expression pattern for matching jQuery variables. Defaults to "^\\$.". This pattern can be enforced with the no-jquery/variable-pattern rule.
  • collectionReturningPlugins - An object describing the return types of jQuery plugins. Keys are plugin method names, and values can be one of:
    • 'always' a plugin which always returns a jQuery collection.
      • e.g. $bar = $foo.stop()
    • 'accessor' a plugin which only returns a jQuery collection when an argument is given.
      • e.g. w = $foo.width(), $bar = $foo.width( 200 )
    • 'valueAccessor' a plugin which only returns a jQuery collection when more than one argument is given.
      • e.g. w = $foo.css( 'width' ), $bar = $foo.css( 'width', '1em' )
    • 'never' (default) a plugin which never returns a jQuery collection.
      • e.g. arr = $foo.toArray()
{
  "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.