-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
refactor: switch to eslint flat config #577
Conversation
eslint.config.js
Outdated
// eslintConfigEslint[3] is eslint-plugin-n's recommended-script config | ||
...eslintConfigEslint.slice(0, 3), | ||
{ | ||
files: ["**/*.js"], | ||
...nodeRecommendedModule | ||
}, | ||
{ | ||
files: ["**/*.cjs"], | ||
...nodeRecommendedScript | ||
}, | ||
...eslintConfigEslint.slice(4), |
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 is not very convenient, perhaps eslint-config-eslint
should export two configurations, one for CommonJS and one for ES Modules? Or 3 configurations: common, CommonJS-specific, and ESM-specific.
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.
👍 to 3 configs: the eslint-plugin-n
is not really needed for web projects like eslint.org.
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.
Is there a reason we can't just do ...eslintConfigESLint
?
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.
Is there a reason we can't just do
...eslintConfigESLint
?
We can't because it's a configuration for CommonJS modules.
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.
Ah, got it.
onToken: token => { | ||
onToken(token) { |
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 is because in the new eslint-config-eslint
the option avoidExplicitReturnArrows: true
is set.
function translateTemplateTokens() { | ||
tokens.push(convertTemplatePart(that._tokens, that._code)); | ||
that._tokens = []; | ||
} | ||
const translateTemplateTokens = () => { | ||
tokens.push(convertTemplatePart(this._tokens, this._code)); | ||
this._tokens = []; | ||
}; |
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.
Small refactor to avoid disabling no-underscore-dangle
, and I think this is a common way to avoid that = this
since ES6.
/** | ||
* @fileoverview Generate `<test-name>.result.js` from `<test-name>.src.js` in | ||
* `tests/fixtures/ecma-version/<number>/**` directory. | ||
* @author Nicholas C. Zakas | ||
* @author Toru Nagashima | ||
* | ||
* Usage: | ||
* node tools/update-ecma-version-tests.js <number> | ||
* | ||
* @author Nicholas C. Zakas | ||
* @author Toru Nagashima | ||
*/ |
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.
Some eslint-plugin-jsdoc rules were reporting errors in the structure, so I moved the usage description under the file overview.
filename.indexOf(".src.js") > -1).map(filename => | ||
filename.includes(".src.js")).map(filename => |
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.
unicorn/prefer-includes
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.
Overall LGTM. Just left a couple notes.
eslint.config.js
Outdated
@@ -0,0 +1,54 @@ | |||
import eslintConfigEslint from "eslint-config-eslint"; |
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.
Consistent ESLint capitalization
import eslintConfigEslint from "eslint-config-eslint"; | |
import eslintConfigESLint from "eslint-config-eslint"; |
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.
Fixed in ef5bdf2
eslint.config.js
Outdated
// eslintConfigEslint[3] is eslint-plugin-n's recommended-script config | ||
...eslintConfigEslint.slice(0, 3), | ||
{ | ||
files: ["**/*.js"], | ||
...nodeRecommendedModule | ||
}, | ||
{ | ||
files: ["**/*.cjs"], | ||
...nodeRecommendedScript | ||
}, | ||
...eslintConfigEslint.slice(4), |
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.
Is there a reason we can't just do ...eslintConfigESLint
?
settings: { | ||
jsdoc: { | ||
mode: "typescript" | ||
} | ||
} | ||
}, |
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.
I've made a PR to move it to eslint-config-eslint
.
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.
👍
We'll remove it from here when we release eslint-config-eslint v9.
Re-approved latest changes. This is ready for merge but would like @mdjermanovic to do that to make sure I didn't miss things from other conversations. |
It's good now with eslint-config-eslint v8. I'll merge this now and update the config when we release eslint-config-eslint v9 with changes from eslint/eslint#17338 and eslint/eslint#17336. |
Switches to
eslint.config.js
, and newly releasedeslint-config-eslint
v8.Marked as
refactor
because this includes changes in production code.