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): inherit rules via the extended config files #9308

Open
wants to merge 1 commit into
base: 02-18-feat_linter_add_support_for_extends_property_in_oxlintrc
Choose a base branch
from

Conversation

camchenry
Copy link
Contributor

@camchenry camchenry commented Feb 23, 2025

This gives the extends keyword some functionality: specifically to allow inheriting rules from other configuration files. Rules that are in the extended configuration will be used as the base, and then files in the config doing the extending will override the extended rules.

So, you can, for example, specify a base configuration that defines rules that you generally want to be enabled. Then, in each nested configuration file, you could disable rules depending on the directory:

.oxlintrc.json       // { "rules: { "no-useless-escape": "error" } }
package1/
  .oxlintrc.json     // { "extends": ["../.oxlintrc.json"], "rules": { "no-useless-escape": "off" } }
package2/
  src                // uses ../.oxlintrc.json with `no-useless-escape` enabled 

As a side effect of this, building a config from a .oxlintrc.json file can result in config errors, even if all of the syntax and rules are configured correctly, because an extended configuration file might be incorrect or unparseable. For now, we simply raise an error if this occurs and stop execution, but in the future we could make this more graceful if we wanted and just ignore that file.

We will also need to revisit performance here, as I think a global cache config might be necessary so that we never load a file more than once and parse it more than once.

Copy link
Contributor Author

camchenry commented Feb 23, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI C-enhancement Category - New feature or request labels Feb 23, 2025
@camchenry camchenry force-pushed the 02-23-feat_linter_inherit_rules_via_the_extended_config_files branch from 971831f to 789e166 Compare February 24, 2025 03:57
@github-actions github-actions bot added the A-editor Area - Editor and Language Server label Feb 24, 2025
@camchenry camchenry force-pushed the 02-18-feat_linter_add_support_for_extends_property_in_oxlintrc branch from 7f3a3de to c92ba6c Compare February 24, 2025 03:58
@camchenry camchenry force-pushed the 02-23-feat_linter_inherit_rules_via_the_extended_config_files branch from 789e166 to fd06c26 Compare February 24, 2025 03:58
Copy link

codspeed-hq bot commented Feb 24, 2025

CodSpeed Performance Report

Merging #9308 will create unknown performance changes

Comparing 02-23-feat_linter_inherit_rules_via_the_extended_config_files (63b413f) with 02-18-feat_linter_add_support_for_extends_property_in_oxlintrc (7cab29f)

Summary

🆕 33 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 codegen[checker.ts] N/A 22.9 ms N/A
🆕 codegen_sourcemap[checker.ts] N/A 66 ms N/A
🆕 isolated-declarations[vue-id.ts] N/A 57.9 ms N/A
🆕 lexer[RadixUIAdoptionSection.jsx] N/A 20.8 µs N/A
🆕 lexer[antd.js] N/A 24.1 ms N/A
🆕 lexer[cal.com.tsx] N/A 5.7 ms N/A
🆕 lexer[checker.ts] N/A 14.5 ms N/A
🆕 lexer[pdf.mjs] N/A 3.8 ms N/A
🆕 linter[RadixUIAdoptionSection.jsx] N/A 2.7 ms N/A
🆕 linter[cal.com.tsx] N/A 1.2 s N/A
🆕 linter[checker.ts] N/A 2.9 s N/A
🆕 mangler[antd.js] N/A 16.1 ms N/A
🆕 mangler[react.development.js] N/A 297.7 µs N/A
🆕 mangler[typescript.js] N/A 39.8 ms N/A
🆕 minifier[antd.js] N/A 163.1 ms N/A
🆕 minifier[react.development.js] N/A 1.8 ms N/A
🆕 minifier[typescript.js] N/A 285.9 ms N/A
🆕 estree[checker.ts] N/A 91.8 ms N/A
🆕 parser[RadixUIAdoptionSection.jsx] N/A 88.7 µs N/A
🆕 parser[antd.js] N/A 111.4 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@camchenry camchenry force-pushed the 02-23-feat_linter_inherit_rules_via_the_extended_config_files branch 2 times, most recently from 3e96436 to dd36f3c Compare March 1, 2025 13:17
@camchenry camchenry marked this pull request as ready for review March 1, 2025 17:57
@camchenry camchenry force-pushed the 02-18-feat_linter_add_support_for_extends_property_in_oxlintrc branch from c92ba6c to dfdbb48 Compare March 1, 2025 22:35
@camchenry camchenry force-pushed the 02-23-feat_linter_inherit_rules_via_the_extended_config_files branch from dd36f3c to 4cfdc59 Compare March 1, 2025 22:35
@camchenry camchenry force-pushed the 02-18-feat_linter_add_support_for_extends_property_in_oxlintrc branch from dfdbb48 to 7cab29f Compare March 3, 2025 18:12
@camchenry camchenry force-pushed the 02-23-feat_linter_inherit_rules_via_the_extended_config_files branch from 4cfdc59 to 63b413f Compare March 3, 2025 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area - CLI A-editor Area - Editor and Language Server A-linter Area - Linter C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants