Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
eslint-plugin-requirejs
Advanced tools
Enforce code conventions for RequireJS modules with ESLint
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.
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
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
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
}
}
This plugin provides the plugin:requirejs/recommended
preset config. Which does the following:
amd
environmentNo 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:.
These rules relate to possible syntax or logic errors in your module definition:
Rule | Description | ||
---|---|---|---|
:star: | no-invalid-define | Disallow invalid module definitions | |
:star: | no-invalid-require | Disallow invalid require or requirejs calls | |
:star: | no-multiple-define | Disallow multiple module definitions in one file | |
:star: | no-assign-exports | Disallow assignment to exports when using Simplified CommonJS Wrapper | |
:star: | no-js-extension | Disallow .js extension in dependency paths |
These rules relate to style guidelines, and are therefore quite subjective:
Rule | Description | ||
---|---|---|---|
no-object-define | Disallow Simple Name/Value Pairs form of define | ||
no-function-define | Disallow Simple Function form of define | ||
no-amd-define | Disallow AMD (dependency array) form of define | ||
no-named-define | Disallow named module form of define | ||
no-commonjs-wrapper | Disallow use of Simplified CommonJS Wrapper | ||
no-commonjs-return | Disallow use of return statement in a module definition when using Simplified CommonJS Wrapper | ||
no-commonjs-exports | Disallow use of exports in a module definition when using Simplified CommonJS Wrapper | ||
no-commonjs-module-exports | Disallow use of module.exports in a module definition when using Simplified CommonJS Wrapper | ||
no-dynamic-require | Disallow use of dynamically generated paths in a require call | ||
no-conditional-require | Disallow use of conditional require calls | ||
no-assign-require | Disallow assignment to require or window.require | ||
no-require-tourl | Disallow use of require.toUrl and require.nameToUrl | ||
enforce-define | Require that all files be wrapped in a define call | ||
:wrench: | 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 |
Take a look at what's in progress for the next milestone, or suggest a new rule by filing an issue.
Contributions are encouraged. There are a few ways you can help:
eslint-plugin-requirejs is licensed under the MIT License.
v4.0.1 - December 15, 2020
FAQs
Enforce code conventions for RequireJS modules with ESLint
The npm package eslint-plugin-requirejs receives a total of 3,952 weekly downloads. As such, eslint-plugin-requirejs popularity was classified as popular.
We found that eslint-plugin-requirejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.