Skip to content

Nesting components with Svelte 5 snippet parameters with the same name can cause ESLint errors #871

@trevorparscal

Description

@trevorparscal

Describe the bug

When components in nested scopes use the same snippet names, ESLint's no-shadow rule detects that the inner scope is shadowing the snippet name from the outer scope.

svelte-issue

While the example shows a contrived use-case, I ran into this pretty quickly once I started creating reusable UI components. I've temporarily disabled ESLint's no-shadow rule, but of course that isn't ideal.

Reproduction

Example with ESLint configuration on GitHub

Example with the same code on REPL

ESLint Error

Logs

[{
	"resource": "/Users/trevorparscal/Sites/svelte-issue/src/routes/+page.svelte",
	"owner": "eslint4",
	"code": {
		"value": "no-shadow",
		"target": {
			"$mid": 1,
			"path": "/docs/latest/rules/no-shadow",
			"scheme": "https",
			"authority": "eslint.org"
		}
	},
	"severity": 8,
	"message": "'icon' is already declared in the upper scope on line 16 column 12.",
	"source": "eslint",
	"startLineNumber": 22,
	"startColumn": 13,
	"endLineNumber": 22,
	"endColumn": 17
},{
	"resource": "/Users/trevorparscal/Sites/svelte-issue/src/routes/+page.svelte",
	"owner": "eslint4",
	"code": {
		"value": "no-shadow",
		"target": {
			"$mid": 1,
			"path": "/docs/latest/rules/no-shadow",
			"scheme": "https",
			"authority": "eslint.org"
		}
	},
	"severity": 8,
	"message": "'label' is already declared in the upper scope on line 13 column 12.",
	"source": "eslint",
	"startLineNumber": 27,
	"startColumn": 13,
	"endLineNumber": 27,
	"endColumn": 18
}]

System Info

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M1
    Memory: 66.11 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    bun: 1.1.12 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 129.1.70.123
    Chrome: 126.0.6478.127
    Safari: 18.0.1
  npmPackages:
    svelte: ^5.0.0-next.1 => 5.0.0-next.264

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy