sveltejs / eslint-plugin-svelte3

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

imimport or impimport #28

Closed frederikhors closed 5 years ago

frederikhors commented 5 years ago

Sometimes in a .svelte file with many imports using cli (or VSCode) it changes the first import in imimport or impimport.

frederikhors commented 5 years ago

I'm using this .eslintrc.js:

module.exports = {
  root: true,
  parserOptions: {
    ecmaVersion: 2019,
    sourceType: 'module'
  },
  env: {
    es6: true,
    browser: true,
    node: true
  },
  extends: [
    'eslint:recommended',
    'standard'
  ],
  plugins: ['svelte3'],
  overrides: [
    {
      files: '*.svelte',
      processor: 'svelte3/svelte3'
    }
  ]
}
Conduitry commented 5 years ago

I'll need a .svelte file that this happens with as well.

frederikhors commented 5 years ago

Yes, I now. I'm trying to create a reproducible gist.

frederikhors commented 5 years ago

Ok I have one example (different from mine, but something strange is happening here too).

From https://github.com/timhall/svelte-apollo:

<script>
  import { getClient, query } from 'svelte-apollo';
  import { GET_BOOKS } from './queries';

  const client = getClient();

  const books = query(client, { query: GET_BOOKS });
</script>

{#await $books}
  Loading...
{:then result}
  {#each result.data.books as book}
    {book.title} by {book.author.name}
  {/each}
{:catch error}
  Error: {error}
{/await}

If you try with: npx eslint --fix .\src\fileName.svelte the error is:

1:26 error Unexpected token ParseError

During saving it creates a new line let $books;.

Conduitry commented 5 years ago

Have you read https://github.com/sveltejs/eslint-plugin-svelte3/blob/master/OTHER_PLUGINS.md#eslint-plugin-import ?

frederikhors commented 5 years ago

Ok. I'm using just eslint-plugin-import.

If you're using them on other linted files, consider adding overrides for them for Svelte components.

How to do this?

Conduitry commented 5 years ago

https://eslint.org/docs/user-guide/configuring#disabling-rules-only-for-a-group-of-files

frederikhors commented 5 years ago

It works. Thanks!