Skip to content

[no-let] Add option to ignore lines based on search string #987

@realmikkifriend

Description

@realmikkifriend

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions