Package Exports
- eslint-plugin-requirejs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-requirejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
eslint-plugin-requirejs
Enforce code conventions for RequireJS modules with ESLint.
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.
Installation
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.
Global Installation
$ npm install -g eslint
$ npm install -g eslint-plugin-requirejsLocal Installation
$ npm install --save-dev eslint
$ npm install --save-dev eslint-plugin-requirejsConfiguration
Add the 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:
{
"plugins": [
"requirejs"
]
}Enable the rules that you would like to use, for example:
{
"rules": {
"requirejs/no-invalid-define": 2,
"requirejs/no-multiple-define": 2,
"requirejs/no-named-define": 2,
"requirejs/no-commonjs-wrapper": 2,
"requirejs/no-object-define": 1
}
}List of supported rules
Possible Errors
- no-invalid-define: Disallow invalid module definitions
- no-invalid-require: Disallow invalid
requireorrequirejscalls - no-multiple-define: Disallow multiple module definitions in one file
- no-assign-exports: Disallow assignment to
exportswhen using Simplified CommonJS Wrapper - no-js-extension: Disallow
.jsextension in dependency paths
Stylistic Choices
- no-object-define: Disallow Simple Name/Value Pairs form of
define(off by default) - no-function-define: Disallow Simple Function form of
define(off by default) - no-amd-define: Disallow AMD (dependency array) form of
define(off by default) - no-named-define: Disallow named module form of
define(off by default) - no-commonjs-wrapper: Disallow use of Simplified CommonJS Wrapper (off by default)
- no-commonjs-return: Disallow use of
returnstatement in a module definition when using Simplified CommonJS Wrapper (off by default) - no-commonjs-exports: Disallow use of
exportsin a module definition when using Simplified CommonJS Wrapper (off by default) - no-commonjs-module-exports: Disallow use of
module.exportsin a module definition when using Simplified CommonJS Wrapper (off by default) - no-dynamic-require: Disallow use of dynamically generated paths in a
requirecall (off by default) - no-conditional-require: Disallow use of conditional
requirecalls (off by default) - no-assign-require: Disallow assignment to
requireorwindow.require(off by default) - no-require-tourl: Disallow use of
require.toUrlandrequire.nameToUrl(off by default) - enforce-define: Require that all files be wrapped in a
definecall (off by default)
Don't see the rule you're looking for?
Take a look at what's in progress for the next milestone, or suggest a new rule by filing an issue.
Contributing
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
License
eslint-plugin-requirejs is licensed under the MIT License.