Skip to content
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(linter) Parse eslint configuration #1146

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

camc314
Copy link
Collaborator

@camc314 camc314 commented Nov 4, 2023

DRAFT

Adds support for parsing eslint configuration files.

Example:

cargo run --bin=oxc_cli lint --config-path ./.eslintrc.json .

This isn't a full implementation of how eslint parses configs but should be fine for now:

Currently supported extends:

  • eslint:recommended -> eslint
  • plugin:react/recommended -> react
  • plugin:@typescript-eslint/recommended -> typescript
  • plugin:react-hooks/recommended -> react
  • plugin:unicorn/recommended -> unicorn
  • plugin:jest/recommended -> jest

These defaults can all be overridden by configuring the rule in the rules section of the estlint config:

e.g.

{
    "extends": [
        "eslint:recommended"
    ],
    "rules": {
        "eqeqeq": "off"
    },
}

This would enable of of the rules within the eslint group. But would not enable eqeqeq as it is explicitly disabled

Note, we do not currently support the following:

  • supplying a filter and config-path
  • supplying a plugin and config-path

Edit:

@github-actions github-actions bot added the A-linter Area - Linter label Nov 4, 2023
crates/oxc_linter/src/config/mod.rs Outdated Show resolved Hide resolved
crates/oxc_linter/src/config/mod.rs Outdated Show resolved Hide resolved
@Boshen
Copy link
Member

Boshen commented Nov 5, 2023

This is amazing, shall we start refactoring and start merging?

After getting introduced to https://graphite.dev/ and https://stacking.dev/, I prefer smaller PRs so we can iterate faster. You may also play around with graphite 😁

Boshen added a commit that referenced this pull request Nov 5, 2023
From #1146

---------

Co-authored-by: Boshen <boshenc@gmail.com>
@camc314
Copy link
Collaborator Author

camc314 commented Nov 5, 2023

This is amazing, shall we start refactoring and start merging?

yes! let me tidy this up today

After getting introduced to https://graphite.dev/ and https://stacking.dev/, I prefer smaller PRs so we can iterate faster. You may also play around with graphite 😁

👀 i'll take a look. Would definitly be helpful at work - I always have too many PRs open 🙂

@aminpaks
Copy link

aminpaks commented Nov 6, 2023

yes! let me tidy this up today

👋 what happens with configs related to rules that oxc doesn't yet support?

@camc314
Copy link
Collaborator Author

camc314 commented Nov 6, 2023

yes! let me tidy this up today

👋 what happens with configs related to rules that oxc doesn't yet support?

they'll be ignored

@JoseBuendiaDigio
Copy link

Any news about this?

@github-actions github-actions bot added the A-cli Area - CLI label Dec 1, 2023
@camc314 camc314 marked this pull request as ready for review December 1, 2023 17:22
@Boshen
Copy link
Member

Boshen commented Dec 2, 2023

👍 Nice work! I'll test this by Monday when I have some internal code to test with.

@Boshen Boshen self-assigned this Dec 5, 2023
@bcentdev
Copy link

yes! let me tidy this up today

👋 what happens with configs related to rules that oxc doesn't yet support?

they'll be ignored

Will be some log to see what rules are being ignored? Or what rules of the config will being applied? Thanks.

Copy link

codspeed-hq bot commented Dec 14, 2023

CodSpeed Performance Report

Merging #1146 will not alter performance

Comparing camc314:c/eslint-config (ffb4cf0) with main (c9589b5)

Summary

✅ 20 untouched benchmarks

@Boshen
Copy link
Member

Boshen commented Dec 14, 2023

@camc314 I apologize for my procrastination on reviewing and merging this PR, I'm really happy with the current state, so let's :shipit:.

But before shipping the next release, we need to figure out what should be done with extends, because the behavior is not matching with eslint (obviously).

@Boshen Boshen merged commit 9275c74 into oxc-project:main Dec 14, 2023
15 of 16 checks passed
@rogerleung0411
Copy link

any roadmap on other config file format like .eslintrc.js or .eslintrc.cjs ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area - CLI A-linter Area - Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants