This plugin is under active development, and is updated frequently. Take a look at the CHANGELOG to see what's recently been added or fixed.
Install ESLint either locally or globally, and then install the plugin (see below). It is important to note that a global instance of ESLint can only use plugins that are also installed globally. A local instance of ESLint, however, can make use of both local and global ESLint plugins.
$ npm install -g eslint $ npm install -g eslint-plugin-requirejs
$ npm install --save-dev eslint $ npm install --save-dev eslint-plugin-requirejs
Installing Older Versions
Please note: this plugin requires Node 6.x or greater and ESLint version 3.x or greater. If you need to use it with an older version of Node or ESLint, you may install a specific, previous version of the plugin:
$ npm install --save-dev email@example.com
plugins section to your config file if not already present and specify
eslint-plugin-requirejs as a plugin. The
eslint-plugin- prefix may be omitted:
Enable the rules that you would like to use, for example:
This plugin provides the
plugin:requirejs/recommended preset config. Which does the following:
- Enables the
- Enables all recommended rules, indicated with a ⭐️ icon in the table below
List of supported rules
No rules are enabled by default. The
"extends": "plugin:requirejs/recommended" property in a configuration file enables the marked with a ⭐️.
--fix option on the command line automatically fixes problems reported by rules marked by a 🔧.
These rules relate to possible syntax or logic errors in your module definition:
|⭐️||no-invalid-define||Disallow invalid module definitions|
|⭐️||no-multiple-define||Disallow multiple module definitions in one file|
|⭐️||no-assign-exports||Disallow assignment to
These rules relate to style guidelines, and are therefore quite subjective:
|no-object-define||Disallow Simple Name/Value Pairs form of
|no-function-define||Disallow Simple Function form of
|no-amd-define||Disallow AMD (dependency array) form of
|no-named-define||Disallow named module form of
|no-commonjs-wrapper||Disallow use of Simplified CommonJS Wrapper|
|no-commonjs-return||Disallow use of
|no-commonjs-exports||Disallow use of
|no-commonjs-module-exports||Disallow use of
|no-dynamic-require||Disallow use of dynamically generated paths in a
|no-conditional-require||Disallow use of conditional
|no-assign-require||Disallow assignment to
|no-require-tourl||Disallow use of
|enforce-define||Require that all files be wrapped in a
|🔧||one-dependency-per-line||Enforce line-break rules for AMD dependencies|
|amd-function-arity||Ensure AMD callbacks have correct number of parameters|
|sort-amd-paths||Ensure that required paths are in alphabetical order|
|no-restricted-amd-modules||Disallow specific amd modules|
Don't see the rule you're looking for?
Contributions are encouraged. There are a few ways you can help:
- Filing issues - if you find a bug or would like to request a new rule or enhancement, file an issue
- Submitting pull requests - pick one of the open issues to work on and submit a pull request
eslint-plugin-requirejs is licensed under the MIT License.