Repository navigation
Conversation
`OxlintRules` serialized array-form rule values as a 2-tuple of the severity and the whole options list, so `--print-config` printed `["deny", [options...]]` instead of `["deny", ...options]`. `parse_rule_value` reads everything after the severity as the options, so the printed value came back as one nested option. Most rules with options then refused the printed config, and some (max-statements, no-restricted-globals, no-inner-declarations, no-magic-numbers) loaded it and silently dropped their options. Serialize the flat `[severity, ...options]` form instead, which is the shape the config schema describes, and add a round-trip test. The ban_rules print-config snapshot changes from `["deny", ["always"]]` to `["deny", "always"]`. The serializer change and the test come from oxc-project#26668. Closes oxc-project#28972 Co-authored-by: Nathan Gage <54559789+nathan-gage@users.noreply.github.com>
Author
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 #28972.
OxlintRulesserialized array-form rule values as a 2-tuple of the severity and the whole options list, so--print-configprinted["deny", [options...]]instead of["deny", ...options].parse_rule_valuereads everything after the severity as the options, so the printed value came back as one nested option. Most rules with options then refused the printed config (invalid type: ...), and some loaded it and silently dropped their options (max-statements,no-restricted-globals,no-inner-declarations,no-magic-numbers).This serializes the flat
[severity, ...options]form, the shape the config schema describes, and adds a round-trip test. Theban_rulesprint-config snapshot changes from["deny", ["always"]]to["deny", "always"]. Only--print-configoutput changes, since it is the only placeOxlintRulesis serialized.The serializer change and the test are taken from #26668 by @nathan-gage (credited as co-author), where they are bundled with the JS-plugin CLI severity filters. I asked in #26668 whether this part could be split out; this PR carries only the fix so it can be reviewed on its own. Happy to close it if you would rather land it through #26668. Note that #26143 has tests and fixtures that expect the nested shape, so whichever of the two lands second needs to update them.
Not covered here, and already wrong before this change (in what
resolve_final_config_fileprints, not how): options of rules that come fromextends, options of TypeScript-adapted ESLint rules configured with thetypescript/or@typescript-eslint/prefix (looked up under the plain rule name, so they print as a bare severity), settings outside the typed built-in blocks (#22117), and CLI filters such as-A/-D.Tested on Windows 11:
cargo test -p oxc_linter --all-featurespasses. The newtest_serialize_roundtripfails without the serializer change.cargo clippy -p oxc_linter --all-targets --all-featureswith warnings denied, andcargo fmt --check, pass.cargo test -p oxlint -- print_configpasses with the updated snapshot. The rest ofcargo test -p oxlintgives the same results with and without this change on this machine: failures in tests that needoxlint-tsgolint, symlinks or a JS runtime, plus onelint::suppressiontest that aborts the test process on Windows either way.oxlintbinary,--print-configfollowed by-c <printed file>gives the same diagnostics and exit code as the original config formax-params,max-statements,no-console,eqeqeq(one and two options),no-restricted-globals,no-inner-declarations,no-magic-numbers,no-emptyandmax-paramsinsideoverrides, and, with oxlint-tsgolint 7.0.2006 running, for type-awaretypescript/restrict-template-expressionsandtypescript/no-floating-promiseswith options.AI disclosure: I used an AI coding assistant to prepare this change and this description. The tests and checks above were run locally.