diff --git a/README.md b/README.md index 7202480..f8b6788 100644 --- a/README.md +++ b/README.md @@ -56,38 +56,45 @@ Enable the rules that you would like to use, for example: } ``` +## 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 ### Possible Errors -| Rule | Description | -| :--- | :--- | -| [no-invalid-define](docs/rules/no-invalid-define.md) | Disallow invalid module definitions | -| [no-invalid-require](docs/rules/no-invalid-require.md) | Disallow invalid `require` or `requirejs` calls | -| [no-multiple-define](docs/rules/no-multiple-define.md) | Disallow multiple module definitions in one file | -| [no-assign-exports](docs/rules/no-assign-exports.md) | Disallow assignment to `exports` when using Simplified CommonJS Wrapper | -| [no-js-extension](docs/rules/no-js-extension.md) | Disallow `.js` extension in dependency paths | +| | Rule | Description | +| :----: | :--- | :---------- | +| :star: | [no-invalid-define](docs/rules/no-invalid-define.md) | Disallow invalid module definitions | +| :star: | [no-invalid-require](docs/rules/no-invalid-require.md) | Disallow invalid `require` or `requirejs` calls | +| :star: | [no-multiple-define](docs/rules/no-multiple-define.md) | Disallow multiple module definitions in one file | +| :star: | [no-assign-exports](docs/rules/no-assign-exports.md) | Disallow assignment to `exports` when using Simplified CommonJS Wrapper | +| :star: | [no-js-extension](docs/rules/no-js-extension.md) | Disallow `.js` extension in dependency paths | ### Stylistic Choices -| Rule | Description | -| :--- | :--- | -| [no-object-define](docs/rules/no-object-define.md) | Disallow Simple Name/Value Pairs form of `define` | -| [no-function-define](docs/rules/no-function-define.md) | Disallow Simple Function form of `define` | -| [no-amd-define](docs/rules/no-amd-define.md) | Disallow AMD (dependency array) form of `define` | -| [no-named-define](docs/rules/no-named-define.md) | Disallow named module form of `define` | -| [no-commonjs-wrapper](docs/rules/no-commonjs-wrapper.md) | Disallow use of Simplified CommonJS Wrapper | -| [no-commonjs-return](docs/rules/no-commonjs-return.md) | Disallow use of `return` statement in a module definition when using Simplified CommonJS Wrapper | -| [no-commonjs-exports](docs/rules/no-commonjs-exports.md) | Disallow use of `exports` in a module definition when using Simplified CommonJS Wrapper | -| [no-commonjs-module-exports](docs/rules/no-commonjs-module-exports.md) | Disallow use of `module.exports` in a module definition when using Simplified CommonJS Wrapper | -| [no-dynamic-require](docs/rules/no-dynamic-require.md) | Disallow use of dynamically generated paths in a `require` call | -| [no-conditional-require](docs/rules/no-conditional-require.md) | Disallow use of conditional `require` calls | -| [no-assign-require](docs/rules/no-assign-require.md) | Disallow assignment to `require` or `window.require` | -| [no-require-tourl](docs/rules/no-require-tourl.md) | Disallow use of `require.toUrl` and `require.nameToUrl` | -| [enforce-define](docs/rules/enforce-define.md) | Require that all files be wrapped in a `define` call | -| [one-dependency-per-line](docs/rules/one-dependency-per-line.md) | Enforce line-break rules for AMD dependencies | -| [amd-function-arity](docs/rules/amd-function-arity.md) | Ensure AMD callbacks have correct number of parameters | -| [sort-amd-paths](docs/rules/sort-amd-paths.md) | Ensure that required paths are in alphabetical order | +| | Rule | Description | +| :----: | :--- | :---------- | +| | [no-object-define](docs/rules/no-object-define.md) | Disallow Simple Name/Value Pairs form of `define` | +| | [no-function-define](docs/rules/no-function-define.md) | Disallow Simple Function form of `define` | +| | [no-amd-define](docs/rules/no-amd-define.md) | Disallow AMD (dependency array) form of `define` | +| | [no-named-define](docs/rules/no-named-define.md) | Disallow named module form of `define` | +| | [no-commonjs-wrapper](docs/rules/no-commonjs-wrapper.md) | Disallow use of Simplified CommonJS Wrapper | +| | [no-commonjs-return](docs/rules/no-commonjs-return.md) | Disallow use of `return` statement in a module definition when using Simplified CommonJS Wrapper | +| | [no-commonjs-exports](docs/rules/no-commonjs-exports.md) | Disallow use of `exports` in a module definition when using Simplified CommonJS Wrapper | +| | [no-commonjs-module-exports](docs/rules/no-commonjs-module-exports.md) | Disallow use of `module.exports` in a module definition when using Simplified CommonJS Wrapper | +| | [no-dynamic-require](docs/rules/no-dynamic-require.md) | Disallow use of dynamically generated paths in a `require` call | +| | [no-conditional-require](docs/rules/no-conditional-require.md) | Disallow use of conditional `require` calls | +| | [no-assign-require](docs/rules/no-assign-require.md) | Disallow assignment to `require` or `window.require` | +| | [no-require-tourl](docs/rules/no-require-tourl.md) | Disallow use of `require.toUrl` and `require.nameToUrl` | +| | [enforce-define](docs/rules/enforce-define.md) | Require that all files be wrapped in a `define` call | +| | [one-dependency-per-line](docs/rules/one-dependency-per-line.md) | Enforce line-break rules for AMD dependencies | +| | [amd-function-arity](docs/rules/amd-function-arity.md) | Ensure AMD callbacks have correct number of parameters | +| | [sort-amd-paths](docs/rules/sort-amd-paths.md) | Ensure that required paths are in alphabetical order | ### Don't see the rule you're looking for? diff --git a/index.js b/index.js index d768f75..18462b1 100644 --- a/index.js +++ b/index.js @@ -23,5 +23,19 @@ module.exports = { "one-dependency-per-line": require("./lib/rules/one-dependency-per-line"), "amd-function-arity": require("./lib/rules/amd-function-arity"), "sort-amd-paths": require("./lib/rules/sort-amd-paths") + }, + configs: { + recommended: { + env: { + amd: true + }, + rules: { + "requirejs/no-invalid-define": "error", + "requirejs/no-invalid-require": "error", + "requirejs/no-multiple-define": "error", + "requirejs/no-assign-exports": "error", + "requirejs/no-js-extension": "error" + } + } } };