Skip to content

Comments

refactor(linter): split unicorn/prefer-spread and eslint/prefer-spread into own rules#8329

Merged
camc314 merged 3 commits intooxc-project:mainfrom
Sysix:refactor-split-prefer-spreads
Jan 9, 2025
Merged

refactor(linter): split unicorn/prefer-spread and eslint/prefer-spread into own rules#8329
camc314 merged 3 commits intooxc-project:mainfrom
Sysix:refactor-split-prefer-spreads

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Jan 7, 2025

closes #7948

@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 7, 2025

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.

@github-actions github-actions bot added A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jan 7, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 7, 2025

CodSpeed Performance Report

Merging #8329 will not alter performance

Comparing Sysix:refactor-split-prefer-spreads (80add08) with main (3ba0b53)

Summary

✅ 29 untouched benchmarks

@Sysix
Copy link
Member Author

Sysix commented Jan 7, 2025

@camc314 the tests for unicorn are failing because the Tester is using the eslint rule for testing.
See the output in CI https://github.com/oxc-project/oxc/actions/runs/12656865138/job/35270412994?pr=8329
and here: 480a091.

Does it need a PLUGIN const in RuleMeta or how can I solve this the simple way?

Looks like this finds the wrong rule:

let rule = self.find_rule().read_json(rule_config.unwrap_or_default());

@camc314
Copy link
Contributor

camc314 commented Jan 8, 2025

yeah i remember starting to look at this:

.find(|rule| rule.category() == self.rule_category && rule.name() == self.rule_name)

this should be changed to something like

diff --git a/crates/oxc_linter/src/tester.rs b/crates/oxc_linter/src/tester.rs
index 0dab59886..1c0f9772e 100644
--- a/crates/oxc_linter/src/tester.rs
+++ b/crates/oxc_linter/src/tester.rs
@@ -508,7 +508,7 @@ impl Tester {
     fn find_rule(&self) -> &RuleEnum {
         RULES
             .iter()
-            .find(|rule| rule.category() == self.rule_category && rule.name() == self.rule_name)
+            .find(|rule| rule.plugin_name() == self.plugin_name && rule.name() == self.rule_name)
             .unwrap_or_else(|| panic!("Rule not found: {}", &self.rule_name))
     }
 }

so yeah it needs a PLUGIN const in RuleMeta

Boshen pushed a commit that referenced this pull request Jan 9, 2025
…8353)

needed for #8329

I wanted to use `proc_macro::Span::SourceFile` to auto detect the plugin
name. But this feature is unstable :/
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@camc314 camc314 merged commit b19d809 into oxc-project:main Jan 9, 2025
26 checks passed
Boshen added a commit that referenced this pull request Jan 13, 2025
## [0.15.6] - 2025-01-13

### Features

- 457aa31 linter: Implement `no-lone-blocks` rule (#8145) (Yuichiro
Yamashita)

### Refactor

- aea9551 ast: Simplify `get_identifier_reference` of `TSType` and
`TSTypeName` (#8273) (Dunqing)
- 43ed3e1 linter: Add output formatter (#8436) (Alexander S.)
- 4e05e66 linter: Remove glob for windows (#8390) (Alexander S.)
- b19d809 linter: Split `unicorn/prefer-spread` and
`eslint/prefer-spread` into own rules (#8329) (Alexander S.)
- 3c534ae linter: Refactor `LintBuilder` to prep for nested configs
(#8034) (camc314)
- 2f9fab9 linter: Remove remapping for plugin name in diagnostics
(#8223) (Alexander S.)

### Testing

- b6c1546 linter: Use plugin name instead of category for finding rule
(#8353) (Alexander S.)

Co-authored-by: Boshen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remap eslint/prefer-spread to unicorn/prefer-spread

2 participants