diff --git a/README.md b/README.md index 59ff02fa..ebb8a51c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ npm install --save-dev eslint eslint-plugin-n **Note:** It recommends a use of [the "engines" field of package.json](https://docs.npmjs.com/files/package.json#engines). The "engines" field is used by `n/no-unsupported-features/*` rules. -**.eslintrc.json** (An example) +### **.eslintrc.json** (An example) ```jsonc { @@ -27,19 +27,26 @@ npm install --save-dev eslint eslint-plugin-n "ecmaVersion": 2020 }, "rules": { - "n/exports-style": ["error", "module.exports"], - "n/file-extension-in-import": ["error", "always"], - "n/prefer-global/buffer": ["error", "always"], - "n/prefer-global/console": ["error", "always"], - "n/prefer-global/process": ["error", "always"], - "n/prefer-global/url-search-params": ["error", "always"], - "n/prefer-global/url": ["error", "always"], - "n/prefer-promises/dns": "error", - "n/prefer-promises/fs": "error" + "n/exports-style": ["error", "module.exports"] } } ``` +### `eslint.config.js` + +```js +const nodeRecommended = require("eslint-plugin-n/configs/recommended") + +module.exports = [ + nodeRecommended, + { + rules: { + "n/exports-style": ["error", "module.exports"] + } + } +] +``` + **package.json** (An example) ```json diff --git a/configs/recommended-module.js b/configs/recommended-module.js new file mode 100644 index 00000000..99d500de --- /dev/null +++ b/configs/recommended-module.js @@ -0,0 +1,13 @@ +/** + * @fileoverview the `recommended-module` config for `eslint.config.js` + * @author 唯然 + */ + +"use strict" + +const { configs, rules } = require("../lib/index.js") + +module.exports = { + plugins: { n: { rules } }, + rules: configs["recommended-module"].rules, +} diff --git a/configs/recommended-script.js b/configs/recommended-script.js new file mode 100644 index 00000000..755714b9 --- /dev/null +++ b/configs/recommended-script.js @@ -0,0 +1,13 @@ +/** + * @fileoverview the `recommended-script` config for `eslint.config.js` + * @author 唯然 + */ + +"use strict" + +const { configs, rules } = require("../lib/index.js") + +module.exports = { + plugins: { n: { rules } }, + rules: configs["recommended-script"].rules, +} diff --git a/configs/recommended.js b/configs/recommended.js new file mode 100644 index 00000000..073ac071 --- /dev/null +++ b/configs/recommended.js @@ -0,0 +1,13 @@ +/** + * @fileoverview the `recommended` config for `eslint.config.js` + * @author 唯然 + */ + +"use strict" + +const { configs, rules } = require("../lib/index.js") + +module.exports = { + plugins: { n: { rules } }, + rules: configs.recommended.rules, +} diff --git a/package.json b/package.json index 166592ce..6f4eff81 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ }, "main": "lib/index.js", "files": [ - "lib" + "lib/", + "configs/" ], "peerDependencies": { "eslint": ">=7.0.0"