-
Notifications
You must be signed in to change notification settings - Fork 12
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: support flat config format default for ESLint 9 #277
Conversation
…on configuration code
I used the next command to compare configs on the next 2 versions yarn eslint --print-config file.tsx
![]() also here is a diff of eslint rules https://www.diffchecker.com/HVG4ATyI/ +'@react-native/platform-colors': ['warn'],
+'no-empty-static-block': ['error'],
-'no-inner-declarations': ['error'],
-'no-new-symbol': ['error'],
+'no-new-native-nonconstructor': ['error'],
+'no-unused-private-class-members': ['error'], did you want to introduce such changes ? |
Thanks, I missed these changes - I will take a look at 1 & 2 to check if we can get this back.
Good catch, most likely some of the plugins we depend on must've changed their rules. I updated part of them since some introduced changes to support flat config. Do I assume properly that we want strictly the same rules in the final outcome that we had previously, or - in case these changes came from upgraded dependencies - would we want to e.g. keep the added rules and only restore the deletions?
Would you tell, where do you see such change? It was already both in |
you right, (I haven't used the latest v8 config) that's why this plugin was missed |
@retyui I tried to reproduce the diffs you reported, but on my side they work pretty much the same... The following is a diff (full config object, not just rules, with stripped disk paths) between:
https://www.diffchecker.com/6lpZreHP/ The only difference here seems to be The following is a diff between:
https://www.diffchecker.com/3eMWAhwO/ The difference in rules is same as with ESLint v8 The As to the order of other modules, I will inspect & update the code soon to maintain it. |
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.
Thank you, excellent work
Now (1dd27ea) the order of plugins is maintained:
Thanks @retyui, can you just take a look & elaborate on what do we want to do with this new Also, would you like me to bump up the version in |
@thymikee Do you agree to bump minor version or it's a major release ? |
node.flat.js
Outdated
@@ -0,0 +1,3 @@ | |||
const createNodeConfig = require('./node.factory'); | |||
|
|||
module.exports = createNodeConfig(true); |
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.
instead of a boolean flag in an argument that controls whether this is a flat config or not, can we have two specialized functions instead of one? createFlatNodeConfig
and createLegacyNodeConfig
or something that makes sense semantically?
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.
Sure, these names make sense - refactored in 10889e9
react-native.flat.js
Outdated
@@ -0,0 +1,3 @@ | |||
const createRNConfig = require('./react-native.factory'); | |||
|
|||
module.exports = createRNConfig(true); |
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.
same boolean as argument situation here
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.
Sure, refactored in 10889e9
"eslint-plugin-prettier": "^5.0.0", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"eslint-plugin-react": "^7.33.2", | ||
"eslint-plugin-jest": "^28.7.0", |
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.
FYI, we usually we treat upgrading major version of deps as a major change
test/package.json
Outdated
"@callstack/eslint-config": "link:..", | ||
"eslint": "*", | ||
"jest": "*", | ||
"jest": "^29", |
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.
what's the reason for not being compatible with lower versions? If that was just for the version bump in the lockfile, you can invalidate the lockfile entry itself
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.
Right, I must've changed it while testing to see if eslint v9 picks the version automatically when specified explicitly, but it didn't (that's why I placed an explicit settings object for jest in eslint.config.mjs
). Reverted in 0bf92a6
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.
Let's roll with this change as a major version, as it mixes both new eslint functionality and bumps some deps' major versions :)
@retyui will you handle the version bump & publish? |
Summary
This PR solves #276 by adding flat configuration entrypoints that can be used with ESLint 9+, which deprecated the old eslintrc format and uses flat config by default.
Some plugins used under the hood by
@callstack/eslint-config
still were not ported to support flat config, thus partially the code performs proper changes either using@eslint/compat
helpers where possible, or manually via manipulation of config / rules objects.The changes involve:
*.flat.js
) with flat config, and common configuration factories (*.factory.js
) that are used both for new flat config entrypoints and old eslintrc-style entrypoints (unchanged file names, as they were); the actual code carrying rules / configuration was moved to*.factory.js
files to share as much code without duplication as possibletest
, carrying two workspace packages:eslint-v8
&eslint-v9
, which are placeholders for scripts & dependency to ESLint v8 & v9; theyarn test
command in the project performs a run ofyarn test
script for each of the workspaces of the monorepo intest/
, causing both ESLint v8 & v9 to run on the same (untouched) files to test both for proper functioning of the flat config exports & the legacy, backwards-compatible eslintrc-style exportsThe only pitfall is manual and/or
@eslint/compat
-assisted manipulation of imported configs / rules / plugins to adapt them to flat config format in a few places, which have been marked with// TODO: ...
with proper information that these changes shall be removed in the future, as these packages provide support for the flat config format.Test plan
yarn
in the root directoryyarn test
will runyarn
in thetest/
monorepo and will run both v8 & v9 ESLint on the test filesThe test was run in this GH Action run.
Additionally, the new branch has been tested in a separate branch in the
chartjs-plugin-dragdata
project artus9033/chartjs-plugin-dragdata#142 & a functional ESLint run is presented in this CI run.