eslint-plugin-svelte3 icon indicating copy to clipboard operation
eslint-plugin-svelte3 copied to clipboard

type-aware linting rules config example

Open ccadieux opened this issue 3 years ago • 0 comments

Using this example from README.md results in error Unexpected token ParseError

module.exports = {
  // ...
  parserOptions: { // add these parser options
    tsconfigRootDir: __dirname,
    project: ['./tsconfig.json'],
    extraFileExtensions: ['.svelte'],
  },
  extends: [ // then, enable whichever type-aware rules you want to use
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking'
  ],
  // ...
};

Following the example in this issue has fixed the issue for me. https://github.com/sveltejs/eslint-plugin-svelte3/issues/116#issuecomment-863152211

Should the readme be updated to this?

module.exports = {
  // ...
  parserOptions: { // add these parser options
    tsconfigRootDir: __dirname,
    project: ['./tsconfig.json'],
    extraFileExtensions: ['.svelte'],
  },
  overrides: [
    {
      files: ['*.svelte'],
      processor: 'svelte3/svelte3',
      extends: [  // then, enable whichever type-aware rules you want to use
        'eslint:recommended', 
        'plugin:@typescript-eslint/recommended',
        'plugin:@typescript-eslint/recommended-requiring-type-checking'
      ],
    }
  ],
  // ...
};

ccadieux avatar Jun 23 '21 18:06 ccadieux