-
Notifications
You must be signed in to change notification settings - Fork 37
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 for eslint v9 #353
base: master
Are you sure you want to change the base?
Conversation
If this project only supports eslint 9 - and not 8 and 9 - it will disrupt the airbnb config from being able to ship eslint 9 support. Separately, I'm not sure why it must be a breaking change. I think we should try to support both simultaneously. |
@ljharb , thank you for your comment. As for airbnb, that is exactly what I was working on trying to migrate to 9, but was unable to complete the migration process to 9 because of its dependency on this library. The test before PR does not pass. |
You're correct that most users of libraries that have gone ESM-only are staying on pre-ESM-only versions - but that's not ok, that's a MASSIVE security problem for the entire JS ecosystem. It's an argument against breaking changes. The airbnb config's next version will support both 8 and 9, and may not even ship a flat config. This tool has to work on both eslintrc and flat config, and eslint 8 and 9, simultaneously. |
I understand and agree with your thinking. |
@ljharb , I have tried to support both v8 and v9. |
Hello @yutak23, I've tried a similar approach as yours, but I was facing some surprises in the output. Some plugins are not properly imported by the ESLint config object and I don't know why... You can take a look at this example where I've forked your yutak23:feature/migrate-to-v9 branch in my local, run the build script and added the dependency in my project. You can see that the I'm going to investigate another approach |
@lotmek , i think, study@localhost:~/workspace/eslint-find-rules-test
$ npm run test:plugins
> [email protected] test:plugins
> eslint-find-rules --ext .json -p eslint.config.js
plugin rules
json/* json/colon-expected json/comma-expected json/comma-or-close-backet-expected json/comma-or-close-brace-expected
json/comment-not-permitted json/duplicate-key json/enum-value-mismatch json/invalid-character json/invalid-escape-character
json/invalid-unicode json/json json/property-expected json/schema-resolve-error json/trailing-comma
json/undefined json/unexpected-end-of-comment json/unexpected-end-of-number json/unexpected-end-of-string json/unknown
json/value-expected |
We should also be automatically looking for files with |
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.
It might be best to first add support for flat config, and then add support for eslint 9 in a separate PR.
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.
Please ensure all files end in a trailing newline.
87315f9
to
bb1d1a2
Compare
i fixed this. |
c974294
to
87315f9
Compare
87315f9
to
bb1d1a2
Compare
Any news on the merge of this PR? There are many other libs that are waiting for this migration to also migrate to ESLint 9 |
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 take this semver-major opportunity to set engines.node
to '^18.18 || ^20.9 || ^22 || >= 23.1'
, and update CI to match.
76bcbe1
to
06eda72
Compare
65d73e2
to
6b05df8
Compare
8017235
to
4cc38cb
Compare
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.
Seems good! I'll merge this after I've tested it on another project.
FWIW, I’ve tried it in one of my projects where config was upgraded to ESLint 9 and flat config and it seems to be working as expected. |
@ljharb, |
|
This ought to fix #351.
ESLint v9 and seems to have moved completely to flat config. Therefore, I believe it is no longer possible to maintain backward compatibility. Therefore, i think it is better to raise the version to 5.0.0 with this modification and release 5.0.0 as supporting only ESLint v9 or higher.I have tried to support both v8 and v9.
I believe that Node.js support is fine for 17+ to match EOL.
About mocking in rule-finder testing
In
calculateConfigArray
at https://github.com/eslint/eslint/blob/v9.11.1/lib/eslint/eslint.js#L444,there is a part where it does
new FlatConfigArray
,As per the implementation at https://github.com/eslint/eslint/blob/v9.11.1/lib/config/flat-config-array.js#L90:
The
baseConfig
ends up being set to the default config (https://github.com/eslint/eslint/blob/v9.11.1/lib/config/default-config.js).Therefore, in the following implementation section:
the following settings inevitably get included:
and it's not possible to execute
calculateConfigForFile
with configurations for rules that are not in ESLint.Therefore, as a workaround, I used a mock to allow initialization with rules that are not in ESLint.
I believe that this does not prevent us from testing what needs to be tested.