sveltejs / eslint-plugin-svelte3

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

Plugin skips parser settings #57

Closed ekulikov-flocktory closed 4 years ago

ekulikov-flocktory commented 4 years ago

I've created the test project with .eslintrc.js that uses babel-eslint parser: https://github.com/ekulikov-flocktory/eslint-plugin-svelte3-test

There are two quite the same files: index.js and index.svelte. If you run npx eslint index.js, you will see no errors. But if you run npx eslint index.svelte you will see "Parser error", which comes from eslint-plugin-svelte3 when it tries to parse the file.

It seems like eslint-plugin-svelte3 should use the parser (including it's settings) described at the .eslintrc.js.

Conduitry commented 4 years ago

Before ESLint gets ahold of the component and parses it according to whatever you specify in that configuration, the Svelte compiler does need to be run on the component (to extract information about what variables are used in the template, etc.), and Svelte doesn't support the optional chaining syntax yet. You'd need a preprocessor for Svelte to be able to compile the component, but there's currently no way to tell this plugin about that preprocessor. See #10.