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
Installation
Install ESLint either locally or globally.
npm install eslintIf you installed ESLint globally, you have to install the RequireJS plugin globally too. Otherwise, install it locally.
$ npm install eslint-plugin-requirejsConfiguration
Add the plugins section to your config file and specify eslint-plugin-requirejs as a plugin.
{
"plugins": [
"requirejs"
]
}Enable the rules that you would like to use.
{
"rules": {
"requirejs/no-invalid-define": 2,
"requirejs/no-multiple-define": 2,
"requirejs/no-object-define": 1,
"requirejs/no-function-define": 2,
"requirejs/no-amd-define": 0,
"requirejs/no-named-define": 2,
"requirejs/no-commonjs-wrapper": 2
}
}List of supported rules
- no-invalid-define: Disallow invalid module definitions
- no-multiple-define: Disallow multiple module definitions in one file
- 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)
To Do
- no-exports: Disallow assignment to
exportsormodule.exportswhen using CommonJS wrapper, prefer return instead - require-return: Enforce returning a value from module definition functions
- validate-relative: Make sure
requireis declared as a dependency if using relative dependency paths inside a module
License
eslint-plugin-requirejs is licensed under the MIT License.