oxc-project / oxc

⚓ A collection of JavaScript tools written in Rust.
https://oxc.rs
MIT License
9.71k stars 360 forks source link

`eslint.config.js` support #3217

Open dalisoft opened 1 month ago

dalisoft commented 1 month ago

Currently eslint.config.js is not supported as tested by bunx oxlint . --import-plugin --config=eslint.config.js

And got

❯ bunx oxlint . --import-plugin --config=eslint.config.js

  × Failed to parse jsonc file "eslint.config.js"

Invalid Options: Failed to parse configuration file.
Boshen commented 1 month ago

The error message is leading, it should be something like "we do not support files other than json".

dalisoft commented 1 month ago

@Boshen yes, but support for eslint.config.js would be cool

DonIsaac commented 1 month ago

@dalisoft please refer to this statement @Boshen made: https://github.com/oxc-project/oxc/pull/2214#issuecomment-1921636907

AndreaPontrandolfo commented 1 month ago

This is actually a HUGE issue because now the new "Flat Config" format (the eslint.config.js) is the default in ESLint (and ALL the other formats are now deprecated, they just don't work anymore) and not supporting it would mean that you give up on the OXLint <> ESLint interoperability. At which point i don't even know why you are developing the --import-plugin, if nobody can use OXLint and ESLint togheter.

Boshen commented 1 month ago

This is actually a HUGE issue because now the new "Flat Config" format (the eslint.config.js) is the default in ESLint (and ALL the other formats are now deprecated, they just don't work anymore) and not supporting it would mean that you give up on the OXLint <> ESLint interoperability. At which point i don't even know why you are developing the --import-plugin, if nobody can use OXLint and ESLint togheter.

Do you have a rough idea of how to make it work? i.e. load eslint and get all the information we need?

AndreaPontrandolfo commented 1 month ago

You mean this? I guess everything can be found here.

DonIsaac commented 1 month ago

@Boshen if you'd like I can put something together

milesj commented 1 month ago

You can't load and evaluate JavaScript from Rust, that's the crux of the problem.

To make this even remotely work, you would need to execute a node process that loads eslint, resolves the config, and outputs its information as JSON (is this even possible?). With this, you're now coupling node's overhead to Rust, and you lose some performance wins.

Boshen commented 1 month ago

You can't load and evaluate JavaScript from Rust, that's the crux of the problem.

To make this even remotely work, you would need to execute a node process that loads eslint, resolves the config, and outputs its information as JSON (is this even possible?). With this, you're now coupling node's overhead to Rust, and you lose some performance wins.

I'm not worried about the performance impact, I'm worried about the maintenance burden put into this project, as stated in https://github.com/oxc-project/oxc/pull/2214#issuecomment-1921636907

When I was doing research while setting up oxlint, I read almost all ESLint related issues from GitHub, stackoverflow, discord, reddit etc, and 90% of them are configuration issues, and a lot of them are unanswered due to its context and complexity.

Dunqing commented 1 month ago

Maybe we can use eslint --print-config to do it. This command will output all configurations in JSON format.

corbinu commented 1 month ago

If oxlint is going to have compatibitly only with eslint 8 and before configs (I think a valid opinon given the burden). Perhaps oxlint needs its own new config format that would have the same advantages of the eslint flat config. There is a lot of great information here on why the changes were made: https://eslint.org/blog/2022/08/new-config-system-part-1/

Perhaps a similar system but written in static RON files would be a good solution?

Oxlint could then support both the past eslint json format and its own new format