@lars-reimann/eslint-config-svelte

7.3.0 • Public • Published

Configuration for ESLint for Svelte Projects

To use this configuration:

  1. Run npm install --save-dev @lars-reimann/eslint-config-svelte.
  2. Create a tsconfig.json file. If you already have one, you can skip this step. You can start with a base configuration and then focus on the details that are unique to your project. Here's a possible example:
    {
        "extends": "@tsconfig/node16/tsconfig.json",
        "include": ["src/**/*"],
        "exclude": ["node_modules", "**/*.test.ts"]
    }
  3. Create an .eslintrc.js file with the following content. Replace the path to the tsconfig.json file. It is also possible to specify multiple projects by passing an array to parserOptions.project and pointing to the tsconfig.json of each project:
    module.exports = {
        root: true,
        parserOptions: {
            tsconfigRootDir: __dirname,
            project: './tsconfig.json',
            extraFileExtensions: ['.svelte'],
        },
        extends: '@lars-reimann/svelte',
    };

Common Issues

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.

Example error message:

0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: vite.config.ts.
The file must be included in at least one of the projects provided

Solution 1:

Ignore the file by adding it to the .eslintignore file:

vite.config.ts

Solution 2:

Follow the instructions to create a tsconfig.eslint.json file. Here is an example for such a file:

{
    "extends": "./tsconfig.json", // extend the actual tsconfig.json
    "compilerOptions": {
        "noEmit": true // prevent building with this configuration
    },
    "include": ["src/**/*", "vite.config.ts"], // include all TypeScript files
    "exclude": ["node_modules"] // don't exclude any TypeScript files
}

Readme

Keywords

Package Sidebar

Install

npm i @lars-reimann/eslint-config-svelte

Weekly Downloads

91

Version

7.3.0

License

MIT

Unpacked Size

4.24 kB

Total Files

4

Last publish

Collaborators

  • lars-reimann