Skip to content
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

Component Argument Expression throws TypeError: Cannot read properties of null (reading 'range') #502

Closed
4 tasks done
TheOnlyRealKat opened this issue Apr 8, 2024 · 0 comments · Fixed by #504
Closed
4 tasks done

Comments

@TheOnlyRealKat
Copy link

TheOnlyRealKat commented Apr 8, 2024

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

  • I'm using eslint-plugin-svelte. (*.svelte file linting does not work with the parser alone. You should also use eslint-plugin-svelte with it.)
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-svelte repo and open the issue in eslint-plugin-svelte repo if there is no solution.
  • 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?

8.57.0

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

  • svelte-eslint-parser@0.34.0
  • eslint-plugin-svelte@2.35.1

What did you do?

Configuration
{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:svelte/base",
        "plugin:@typescript-eslint/recommended"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": "latest",
        "sourceType": "module"
    },
    "overrides": [
        {
            "files": [
                "*.svelte"
            ],
            "parser": "svelte-eslint-parser",
            "parserOptions": {
                "parser": "@typescript-eslint/parser"
            }
        }
    ],
    "plugins": [
        "@typescript-eslint"
    ],
    "rules": {
        "indent": [
            "error",
            4,
            {
                "SwitchCase": 1
            }
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "double"
        ],
        "semi": [
            "error",
            "always"
        ],
        "eol-last": [
            "error",
            "always"
        ]
    }
}
test.svelte
<script lang="ts">
    import Button from "$lib/Button.svelte";
    import { writable } from "svelte/store";

    interface store {
        map: Map<number, string>;
        number: number;
    }
    const test = new Map<number, string>([
        [1, "a"],
        [2, "b"],
        [3, "c"],
    ]);

    const store = writable<store>({
        map: test,
        number: 1,
    });
</script>

<div>
    {#if $store.map.size > 1}
        {#each $store.map as [index, tab]}
            <Button
                active={$store.number === index}>
                {index} {tab}
            </Button>
        {/each}
    {/if}
</div>

Button.svelte

<script lang="ts">
    export let active: boolean = false;
</script>

<button class:active={active}>
    <slot />
</button>

What did you expect to happen?

Nothing. Should work.

What actually happened?

TypeError: Cannot read properties of null (reading 'range')
Occurred while linting C:~snip~\src\test.svelte:1
Rule: "indent"

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/TheOnlyRealKat/svelte-eslint-bug

Additional comments

It worked with 0.33, and breaks with 0.34.0-next.3 or newer
See reproduction repo branches.

If you remove
active={$store.number === index}
from the Button Component it works, so I guess it has something todo with that.

@TheOnlyRealKat TheOnlyRealKat changed the title Template Condition/Expression throw error Component Argument Expression throws TypeError: Cannot read properties of null (reading 'range') Apr 8, 2024
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

Successfully merging a pull request may close this issue.

1 participant