Skip to content

Commit

Permalink
feat: support eslint.config.js (fixes #89)
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Apr 21, 2023
1 parent aa75610 commit 3830d3e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
27 changes: 17 additions & 10 deletions README.md
Expand Up @@ -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
{
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions configs/recommended-module.js
@@ -0,0 +1,13 @@
/**
* @fileoverview the `recommended-module` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

"use strict"

const { configs, rules } = require("../lib/index.js")

module.exports = {
plugins: { n: { rules } },
rules: configs["recommended-module"].rules,
}
13 changes: 13 additions & 0 deletions configs/recommended-script.js
@@ -0,0 +1,13 @@
/**
* @fileoverview the `recommended-script` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

"use strict"

const { configs, rules } = require("../lib/index.js")

module.exports = {
plugins: { n: { rules } },
rules: configs["recommended-script"].rules,
}
13 changes: 13 additions & 0 deletions configs/recommended.js
@@ -0,0 +1,13 @@
/**
* @fileoverview the `recommended` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

"use strict"

const { configs, rules } = require("../lib/index.js")

module.exports = {
plugins: { n: { rules } },
rules: configs.recommended.rules,
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -7,7 +7,8 @@
},
"main": "lib/index.js",
"files": [
"lib"
"lib/",
"configs/"
],
"peerDependencies": {
"eslint": ">=7.0.0"
Expand Down

0 comments on commit 3830d3e

Please sign in to comment.