Skip to content

fix: no-destructure and import autofixes that broke code (fixes #261) - #263

Merged
ryansolid merged 1 commit into
mainfrom
fix/261-destructure-autofix
Nov 17, 2026
Merged

ryansolid merged 1 commit into
mainfrom
fix/261-destructure-autofix

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Requested by Ryan · project thread

Fixes #261 (all five cases from the report).

solid/no-destructure now reports without an autofix when the fix can't be faithful:

  1. A nested pattern (({ user: { name } }), ({ items: [first] })) or a non-identifier rest. The fix used to replace the parameter and leave name undefined.

  2. and 3. props or _props already declared in the function or a nested scope, or read from an enclosing scope (an outer component's props). The new parameter used to shadow it or cause a duplicate declaration.

  3. A default that reads another destructured prop (({ a, b = a })). This used to crash ESLint with "Fix objects must not be overlapped", and moving a into the merge(...) call would leave it unbound anyway.

  4. appendImports (used by jsx-no-undef and imports) no longer writes import * as Solid, { For } from "solid-js", which is a syntax error. With a namespace import it adds a separate import { For } from "solid-js"; after it.

A destructured prop that is itself named props (({ props })) still autofixes, since that binding goes away.

Tests

New invalid cases (no output) for each skipped fix, plus a jsx-no-undef namespace case; 8 of them fail without the change. Full PARSER=all suite passes (3,134 tests).

🤖 Generated with Claude Code

https://claude.ai/code/session_0117BoWPBR5hjwWf2VYS9c3p

no-destructure now reports without an autofix when the fix can't be
faithful:
- a nested pattern (`{ user: { name } }`) or non-identifier rest, which
  has no `props.x` rewrite and used to leave the inner bindings undefined;
- a default that reads another destructured prop (`{ a, b = a }`), which
  used to crash ESLint with overlapping fixes;
- `props` or `_props` already declared in the function (or a nested
  scope) or read from an enclosing scope, which the new parameter would
  redeclare or shadow.

appendImports (jsx-no-undef, imports) no longer merges named specifiers
into a namespace import (`import * as Solid, { For }` is a syntax error);
it adds a separate import declaration instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117BoWPBR5hjwWf2VYS9c3p
@ryansolid ryansolid self-assigned this Nov 17, 2026
@ryansolid
ryansolid merged commit 653dc61 into main Nov 17, 2026
3 checks passed
@ryansolid
ryansolid deleted the fix/261-destructure-autofix branch November 17, 2026 17:46
@ryansolid ryansolid mentioned this pull request Nov 17, 2026
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.

no-destructure and appendImports autofixes: nested patterns, props collisions, overlap crash, and namespace imports

1 participant