Skip to content

Commit 80d44a4

Browse files
eslint: replace unmaintained 'node' plugin with it's fork (#3882)
1 parent d45e48b commit 80d44a4

File tree

4 files changed

+107
-127
lines changed

4 files changed

+107
-127
lines changed

.eslintrc.cjs

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ module.exports = {
77
'shared-node-browser': true,
88
},
99
reportUnusedDisableDirectives: true,
10-
plugins: ['node', 'import', 'simple-import-sort'],
10+
plugins: ['n', 'import', 'simple-import-sort'],
1111
settings: {
12-
node: {
13-
tryExtensions: ['.js', '.ts', '.jsx', '.json', '.node', '.d.ts'],
14-
},
1512
// eslint-plugin-import tries to parse all imported files included huge ones (e.g. 'typescript')
1613
// that leads to very poor perfomance so to fix that we disable all checks on external files.
1714
'import/ignore': '/node_modules/',
@@ -26,57 +23,54 @@ module.exports = {
2623
'require-to-string-tag': 'off',
2724

2825
//////////////////////////////////////////////////////////////////////////////
29-
// `eslint-plugin-node` rule list based on `v11.1.x`
26+
// `eslint-plugin-n` rule list based on `v15.7.x`
3027
//////////////////////////////////////////////////////////////////////////////
3128

3229
// Possible Errors
33-
// https://github.com/mysticatea/eslint-plugin-node#possible-errors
34-
'node/handle-callback-err': ['error', 'error'],
35-
'node/no-callback-literal': 'error',
36-
'node/no-exports-assign': 'error',
37-
'node/no-extraneous-import': 'error',
38-
'node/no-extraneous-require': 'error',
39-
'node/no-missing-import': 'off', // TODO: Blocked by https://github.com/mysticatea/eslint-plugin-node/issues/248
40-
'node/no-missing-require': 'error',
41-
'node/no-new-require': 'error',
42-
'node/no-path-concat': 'error',
43-
'node/no-process-exit': 'off',
44-
'node/no-unpublished-bin': 'error',
45-
'node/no-unpublished-import': 'error',
46-
'node/no-unpublished-require': 'error',
47-
'node/no-unsupported-features/es-builtins': 'error',
48-
'node/no-unsupported-features/es-syntax': [
49-
'error',
50-
{ ignores: ['modules'] },
51-
],
52-
'node/no-unsupported-features/node-builtins': 'error',
53-
'node/process-exit-as-throw': 'error',
54-
'node/shebang': 'error',
30+
// https://github.com/eslint-community/eslint-plugin-n#possible-errors
31+
'n/handle-callback-err': ['error', 'error'],
32+
'n/no-callback-literal': 'error',
33+
'n/no-exports-assign': 'error',
34+
'n/no-extraneous-import': 'error',
35+
'n/no-extraneous-require': 'error',
36+
'n/no-missing-import': 'error',
37+
'n/no-missing-require': 'error',
38+
'n/no-new-require': 'error',
39+
'n/no-path-concat': 'error',
40+
'n/no-process-exit': 'off',
41+
'n/no-unpublished-bin': 'error',
42+
'n/no-unpublished-import': 'error',
43+
'n/no-unpublished-require': 'error',
44+
'n/no-unsupported-features/es-builtins': 'error',
45+
'n/no-unsupported-features/es-syntax': ['error', { ignores: ['modules'] }],
46+
'n/no-unsupported-features/node-builtins': 'error',
47+
'n/process-exit-as-throw': 'error',
48+
'n/shebang': 'error',
5549

5650
// Best Practices
57-
// https://github.com/mysticatea/eslint-plugin-node#best-practices
58-
'node/no-deprecated-api': 'error',
51+
// https://github.com/eslint-community/eslint-plugin-n#best-practices
52+
'n/no-deprecated-api': 'error',
5953

6054
// Stylistic Issues
61-
// https://github.com/mysticatea/eslint-plugin-node#stylistic-issues
62-
'node/callback-return': 'error',
63-
'node/exports-style': 'off', // TODO: consider
64-
'node/file-extension-in-import': 'off', // TODO: consider
65-
'node/global-require': 'error',
66-
'node/no-mixed-requires': 'error',
67-
'node/no-process-env': 'off',
68-
'node/no-restricted-import': 'off',
69-
'node/no-restricted-require': 'off',
70-
'node/no-sync': 'error',
71-
'node/prefer-global/buffer': 'error',
72-
'node/prefer-global/console': 'error',
73-
'node/prefer-global/process': 'error',
74-
'node/prefer-global/text-decoder': 'error',
75-
'node/prefer-global/text-encoder': 'error',
76-
'node/prefer-global/url-search-params': 'error',
77-
'node/prefer-global/url': 'error',
78-
'node/prefer-promises/dns': 'off',
79-
'node/prefer-promises/fs': 'off',
55+
// https://github.com/eslint-community/eslint-plugin-n#stylistic-issues
56+
'n/callback-return': 'error',
57+
'n/exports-style': 'off', // TODO: consider
58+
'n/file-extension-in-import': 'error',
59+
'n/global-require': 'error',
60+
'n/no-mixed-requires': 'error',
61+
'n/no-process-env': 'off',
62+
'n/no-restricted-import': 'off',
63+
'n/no-restricted-require': 'off',
64+
'n/no-sync': 'error',
65+
'n/prefer-global/buffer': 'error',
66+
'n/prefer-global/console': 'error',
67+
'n/prefer-global/process': 'error',
68+
'n/prefer-global/text-decoder': 'error',
69+
'n/prefer-global/text-encoder': 'error',
70+
'n/prefer-global/url-search-params': 'error',
71+
'n/prefer-global/url': 'error',
72+
'n/prefer-promises/dns': 'off',
73+
'n/prefer-promises/fs': 'off',
8074

8175
//////////////////////////////////////////////////////////////////////////////
8276
// `eslint-plugin-import` rule list based on `v2.27.x`
@@ -705,7 +699,7 @@ module.exports = {
705699
files: 'src/**/__*__/**',
706700
rules: {
707701
'require-to-string-tag': 'off',
708-
'node/no-unpublished-import': [
702+
'n/no-unpublished-import': [
709703
'error',
710704
{ allowModules: ['chai', 'mocha'] },
711705
],
@@ -723,8 +717,8 @@ module.exports = {
723717
node: true,
724718
},
725719
rules: {
726-
'node/no-sync': 'off',
727-
'node/no-unpublished-import': ['error', { allowModules: ['mocha'] }],
720+
'n/no-sync': 'off',
721+
'n/no-unpublished-import': ['error', { allowModules: ['mocha'] }],
728722
'import/no-extraneous-dependencies': [
729723
'error',
730724
{ devDependencies: true },
@@ -742,9 +736,10 @@ module.exports = {
742736
node: true,
743737
},
744738
rules: {
745-
'node/no-sync': 'off',
739+
'n/no-sync': 'off',
746740
'import/no-nodejs-modules': 'off',
747741
'no-console': 'off',
742+
'n/no-missing-import': ['error', { allowModules: ['graphql'] }],
748743
},
749744
},
750745
{
@@ -756,8 +751,9 @@ module.exports = {
756751
node: true,
757752
},
758753
rules: {
759-
'node/no-sync': 'off',
760-
'node/no-extraneous-import': ['error', { allowModules: ['graphql'] }],
754+
'n/no-sync': 'off',
755+
'n/no-missing-import': ['error', { allowModules: ['graphql'] }],
756+
'n/no-extraneous-import': ['error', { allowModules: ['graphql'] }],
761757
'import/no-unresolved': 'off',
762758
'import/no-namespace': 'off',
763759
'import/no-nodejs-modules': 'off',
@@ -771,8 +767,8 @@ module.exports = {
771767
},
772768
rules: {
773769
'only-ascii': ['error', { allowEmoji: true }],
774-
'node/no-unpublished-import': 'off',
775-
'node/no-sync': 'off',
770+
'n/no-unpublished-import': 'off',
771+
'n/no-sync': 'off',
776772
'import/no-namespace': 'off',
777773
'import/no-extraneous-dependencies': [
778774
'error',
@@ -800,7 +796,7 @@ module.exports = {
800796
},
801797
},
802798
rules: {
803-
'node/no-unpublished-import': 'off',
799+
'n/no-unpublished-import': 'off',
804800
'import/no-default-export': 'off',
805801
},
806802
},
@@ -818,12 +814,13 @@ module.exports = {
818814
},
819815
rules: {
820816
'no-restricted-exports': 'off',
821-
'node/no-unpublished-require': 'off',
817+
'n/no-unpublished-require': 'off',
822818
'import/no-default-export': 'off',
823819
'import/no-commonjs': 'off',
824820
'import/no-nodejs-modules': 'off',
825821
'import/no-extraneous-dependencies': 'off',
826822
// Ignore docusarus related webpack aliases
823+
'n/no-missing-import': 'off',
827824
'import/no-unresolved': [
828825
'error',
829826
{ ignore: ['^@theme', '^@docusaurus', '^@generated'] },

integrationTests/webpack/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import assert from 'assert';
22

3+
/* eslint-disable n/no-missing-import */
34
import cjs from './dist/main-cjs.cjs';
45
import mjs from './dist/main-mjs.cjs';
6+
/* eslint-enable n/no-missing-import */
57

68
assert.deepStrictEqual(cjs.result, {
79
data: {

package-lock.json

Lines changed: 49 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"docusaurus-plugin-typedoc-api": "2.5.1",
7676
"eslint": "8.34.0",
7777
"eslint-plugin-import": "2.27.5",
78-
"eslint-plugin-node": "11.1.0",
78+
"eslint-plugin-n": "15.7.0",
7979
"eslint-plugin-react": "7.32.2",
8080
"eslint-plugin-react-hooks": "4.6.0",
8181
"eslint-plugin-simple-import-sort": "10.0.0",

0 commit comments

Comments
 (0)