7.5.0 • Published 1 year ago
@lars-reimann/eslint-config-svelte v7.5.0
Configuration for ESLint for Svelte Projects
To use this configuration:
- Run
npm install --save-dev @lars-reimann/eslint-config-svelte. - Create a
tsconfig.jsonfile. 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"] } - Create an
.eslintrc.jsfile with the following content. Replace the path to thetsconfig.jsonfile. It is also possible to specify multiple projects by passing an array toparserOptions.projectand pointing to thetsconfig.jsonof 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 providedSolution 1:
Ignore the file by adding it to the .eslintignore file:
vite.config.tsSolution 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
}