feat(linter): PoC to add deny_unknown_fields and error propagation for ~140 rules#17614
feat(linter): PoC to add deny_unknown_fields and error propagation for ~140 rules#17614connorshea wants to merge 43 commits intomainfrom
deny_unknown_fields and error propagation for ~140 rules#17614Conversation
…he jest/no-hooks rule. The upstream no-hooks rule does allow "undefined" and "null" values based on their tests, but I don't really see any value in supporting that explicitly, quite frankly. So I've removed the tests that allowed those particular cases. I also added some tests to ensure that the "allow" array can be empty, and also that the config itself can be empty and not cause a panic. Written with help from Copilot + Raptor mini.
`diagnostic` was misspelled.
…ion to the no-hooks rule.
…nderstand. Needed to make it pretty and split on whitespace to avoid multi-line error messages.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Connor Shea <connor.james.shea@gmail.com>
It seems like it may be necessary? Not totally clear on that.
And sort them so the output is stable.
…add deny_unknown_fields.
…DefaultRuleConfig. Used a script to determine which to convert, then manually removed a few problematic ones I know of (namely the max_* rules).
…n failing to deserialize. It is the exact same change for each of these rules.
…when an invalid config is hit. This converts most remaining DefaultRuleConfig usages to this pattern. Some rules have customization that prevent this conversion for now.
CodSpeed Performance ReportMerging #17614 will not alter performanceComparing Summary
Footnotes
|
…ame config object to RuleNameConfig.
…truct names. Normally you do not have more than one struct anyway, so this cleans things up for most rule generations.
| /// This helper also performs an integration check by embedding the config into an | ||
| /// `.oxlintrc` `rules` entry and running `ConfigStoreBuilder::from_oxlintrc` to ensure | ||
| /// that overrides parsing surface the same errors when applicable. | ||
| pub fn expect_configs(self, valid: Vec<Value>, invalid: Vec<Value>) -> Self { |
There was a problem hiding this comment.
I think we should consider adding this change to main by cherry-picking it/copying it over, but otherwise this PR can probably just be closed. I can redo the deny_unknown_fields/from_configuration change to the full ruleset easily enough.
|
Closing since this is being handled properly by #18104 (and a few other small PRs) instead. |
JUST A TEST, DO NOT MERGE
Includes/builds off of #17600 as a test for the changes in that PR. In this PR, only the last 5 commits really matter, as the rest come from #17600.
I ran this against ecosystem-ci, and honestly I'm pretty surprised that this doesn't error for a single repo: https://github.com/oxc-project/oxc-ecosystem-ci/actions/runs/20683517161
Just an experiment for the moment, but this converts almost all of the straight-forward rules to this pattern.
AI Disclosure: I used Copilot to write a script to add the deny_unknown_fields attribute on relevant rules with struct-based configuration options. I've included the script below.
I then manually did a find+replace on the common pattern for the
from_configurationfunction, to change that for all the rules where it was reasonably simple to do so.