-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: Update shouldUseFlatConfig and CLI so flat config is default #17748
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
Tests are failing because rules are being called with syntax that isn't supported in those older Node.js versions. Need to investigate why that's happening. |
This PR timely! I was just about to open a related docs issue: https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-file-resolution
I think this should guide developers to set the variable to |
Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update. |
tests/lib/cli.js
Outdated
const configPath = getFixturePath(".eslintrc"); | ||
const filePath = getFixturePath("passing.js"); | ||
|
||
await cli.execute(`--config ${configPath} ${filePath}`, null, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After these changes, npm test
will be logging more than 100 deprecation warnings until we drop eslintrc in v10.
Can we avoid that?
allowFlatConfig = false
is passed only from tests, so we could update the condition in lib/cli.js
to avoid logging warnings while running tests:
-if (!usingFlatConfig) {
+if (allowFlatConfig && !usingFlatConfig) {
process.emitWarning("You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details.", "ESLintRCWarning");
}
Then, we could update this test this way to make it work:
await cli.execute(`--config ${configPath} ${filePath}`, null, false); | |
const localCLI = proxyquire("../../lib/cli", { | |
"./eslint/flat-eslint": { shouldUseFlatConfig: () => Promise.resolve(false) } | |
}); | |
await localCLI.execute(`--config ${configPath} ${filePath}`); |
Or, perhaps even better, merge this test into the test for ESLINT_USE_FLAT_CONFIG=false
as that's anyway the most realistic test:
it(`should not use it when ESLINT_USE_FLAT_CONFIG=false even if an eslint.config.js is present:${configType}`, async () => {
process.env.ESLINT_USE_FLAT_CONFIG = "false";
process.cwd = getFixturePath;
const exitCode = await cli.execute(`--no-ignore --ext .js ${getFixturePath("files")}`, null, useFlatConfig);
assert.strictEqual(exitCode, 0);
+ if (useFlatConfig) {
+ assert.strictEqual(processStub.callCount, 1, "calls `process.emitWarning()` once");
+ assert.strictEqual(processStub.getCall(0).args[1], "ESLintRCWarning");
+ }
});
That would leave npm test
with zero eslintrc deprecation warnings (assuming #17797 will be merged; those tests pass allowFlatConfig = true
but mistakenly still work in eslintc mode, so they're mistakenly logging deprecation warnings).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, I went with the second approach.
Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might fix merge conflicts.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Updates
shouldUseFlatConfig()
to returntrue
unless theESLINT_USE_FLAT_CONFIG
environment variable is"false"
.Also ensures the CLI emits a warning when eslintrc is used.
Refs #13481
Is there anything you'd like reviewers to focus on?