Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint reporting no-unused-vars when variable is declared as @const and used in the key of an #each #8109

Closed
OlsonDev opened this issue Dec 14, 2022 · 1 comment

Comments

@OlsonDev
Copy link

Describe the bug

I'm not sure if this belongs here or on the eslint issues, but I suspect here is more accurate.

I have a generic Grid component that has the ability to have sub-rows within it. I have a piece of logic that looks like:

            {#each _rows as row, i (rowKey(row))}
              {@const _subRows = subRows(row)}
              {@const hasSubRows = row !== _subRows}
              {@const rowspan = hasSubRows ? getCount(_subRows) : null}
              {@const __rows = hasSubRows ? _subRows : [row]}
              {@const keyFunc = hasSubRows ? subRowKey : rowKey}
              {#each __rows as subRow, j (keyFunc(subRow))}
                <tr
                  ...attributes>
                    ...inner HTML content
                </tr>
              {/each}

and eslint is reporting:

  69:23  error  'keyFunc' is assigned a value but never used  no-unused-vars

This will unfortunately prevent our build pipeline from accepting this build. I've tried adding <!-- eslint-disable-next-line no-unused-vars --> before, but that doesn't seem to fix it.

By the way, the code does compile and run perfectly.

Thanks!

Reproduction

Here's a fairly minimal reproduction: REPL -- if the REPL supports eslint, I couldn't figure out how to enable it.

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 7.67 GB / 31.73 GB
  Binaries:
    Node: 18.10.0 - C:\Program Files\nodejs\node.EXE
    npm: 7.19.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (108.0.1462.46)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    svelte: ^3.53.0 => 3.52.0
    webpack: ^5.75.0 => 5.74.0


### Severity

annoyance
@Conduitry
Copy link
Member

If this is still happening, it should be reported in the ESLint plugin repo - https://github.com/sveltejs/eslint-plugin-svelte

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2025
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

No branches or pull requests

2 participants