sveltejs / eslint-plugin-svelte3

An ESLint plugin for Svelte v3 components.
MIT License
373 stars 43 forks source link

Unexpected character '@' when using {@const} #185

Closed ptelad closed 2 years ago

ptelad commented 2 years ago

I'm trying to use {@const} in a svelte file but eslint always failed the error:

  135:26  error  Unexpected character '@'  ParseError

I'm on version 3.4.1 which suppose to support {@const}.

I'm using it inside an {#each} statement, I don't know if that helps...

ptelad commented 2 years ago

.eslintrc.json

{
    "extends":  ["../../.eslintrc.json"],
    "parserOptions": {
        "ecmaVersion": 2020,
        "sourceType": "module"
    },
    "env": {
        "es6": true,
        "browser": true
    },
    "globals": {
        "jest": true,
        "test": true,
        "expect": true
    },
    "ignorePatterns": ["public/build/*"],
    "plugins": ["svelte3"],
    "overrides": [
        {
            "files": ["*.svelte"],
            "processor": "svelte3/svelte3"
        }
    ],
    "rules": {
        "camelcase": "off",
        "no-shadow": 0
    }
}

parent .eslintrc.json

{
    "extends": "./node_modules/eko-js-guide/.eslintrc.json",
    "parserOptions": {
        "ecmaVersion": 2020
    },
    "rules": {
        "space-before-function-paren": ["warn", {
            "anonymous": "never",
            "named": "never",
            "asyncArrow": "always"
        }],
        "capitalized-comments": "off",
        "lines-around-comment": "off",
        "no-prototype-builtins": "off"
    },
    "overrides": [
        {
          "files": [
            "**/*.test.js"
          ],
          "env": {
            "jest": true
          },
          "plugins": [
            "no-only-tests"
          ],
          "rules": {
            "no-magic-numbers": "off",
            "no-only-tests/no-only-tests": "error"
          }
        }
    ]
}

The parent of this is just a bunch of rules.

ptelad commented 2 years ago

I am ashamed to share that I was too trusting of WebStorm's capabilities. You see, I upgraded eslint-plugin-svelte3 from 2.7.3 to 3.4.1 and hit the yarn button in webstorm. I even saw that the version was updated in the node_modules but my issue continued so I went to google, found nothing and came here.

Removing node_modules and yarn.lock and running yarn again fixed the issue and everything's fine.

I really hope this helps someone googling frantically like I did, but I found nothing and you have this! You're welcome!

Sorry if I wasted anyone's time.