sveltejs / eslint-plugin-svelte3

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

Using rules and config from .eslintrc.js #25

Closed frederikhors closed 5 years ago

frederikhors commented 5 years ago

I have

{
  "extends": "standard"
}

(which comes from https://github.com/standard/eslint-config-standard#usage) in my .eslintrc.js and I'm wondering why this doesn't work in <script></script> part of my .svelte files.

What rules is this plugin following?

I' using https://github.com/UnwrittenFun/svelte-vscode. Can I have standard.js style in my js code?

Conduitry commented 5 years ago

Do you have a minimal reproduction of this somewhere that can be cloned?

Have you tried running ESLint from the command line? That is - Is this an ESLint issue or an editor configuration and integration issue?

frederikhors commented 5 years ago

Reproduction project: https://github.com/frederikhors/svelte3-vscode-eslint

I'm using extension https://github.com/UnwrittenFun/svelte-vscode in VS Code.

Using this in command line: npx eslint --fix .\src\* works good, it changes App.svelte and main.js as I want: following standard.js rules.

VS Code doesn't follow standard.js rules on format command (on saving also).

Conduitry commented 5 years ago

If running eslint from the command line is working, there's nothing wrong with this plugin, and the issue is somewhere in your editor config.

Are you using a vscode extension that adds Svelte syntax highlighting to *.svelte files? If so, you need to instruct the ESLint extension to lint "language": "svelte" instead of "language": "html". I recently updated the INTEGRATIONS.md doc about this.

frederikhors commented 5 years ago

@Conduitry thanks a lot for your answer.

Unfortunately it doesn't work. I'm following INTEGRATIONS.ms config but VSCode doesn't format my code using .eslintrc.js with and without Prettier extension.

I tried very hard.

I think I'm very tired now, I think I'll wait for you or some good soul on this road (reproduction project: https://github.com/frederikhors/svelte3-vscode-eslint).

Conduitry commented 5 years ago

This is going to depend on your own vscode settings, so what you checked in isn't going to be enough to reproduce this. You haven't shown me the relevant parts of your user-level vscode settings.json file.

I'm personally getting red squiggles from eslint in vscode. Are you not getting these?

I don't think the dbaeumer.vscode-eslint extension provides a 'formatter' for ESLint to use like the Prettier extension does. In any case, in the only formatter I see configured in your project-specific configuration file is for Prettier.

The ESLint extension has its own eslint.autoFixOnSave setting, and if I enable this in your project, I do get .js and .svelte files to format (using eslint) on save.

frederikhors commented 5 years ago

You haven't shown me the relevant parts of your user-level vscode settings.json file.

Is empty.

The ESLint extension has its own eslint.autoFixOnSave setting, and if I enable this in your project, I do get .js and .svelte files to format (using eslint) on save.

Now it works for me. But two problems:

frederikhors commented 5 years ago

Fixed everything. Thanks @Conduitry!