4.0.1 • Published 3 years ago

eslint-plugin-requirejs v4.0.1

Weekly downloads
16,844
License
MIT
Repository
github
Last release
3 years ago

npm Maintenance Status Build Status Coverage Status Package Quality

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-requirejs

Local Installation

$ 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 eslint-plugin-requirejs@3.2.0

Configuration

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
  }
}

Bundled Config

This plugin provides the plugin:requirejs/recommended preset config. Which does the following:

  • Enables the amd environment
  • Enables all recommended rules, indicated with a :star: 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 :star:.

The --fix option on the command line automatically fixes problems reported by rules marked by a :wrench:.

Possible Errors

These rules relate to possible syntax or logic errors in your module definition:

RuleDescription
:star:no-invalid-defineDisallow invalid module definitions
:star:no-invalid-requireDisallow invalid require or requirejs calls
:star:no-multiple-defineDisallow multiple module definitions in one file
:star:no-assign-exportsDisallow assignment to exports when using Simplified CommonJS Wrapper
:star:no-js-extensionDisallow .js extension in dependency paths

Stylistic Choices

These rules relate to style guidelines, and are therefore quite subjective:

RuleDescription
no-object-defineDisallow Simple Name/Value Pairs form of define
no-function-defineDisallow Simple Function form of define
no-amd-defineDisallow AMD (dependency array) form of define
no-named-defineDisallow named module form of define
no-commonjs-wrapperDisallow use of Simplified CommonJS Wrapper
no-commonjs-returnDisallow use of return statement in a module definition when using Simplified CommonJS Wrapper
no-commonjs-exportsDisallow use of exports in a module definition when using Simplified CommonJS Wrapper
no-commonjs-module-exportsDisallow use of module.exports in a module definition when using Simplified CommonJS Wrapper
no-dynamic-requireDisallow use of dynamically generated paths in a require call
no-conditional-requireDisallow use of conditional require calls
no-assign-requireDisallow assignment to require or window.require
no-require-tourlDisallow use of require.toUrl and require.nameToUrl
enforce-defineRequire that all files be wrapped in a define call
:wrench:one-dependency-per-lineEnforce line-break rules for AMD dependencies
amd-function-arityEnsure AMD callbacks have correct number of parameters
sort-amd-pathsEnsure that required paths are in alphabetical order
no-restricted-amd-modulesDisallow specific amd modules

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.

4.0.1

3 years ago

4.0.0

5 years ago

3.2.0

6 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.0

8 years ago

3.0.0-rc1

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

0.10.0

8 years ago

0.9.4

8 years ago

0.9.3

8 years ago

0.9.2

8 years ago

0.9.1

8 years ago

0.9.0

8 years ago

0.8.0

8 years ago

0.7.2

8 years ago

0.7.1

8 years ago

0.7.0

8 years ago

0.6.0

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago