Skip to content

Bug: no-unused-vars raising TypeError #19273

Closed as not planned
Closed as not planned
@CNSeniorious000

Description

Environment

Node version: v22.12.0
npm version: v10.9.0
Local ESLint version: v9.17.0
Global ESLint version: Not found
Operating System: win32 10.0.26100

What parser are you using?

Other

What did you do?

Configuration
import antfu from '@antfu/eslint-config'

export default antfu({
  svelte: true,
  typescript: true,
  formatters: true,
})
{#if true}
  {#each [1, 2, 3] as a}
    {a}

    <!-- eslint-disable-next-line no-unused-vars -->
    {@const _ = console.error({ a })}

  {/each}
{/if}

What did you expect to happen?

no error

What actually happened?

ops! Something went wrong! :(

ESLint: 9.17.0

TypeError: Cannot read properties of undefined (reading 'length')
    at handleFixes (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/rules/no-unused-vars.js#cjs:1162:48)
    at Object.fix (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/rules/no-unused-vars.js#cjs:1471:48)
    at normalizeFixes (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/linter/report-translator.js#cjs:193:28)
    at eval (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/linter/report-translator.js#cjs:223:22)
    at Array.map (<anonymous>)
    at mapSuggestions (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/linter/report-translator.js#cjs:217:10)
    at eval (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/linter/report-translator.js#cjs:372:55)
    at FileContext.report (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/linter/linter.js#cjs:1062:41)
    at Program:exit (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/rules/no-unused-vars.js#cjs:1458:33)
    at ruleErrorHandler (file:///home/projects/vitejs-vite-geepgmmf/node_modules/eslint/lib/linter/linter.js#cjs:1098:48)

Link to Minimal Reproducible Example

https://stackblitz.com/edit/eslint-no-unused-vars-repro?file=package.json

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

9.16.0 works fine.

It seems this is threw from here.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    3rd party pluginThis is an issue related to a 3rd party plugin, config, or parserrepro:yesIssues with a reproducible exampleworks as intendedThe behavior described in this issue is working correctly

    Type

    No type

    Projects

    • Status

      Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions