Skip to content

Commit

Permalink
Switch to eslint-plugin-n
Browse files Browse the repository at this point in the history
I noticed some odd behavior in the Node.js linter. The original `eslint-plugin-node` does not seem to be maintained anymore. Let's switch to the fork [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n).

Also see bufbuild/protobuf-es#614
  • Loading branch information
timostamm committed Nov 16, 2023
1 parent f8f132a commit 1843c4f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 97 deletions.
44 changes: 16 additions & 28 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
"packages/*/dist/**",
"node_modules/**",
],
plugins: ["@typescript-eslint", "node", "import"],
plugins: ["@typescript-eslint", "n", "import"],
// Rules and settings that do not require a non-default parser
extends: ["eslint:recommended"],
rules: {
Expand Down Expand Up @@ -68,35 +68,23 @@ module.exports = {
{
files: ["**/*.{js,mjs,cjs}"],
parserOptions: {
ecmaVersion: 2020,
ecmaVersion: 13, // ES2022 - https://eslint.org/docs/latest/use/configure/language-options#specifying-environments
},
extends: ["eslint:recommended", "plugin:node/recommended"],
extends: ["eslint:recommended", "plugin:n/recommended"],
rules: {
"node/shebang": "off", // this plugin only determines shebang necessary for files that are in a package.json "bin" field
"node/exports-style": ["error", "module.exports"],
"node/file-extension-in-import": ["error", "always"],
"node/prefer-global/buffer": ["error", "always"],
"node/prefer-global/console": ["error", "always"],
"node/prefer-global/process": ["error", "always"],
"node/prefer-global/url-search-params": ["error", "always"],
"node/prefer-global/url": ["error", "always"],
"node/prefer-promises/dns": "error",
"node/prefer-promises/fs": "error",
"no-process-exit": "off",
"node/no-unsupported-features/es-builtins": [
"error",
{
version: ">=16.0.0",
ignores: [],
},
],
"node/no-unsupported-features/node-builtins": [
"error",
{
version: ">=16.0.0",
ignores: [],
},
],
"n/shebang": "off", // this rule reports _any_ shebang outside of an npm binary as an error
"n/prefer-global/process": "off",
"n/no-process-exit": "off",
"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/url-search-params": ["error", "always"],
"n/prefer-global/url": ["error", "always"],
"n/prefer-promises/dns": "error",
"n/prefer-promises/fs": "error",
"n/no-unsupported-features/node-builtins": "error",
"n/no-unsupported-features/es-syntax": "error",
},
},
{
Expand Down
125 changes: 57 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"eslint": "^8.50.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": "^16.3.1",
"prettier": "^3.0.2",
"typescript": "5.2.2"
}
Expand Down

0 comments on commit 1843c4f

Please sign in to comment.