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

fix(linter): category filters not re-configuring already-enabled rules #6085

Conversation

DonIsaac
Copy link
Collaborator

@DonIsaac DonIsaac commented Sep 26, 2024

AI generated because I'm busy

TL;DR

Enhanced LinterBuilder functionality and improved rule configuration handling.

What changed?

  • Made rules field in LinterBuilder public within the crate.
  • Added a plugins() method to LinterBuilder to access lint plugins.
  • Improved rule configuration logic in configure_rules method to update existing rules' severity.
  • Added comprehensive test cases for LinterBuilder functionality.
  • Implemented Borrow<RuleEnum> for RuleWithSeverity to improve rule lookup efficiency.

How to test?

  1. Run the newly added test cases in the test module of builder.rs.
  2. Verify that all tests pass, including:
    • Default builder configuration
    • Empty builder configuration
    • Rule filtering and severity changes
    • Plugin configuration and rule interactions

Why make this change?

These changes improve the flexibility and robustness of the linter configuration process:

  1. Allowing access to the rules field enables more advanced customization options.
  2. The new plugins() method provides better visibility into configured plugins.
  3. Updating existing rules' severity ensures consistent behavior when reconfiguring rules.
  4. Comprehensive tests ensure the reliability of the LinterBuilder functionality.
  5. Implementing Borrow<RuleEnum> for RuleWithSeverity optimizes rule lookup operations.

These enhancements contribute to a more maintainable and efficient linter system.

Copy link

graphite-app bot commented Sep 26, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

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

@github-actions github-actions bot added the A-linter Area - Linter label Sep 26, 2024
@DonIsaac DonIsaac changed the title add more tests fix(linter): category filters not re-configuring already-enabled rules Sep 26, 2024
@DonIsaac DonIsaac marked this pull request as ready for review September 26, 2024 18:59
@DonIsaac DonIsaac added the C-bug Category - Bug label Sep 26, 2024 — with Graphite App
Copy link

codspeed-hq bot commented Sep 26, 2024

CodSpeed Performance Report

Merging #6085 will not alter performance

Comparing don/09-26-fix_linter_filters_in_linterbuilder_not_re-configuring_existing_rules_correctly (8759528) with main (55949eb)

Summary

✅ 29 untouched benchmarks

@DonIsaac DonIsaac changed the base branch from don/09-26-test_linter_add_oxlintrules_override_rules_tests to graphite-base/6085 September 26, 2024 19:40
@DonIsaac DonIsaac force-pushed the don/09-26-fix_linter_filters_in_linterbuilder_not_re-configuring_existing_rules_correctly branch from 79fde4b to 2ecf67e Compare September 26, 2024 19:44
@DonIsaac DonIsaac changed the base branch from graphite-base/6085 to main September 26, 2024 19:45
@DonIsaac DonIsaac force-pushed the don/09-26-fix_linter_filters_in_linterbuilder_not_re-configuring_existing_rules_correctly branch from 2ecf67e to 49e2fb4 Compare September 26, 2024 19:45
Copy link

graphite-app bot commented Sep 26, 2024

Merge activity

  • Sep 26, 4:17 PM EDT: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Sep 26, 4:17 PM EDT: DonIsaac added this pull request to the Graphite merge queue.
  • Sep 26, 4:23 PM EDT: DonIsaac merged this pull request with the Graphite merge queue.

#6085)

> AI generated because I'm busy
### TL;DR

Enhanced LinterBuilder functionality and improved rule configuration handling.

### What changed?

- Made `rules` field in `LinterBuilder` public within the crate.
- Added a `plugins()` method to `LinterBuilder` to access lint plugins.
- Improved rule configuration logic in `configure_rules` method to update existing rules' severity.
- Added comprehensive test cases for `LinterBuilder` functionality.
- Implemented `Borrow<RuleEnum>` for `RuleWithSeverity` to improve rule lookup efficiency.

### How to test?

1. Run the newly added test cases in the `test` module of `builder.rs`.
2. Verify that all tests pass, including:
   - Default builder configuration
   - Empty builder configuration
   - Rule filtering and severity changes
   - Plugin configuration and rule interactions

### Why make this change?

These changes improve the flexibility and robustness of the linter configuration process:

1. Allowing access to the `rules` field enables more advanced customization options.
2. The new `plugins()` method provides better visibility into configured plugins.
3. Updating existing rules' severity ensures consistent behavior when reconfiguring rules.
4. Comprehensive tests ensure the reliability of the `LinterBuilder` functionality.
5. Implementing `Borrow<RuleEnum>` for `RuleWithSeverity` optimizes rule lookup operations.

These enhancements contribute to a more maintainable and efficient linter system.
@DonIsaac DonIsaac force-pushed the don/09-26-fix_linter_filters_in_linterbuilder_not_re-configuring_existing_rules_correctly branch from 49e2fb4 to 8759528 Compare September 26, 2024 20:18
@graphite-app graphite-app bot merged commit 8759528 into main Sep 26, 2024
26 checks passed
@graphite-app graphite-app bot deleted the don/09-26-fix_linter_filters_in_linterbuilder_not_re-configuring_existing_rules_correctly branch September 26, 2024 20:23
DonIsaac added a commit that referenced this pull request Sep 26, 2024
DonIsaac added a commit that referenced this pull request Sep 27, 2024
@oxc-bot oxc-bot mentioned this pull request Sep 27, 2024
Boshen added a commit that referenced this pull request Sep 27, 2024
## [0.9.9] - 2024-09-27

### Bug Fixes

- bd8f786 linter: Rule and generic filters do not re-configure existing
rules (#6087) (DonIsaac)
- c5cdb4c linter: Disable all rules in a plugin when that plugin gets
turned off (#6086) (DonIsaac)
- 6c855af linter: Only write fix results if source code has changed
(#6096) (DonIsaac)
- 8759528 linter: Category filters not re-configuring already-enabled
rules (#6085) (DonIsaac)
- c2616f7 linter: Fix panic in fixer for `oxc/only-used-in-recursion`
(#6070) (camc314)
- 3da3845 linter: Malformed snippets in `eslint/for-direction` docs
(#6060) (DonIsaac)
- c047d42 linter: `no-useless-escape`: do not crash on backslash
character (#6048) (camchenry)
- 6f76ebe linter: Ignore invalid or partial disable directives (#6045)
(camchenry)
- 09a24cd linter: Fix false positives for generics in
`no-unexpected-multiline` (#6039) (camchenry)
- d05fd20 linter: Newline in type parameters causing false positive in
`no-unexpected-multiline` (#6031) (DonIsaac)
- 01b9c4b npm/oxlint: Make bin/oxc_language_server an executable (#6066)
(Boshen)

### Performance

- f8464a3 linter: `no-magic-numbers` remove redudant checks in
`is_array_index` (#6033) (Alexander S.)
- c16ae60 linter: `jest/prefer-hooks-in-order`: rewrite rule to allocate
less and iterate fewer times (#6030) (camchenry)

### Documentation

- a4fdf1b linter: Improve docs for promise rules (#6051) (dalaoshu)
- 21cdb78 linter: Fix incorrect "bad" example in
`only-used-in-recursion` (#6029) (Boshen)

### Refactor

- 1f92d61 linter: `jest/prefer-hooks-in-order`: improve diagnostic
messages (#6036) (camchenry)

### Testing

- 55949eb linter: Add `OxlintRules::override_rules` tests (#6081)
(DonIsaac)
- 1a6923a linter: Add filter parsing test cases (#6080) (DonIsaac)
- 58d333a linter: Add more test cases for disable directives (#6047)
(camchenry)

---------

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-linter Area - Linter C-bug Category - Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants