Add config-combo integration tests; fix three issues they uncovered #637
Merged
Conversation
screendriver
previously approved these changes
May 4, 2026
Static rule-configuration tests verify *which* rules are configured. These new tests verify rules actually fire on real code, the configs don't false-positive on clean code, and autofix is idempotent. Each combo (base+typescript, base+node, base+typescript+node, base+typescript+react-tsx) gets a violations fixture, a clean fixture, and three assertions: expected rule-id set, zero reports on clean code, and idempotent --fix. Three currently-failing tests surface real bugs the static checks miss: functional/prefer-immutable-types loops infinitely on Buffer, react/forward-ref-uses-ref crashes under ESLint 10, and functional/readonly-type conflicts with functional/prefer-immutable-types on opaque React types.
…ap fixers Previously the rule enforced ReadonlyShallow on parameters, return types, and variables, with a fallback fixer that wrapped any non-readonly type in Readonly<>. That caused an infinite autofix loop on opaque types like Buffer (each pass added another Readonly< layer) and false positives on opaque library types in return positions (e.g. React.JSX.Element). Now: only parameters are enforced, the fixer handles T[], tuples, and Map/Set inline, and object literal violations are report-only so the user adds the `readonly` keyword manually. Same fixer change applied to type-declaration-immutability for consistency.
The rule crashes on ESLint 10 because it still calls the removed `context.getSourceCode()` API. Upstream fix (jsx-eslint/eslint-plugin-react#3979) has been stalled for ~3 months, and the project hasn't shipped a release since April 2024. Low-cost workaround — React 19 deprecates `forwardRef`, so the rule is becoming obsolete anyway. Plan to migrate to @eslint-react/eslint-plugin in a follow-up; this gets CI green in the meantime.
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.
Adds behavioural integration tests across four config combinations
(
base+typescript,base+node,base+typescript+node,base+typescript+react-tsx) — each asserting violations are reported,clean code produces no false positives, and
--fixis idempotent.The existing static tests only verify which rule names are
configured; they never lint actual code. The new tests caught three
real bugs, all fixed here:
functional/prefer-immutable-typesinfinite autofix loop onopaque types. The catch-all
Readonly<>fallback fixer wrapstypes whose immutability is "Unknown" (e.g.
Buffer,React.JSX.Element) on every pass without ever satisfying therule. → Narrowed scope to parameters only and removed the catch-all
fixer. Object literals now report-only;
T[]/ tuple /Map/Setautofixes kept. Same fixer change infunctional/type-declaration-immutability.react/forward-ref-uses-refcrashes on ESLint 10.eslint-plugin-react@7.37.5still calls removedcontext.getSourceCode(). Upstream fix(Fix ESLint v10 RuleContext API removal (follow-up to #3972) jsx-eslint/eslint-plugin-react#3979) stalled ~3 months. → Disabled
with a comment. Migration to
@eslint-react/eslint-pluginis asensible follow-up.
readonly-type↔prefer-immutable-typesconflict on opaquereturn types.
prefer-immutable-typesdemandedReadonly<JSX.Element>,readonly-type: 'keyword'rejected thewrapper, no inline form available. → Implicitly resolved by Force exact dependency installation #1's
narrower scope.