Skip to content

False positives for no-immutable-reactive-statements when globalReturn is enabled #1233

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

Open
2 tasks done
RedHatter opened this issue May 20, 2025 · 0 comments
Open
2 tasks done

Comments

@RedHatter
Copy link

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.27.0

What version of eslint-plugin-svelte are you using?

3.8.1

What did you do?

Configuration
import js from "@eslint/js";
import sveltePlugin from "eslint-plugin-svelte";
import svelteParser from "svelte-eslint-parser";
import tseslint from "typescript-eslint";
export default tseslint.config(
  js.configs.recommended,
  ...tseslint.configs.recommended,
  ...sveltePlugin.configs["flat/recommended"],
  {
    files: ["**/*.svelte", "*.svelte"],
    languageOptions: {
      parser: svelteParser,
      parserOptions: {
        ecmaFeatures: {
          globalReturn: true,
        },
        parser: {
          ts: "@typescript-eslint/parser",
        },
        extraFileExtensions: [".svelte"],
      },
    }
  },
  {
    files: ["**/*.svelte.ts", "*.svelte.ts"],
    languageOptions: {
      parser: svelteParser,
      parserOptions: {
        parser: tseslint.parser,
      },
    }
  },
  {
    files: ["**/*.svelte.js", "*.svelte.js"],
    languageOptions: {
      parser: svelteParser,
    }
  },
);
<script lang="ts">
  export let a;

  $: b = a;
</script>

{b}

What did you expect to happen?

I expected the code to pass eslint

What actually happened?

Eslint fails with svelte/no-immutable-reactive-statements error

Link to GitHub Repo with Minimal Reproducible Example

https://eslint-online-playground.netlify.app/#eNq1VMFu2zAM/RVC2GELEvvutsOAbb0NG3addlBs2nAmS4YkFymC/PsoS3LsJOuKFr0YFvneI0WRPDBryvzb42fd9Vqhcpl9QOmQFezWlqbtHUihmjvOnOXsI1cAuO+1ITM6EDdcedO7ArZwNx5v80AjKFeH7ZErtmZoZUvSpVZ122Q7S+otxSOVnYXa6A44+xRA+Y7ikE70h2x+yKFpVUIG4KYfjZuAuMIRxqJJnGDbJOrom3OcDa6Ed489hotEzgiOV6+wFoM8keLF3vtS7Gw82cxgqbsOVYXV2ruyLDtjXMXMr5xwvzirpXD5DM7Z75Fx8B+AupVoCyDgapWvoghna7rL6RQYMD7pIBr83rtWK6JFEYBQmWJRw0hKzksS9UTZiXsUbjA+iZkDoJF6K+RPJJ8qwJkBJz2A4+w/hV6wHclRb1w8R56e8B9iuHdG3FNNvu4dKhsSpuJclOJEo1ZNh6dqSm+4LOtoeLPKJtrUOcHw4uz9eC2y94ZXZT9F/nBDo96L8g8pkKxWNOajQBgnzvxTdroapG/M4Kjw4Qv2vqFV2SKlMsVcbgRPpQFAS4MY46ZF8KTzfEtchT7Deb45rkJPXfpfwLRV5rixkFwd2fEvFSTV7A==

Additional comments

When the eslint option languageOptions.parserOptions.ecmaFeatures.globalReturn is set no-immutable-reactive-statements fails for most reactive statements. Not all of them but I haven't been able to determine why some work and others don't.

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

1 participant