Skip to content

Commit

Permalink
feat: Replace deprecated eslint-plugin-node with eslint-plugin-n (#119)
Browse files Browse the repository at this point in the history
eslint-plugin-node is deprecated now.

BREAKING CHANGE: Since we switched from eslint-plugin-node to eslint-plugin-n, this may introduce new ESLint errors in Node projects.
  • Loading branch information
jhnns committed Mar 22, 2024
1 parent 4c5b1fd commit f0d0521
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 29 deletions.
17 changes: 3 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ npm i eslint eslint-config-peerigon eslint-plugin-react eslint-plugin-jsx-a11y e
### TypeScript + Node

```
npm i eslint eslint-config-peerigon eslint-plugin-node --save-dev
npm i eslint eslint-config-peerigon eslint-plugin-n --save-dev
```

```js
Expand Down Expand Up @@ -249,10 +249,10 @@ _We recommend using [`peerigon/styles/prefer-arrow`](#peerigonstylesprefer-arrow

### [`peerigon/node`](node.js)

**Important: Requires [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node).**
**Important: Requires [`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n).**

```
npm i eslint-plugin-node --save-dev
npm i eslint-plugin-n --save-dev
```

```js
Expand All @@ -266,17 +266,6 @@ npm i eslint-plugin-node --save-dev
}
```

[`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node) uses the ["engines" field](https://docs.npmjs.com/files/package.json#engines) and the ["type" field](https://nodejs.org/api/esm.html#esm_enabling) in your `package.json` to check for compatibility issues. We recommend the following configuration:

```json
{
"type": "module",
"engines": {
"node": ">=14.0.0"
}
}
```

### [`peerigon/react`](react.js)

**Important: Requires [`eslint-plugin-react`](https://github.com/yannickcr/eslint-plugin-react), [`eslint-plugin-jsx-a11y`](https://github.com/evcohen/eslint-plugin-jsx-a11y) and [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks) as project dependency.**
Expand Down
18 changes: 9 additions & 9 deletions node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module.exports = {
plugins: ["node"],
extends: ["plugin:node/recommended"],
extends: ["plugin:n/recommended"],
env: {
node: true,
},
Expand All @@ -14,25 +14,25 @@ module.exports = {
},
rules: {
/* eslint-enable sort-keys */
"node/callback-return": "warn", // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/callback-return.md
"node/global-require": "off", // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/global-require.md
"node/handle-callback-err": ["warn", "^(err|error)$"], // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/handle-callback-err
"node/no-mixed-requires": [
"n/callback-return": "warn", // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/callback-return.md
"n/global-require": "off", // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/global-require.md
"n/handle-callback-err": ["warn", "^(err|error)$"], // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/handle-callback-err
"n/no-mixed-requires": [
"warn",
{
allowCall: true,
grouping: false,
},
], // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-mixed-requires.md
"node/no-new-require": "warn", // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-new-require.md
"node/no-path-concat": "warn", // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-path-concat.md
], // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-mixed-requires.md
"n/no-new-require": "warn", // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-new-require.md
"n/no-path-concat": "warn", // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-path-concat.md
// process.exit() is often used in situations where it would have been better to either throw an error or
// let the process exit by itself.
// There are situations where process.exit() is the cause of truncated stdout output,
// see https://nodejs.org/api/process.html#process_process_exit_code
// If you want to set the exit code, you can also use process.exitCode.
// Disable this rule if you have to exit the process forcefully and you know what you're doing.
"node/no-process-exit": "warn", // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-process-exit.md
"n/no-process-exit": "warn", // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-process-exit.md
/* eslint-disable sort-keys */
},
};
Loading

0 comments on commit f0d0521

Please sign in to comment.