Repository navigation
fix(linter): apply CLI severity filters to JS plugin rules - #26668
Open
nathan-gage wants to merge 8 commits into
Open
nathan-gage wants to merge 8 commits into
nathan-gage wants to merge 8 commits into
Conversation
…nabling and allowing JS plugin rules from the CLI
…int-config output round-trips
…efore JS plugin lookup
… the config declares
…li_filter fixture
|
This PR's That part looks independent of the JS-plugin severity filters. Would you consider splitting it into its own PR, so it can be reviewed and land separately? |
This was referenced Nov 7, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22730
Cherry-picks the change from #23336 (withdrawn by its author), preserving its authorship, plus fixes for problems found while testing it.
Summary
-A/-W/-D <plugin>/<rule>now reach rules fromjsPlugins, the same way they reach built-in rules:-D custom/ruleenables a plugin rule the config never mentioned.-D/-Won a configured plugin rule changes its severity and keeps its options.-A custom/ruleremoves a configured plugin rule.-D eslint-plugin-custom/rule,-D custom/rule, and-D @scope/custom/ruleall work.jsPluginsdeclare that plugin — the same boundconfig.pluginsputs on built-in rules. With nested configs,-D custom/ruleapplies wherecustomis declared and nowhere else.--print-configlists JS plugin rules, and its array-form rule values now round-trip.These filters change base rule configuration; matching file
overrideskeep their existing precedence, as for built-in rules. Unqualified names (-D rule), categories, andallstill only address built-in rules.Root cause
ConfigStoreBuilder::with_filteronly upserted into the built-in rule map.external_rulesis filled byOxlintRules::override_rulesfrom the config file, and the CLI path never touched it, so-D custom/rulewas silently dropped.Changes
with_filters/with_filtertake&ExternalPluginStoreand resolveplugin/rulefilters against it, after the same normalizationparse_rule_keyapplies to config keys (unalias_plugin_name). Callers (lint.rs,config_loader.rs, the category loop infrom_oxlintrc) pass the store they already have. fix(linter): apply CLI severity filters to JS plugin rules #23336 added a parallelwith_filters_and_external_rules; folded into the existing methods instead.ExternalPluginStoreis shared by every config in a run, so a bare lookup would also find plugins other configs loaded, and which configs picked up-D custom/ruledepended on load order. The builder now records the plugin ids its base config declares (load_external_pluginreturns the id; the store maps plugin path → id and rule → plugin) and filters only enable rules from those.LintFilterKind::parsesplits scoped plugin names at the last/, matchingparse_rule_key. Fixes-D @scope/plugin/rulefor JS plugins and, incidentally,-D @next/next/<rule>for the built-in nextjs plugin.--print-configincludes JS plugin rules (resolve_final_config_filetakes the store;ExternalPluginStore::optionsadded to read options back). Previously only built-in rules were serialized, so a CLI-enabled plugin rule looked like a no-op.OxlintRulesserialized array-form rules as[severity, [options]], whichparse_rule_valuereads back as one nested option, so--print-configoutput did not round-trip. Now[severity, ...options], as the JSON schema already describes. Theban_rulesprint-config snapshot changes accordingly.with_filter(s),resolve_final_config_file,register_plugin, andis_plugin_registered(nowregistered_plugin_id) change signature;oxc_linterispublish = falseand all in-repo callers are updated.Tests
Unit:
test_filter_external_rule(enable from CLI, prefixed plugin name, undeclared plugin ignored, severity change keeping options, allow, unknown name),test_print_config_includes_external_rules,test_serialize_roundtrip, scoped cases inLintFilterKindtest_parse.E2E fixtures:
js_plugin_cli_filter(from #23336, now with an option the rule reports: warn → error, option kept),js_plugin_cli_filter_enable,js_plugin_cli_filter_allow,js_plugin_cli_filter_scoped,js_plugin_cli_filter_prefixed,js_plugin_cli_filter_nested(root + three sibling configs, one declaring the plugin),js_plugin_cli_filter_print_config.Ran
cargo test -p oxc_linter,cargo test -p oxlint,cargo lintonoxc_linterand its workspace dependents,just docflags on both crates,typos,oxfmt --check, andpnpm --filter oxlint-app build-test && pnpm --filter oxlint-app test.AI assistance
Prepared with AI assistance; reviewed and tested by me.