ITADN

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

#987Openrealmikkifriend 创建于 2025-07-20
Type: FeatureAccepted
R
realmikkifriendcommented
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](https://svelte.dev/docs/svelte/legacy-export-let)) * `let { variable } = $props();` ([Svelte 5, based on documentation](https://svelte.dev/docs/svelte/v5-migration-guide#Reactivity-syntax-changes-export-let-$props), see [discussion](https://github.com/sveltejs/svelte/issues/12121)) 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.
2 条评论