Skip to content

Commit 617cca9

Browse files
committed
ESLint: use the --rulesdir option for internal rules.
Motivation: We need to have a way to have internal ESLint rules. ESLint allows you to import rules in two ways: 1. As an npm package, it is problematic for internal rules since we don't want to publish it on NPM. So in the past, we used NPM-specific workarounds to treat a directory as a package. 2. `--rulesdir` CLI option, the problem with it is deprecated. ESLint team is planning to deprecate the current config format and switch to: https://eslint.org/docs/latest/use/configure/configuration-files-new This format forces you to import plugins manually, and it entirely resolves our problem with internal rules. But it requires that all plugins that we use to support this format. I propose to temporarily switch to `--rulesdir` and start working on changing to the new format since the entire config format will be deprecated anyway. This switch will unblock support for node@19 in CI and local development and unblock graphql#3848.
1 parent f201681 commit 617cca9

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

.eslintrc.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ env:
55
shared-node-browser: true
66
reportUnusedDisableDirectives: true
77
plugins:
8-
- internal-rules
98
- node
109
- import
1110
- simple-import-sort
@@ -22,9 +21,9 @@ rules:
2221
# See './resources/eslint-internal-rules/README.md'
2322
##############################################################################
2423

25-
internal-rules/only-ascii: error
26-
internal-rules/no-dir-import: error
27-
internal-rules/require-to-string-tag: off
24+
only-ascii: error
25+
no-dir-import: error
26+
require-to-string-tag: off
2827

2928
##############################################################################
3029
# `eslint-plugin-node` rule list based on `v11.1.x`
@@ -658,10 +657,10 @@ overrides:
658657
'@typescript-eslint/type-annotation-spacing': off
659658
- files: 'src/**'
660659
rules:
661-
internal-rules/require-to-string-tag: error
660+
require-to-string-tag: error
662661
- files: 'src/**/__*__/**'
663662
rules:
664-
internal-rules/require-to-string-tag: off
663+
require-to-string-tag: off
665664
node/no-unpublished-import: [error, { allowModules: ['chai', 'mocha'] }]
666665
import/no-deprecated: off
667666
import/no-restricted-paths: off
@@ -700,7 +699,7 @@ overrides:
700699
env:
701700
node: true
702701
rules:
703-
internal-rules/only-ascii: [error, { allowEmoji: true }]
702+
only-ascii: [error, { allowEmoji: true }]
704703
node/no-unpublished-import: off
705704
node/no-sync: off
706705
import/no-namespace: off

package-lock.json

Lines changed: 1 addition & 9 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"changelog": "ts-node resources/gen-changelog.ts",
3636
"benchmark": "ts-node resources/benchmark.ts",
3737
"test": "npm run lint && npm run check && npm run testonly:cover && npm run prettier:check && npm run check:spelling && npm run check:integrations",
38-
"lint": "eslint --cache --max-warnings 0 .",
38+
"lint": "eslint --cache --max-warnings 0 --rulesdir resources/eslint-internal-rules/ .",
3939
"check": "tsc --pretty",
4040
"testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts",
4141
"testonly:cover": "c8 npm run testonly",
@@ -75,7 +75,6 @@
7575
"docusaurus-plugin-typedoc-api": "2.5.0",
7676
"eslint": "8.27.0",
7777
"eslint-plugin-import": "2.26.0",
78-
"eslint-plugin-internal-rules": "file:./resources/eslint-internal-rules",
7978
"eslint-plugin-node": "11.1.0",
8079
"eslint-plugin-react": "7.31.10",
8180
"eslint-plugin-react-hooks": "4.6.0",

resources/build-docusaurus.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ fs.writeFileSync(tmpDirPath('package.json'), JSON.stringify(packageJSON));
1414

1515
copyToTmpDir('package-lock.json');
1616
copyToTmpDir('tsconfig.json');
17-
copyToTmpDir('resources/eslint-internal-rules');
1817
copyToTmpDir('src');
1918
copyToTmpDir('website');
2019

0 commit comments

Comments
 (0)