Skip to content

no-unassigned-vars (ESLint 10 recommended) flags variables used as ref={el} #231

Description

@dex157

Describe the bug

ESLint 10's recommended no-unassigned-vars flags Solid refs. For let el; <div ref={el} />, the compiler assigns el, but ESLint only sees a read.

To Reproduce

export const Box = () => {
  let el!: HTMLDivElement;
  return <div ref={el} onClick={() => el.focus()} />;
};

Config: [js.configs.recommended, ...tseslint.configs.recommended, solid], where solid is eslint-plugin-solid/configs/v2.

2:7  error  'el' is always 'undefined' because it's never assigned  no-unassigned-vars

Expected behavior

No report for a variable used as ref={…}.

Environment (please complete the following information):

  • OS: macOS
  • Node version: v24.19.0
  • eslint-plugin-solid version: 0.18.0
  • eslint version: 10.11.0

Additional context

ESLint has no "mark as written" API, so there are two fixes. One is a solid/no-unassigned-vars wrapper that drops reports for ref targets, which is what I'd prefer. The other is turning the core rule off in the configs.

  • I would be willing to contribute a PR to fix this issue

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions