Skip to content

Add config-combo integration tests; fix three issues they uncovered #637

Merged
lo1tuma merged 3 commits into
mainfrom
more-testing
May 4, 2026
Merged

Add config-combo integration tests; fix three issues they uncovered #637
lo1tuma merged 3 commits into
mainfrom
more-testing

Conversation

@lo1tuma
Copy link
Copy Markdown
Member

@lo1tuma lo1tuma commented May 4, 2026

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 --fix is 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:

  1. functional/prefer-immutable-types infinite autofix loop on
    opaque types.
    The catch-all Readonly<> fallback fixer wraps
    types whose immutability is "Unknown" (e.g. Buffer,
    React.JSX.Element) on every pass without ever satisfying the
    rule. → Narrowed scope to parameters only and removed the catch-all
    fixer. Object literals now report-only; T[] / tuple / Map /
    Set autofixes kept. Same fixer change in
    functional/type-declaration-immutability.

  2. react/forward-ref-uses-ref crashes on ESLint 10.
    eslint-plugin-react@7.37.5 still calls removed
    context.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-plugin is a
    sensible follow-up.

  3. readonly-typeprefer-immutable-types conflict on opaque
    return types.
    prefer-immutable-types demanded
    Readonly<JSX.Element>, readonly-type: 'keyword' rejected the
    wrapper, no inline form available. → Implicitly resolved by Force exact dependency installation #1's
    narrower scope.

@lo1tuma lo1tuma requested a review from screendriver May 4, 2026 12:25
screendriver
screendriver previously approved these changes May 4, 2026
lo1tuma added 3 commits May 4, 2026 16:20
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.
@lo1tuma lo1tuma disabled auto-merge May 4, 2026 14:22
@lo1tuma lo1tuma merged commit 1d98631 into main May 4, 2026
4 checks passed
@lo1tuma lo1tuma deleted the more-testing branch May 4, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants