sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
282 stars 30 forks source link

The Svelte ESLint plugin causes Vue rules to fail when exported together with the ESLint Config package. #589

Closed chengpeiquan closed 9 months ago

chengpeiquan commented 10 months ago

Hi @ota-meshi , I am currently maintaining an npm package of ESLint Flag Config (See: @bassist/eslint ).

Therefore, ESLint plugins from different technology stacks will be installed together in this package as dependencies, and export the corresponding preset configuration (e.g. Vue, React, Svelte and so on).

Since adding Svelte's ESLint configuration, I have received feedback that Vue's Lint rules are not working (See https://github.com/chengpeiquan/bassist/issues/18 ).

I checked today and found that it is indeed Svelte that causes Vue's rules to fail. After some testing, the main reason is that svelte-eslint-parser and eslint-plugin-svelte are related dependencies of Svelte ESLint.

  1. When I import these two plug-ins and export a Svelte configuration, Vue's ESLint will fail in the Vue project.
  2. When I import these two plug-ins, but do not use them, for example, only export some Svelte configurations that have nothing to do with Parser and Plugin, Vue ESLint works normally in the Vue project.
  3. When I don't use these two plugins at all (including using but not exporting the Svelte configuration), Vue ESLint works normally in the Vue project.

Forgive me for not being able to further understand the specific reason, because the ESLint plug-ins of Svelte and Vue are maintained by you, so I will report this situation. I hope if I have time, I can find out the reason further?

My current solution is to publish Svelte's configuration as a sub-package to isolate it from other technology stacks.

// eslint.config.js
import { defineConfig, prettier } from '@bassist/eslint'
import { svelte } from '@bassist/eslint/svelte'
chengpeiquan commented 9 months ago

Sorry, I've been busy these past two days. I planned to make a minimal reproducible repo today. I accidentally discovered the real reason.

I used to pay too much attention to the code error prompts of VS Code and the error feedback of the problem panel, because there was no error message, the cause was not noticed in time.

Today I ran pnpm lint to directly perform the ESLint check and got error feedback. The truth is revealed!

So I decided to keep the current sub-package import to avoid dependencies conflict error.

image