-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Thanks very much to the devs for this library, which has helped me understand functional programming more than any tutorial.
Background
Svelte passes props between components using a different method depending on which major version is used:
export let variable
(Svelte 4, what I'm using)let { variable } = $props();
(Svelte 5, based on documentation, see discussion)
In addition to this plugin, I enabled ESLint to scan Svelte components in my codebase by installing eslint-plugin-svelte
and enabling the recommended configs per documentation.
Issue
Either valid usage of let
in Svelte components triggers the no-let
rule. I can't find a way to prevent this using this library's existing options, eslint-plugin-svelte
, or ESLint configuration.
export let variable; // valid Svelte 4 syntax, incorrectly shows no-let error
let { variable } = $props(); // valid Svelte 5 syntax, incorrectly shows no-let error
let variable; // correctly shows no-let error
For reference, while I don't want to lose the benefit of no-let
linting, it's possible to disable this rule in Svelte files in eslint.config.mjs
:
{
files: ["**/*.svelte"],
rules: {
"functional/no-let": "off",
},
},
Suggestion
In addition to the ignoreIdentifierPattern
option, it would be great if the no-let
rule had an ignoreLinePattern
(or ignoreCodePattern
for consistency with rules like no-classes
) option that skips matching lines. It would accept either search strings or arrays of search strings (e.g. ^export
and \$props\(\)
).
I barely understand ESLint but have searched and prompted for a way to configure it like this. As far as I can tell, ESLint configuration blocks (like above) can't disable linting by search string. I would love for this to be incorrect, because it would bypass the need to add new features.