Set up eslint with type information

This commit is contained in:
Joscha 2025-02-10 15:02:45 +01:00
parent 4aeb9eb8bd
commit fba72e723f
2 changed files with 22 additions and 6 deletions

View file

@ -1,3 +1,5 @@
// @ts-check
// https://eslint.org/docs/latest/use/configure/
// https://eslint.vuejs.org/user-guide/
@ -7,15 +9,29 @@ import pluginVue from "eslint-plugin-vue";
import configPrettier from "eslint-config-prettier";
export default tseslint.config(
{ ignores: ["dist/", "src/vite-env.d.ts"] },
{ ignores: ["dist/", "eslint.config.js", "vite.config.ts", "src/vite-env.d.ts"] },
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
...pluginVue.configs["flat/recommended"],
// We don't want prettier's formatting decisions being second-guessed by eslint.
// Prettier's formatting decisions should not be second-guessed by eslint.
configPrettier,
// We need to tell the vue parser that it should use the ts parser instead of the js parser.
// Set up the ts parser to use type info and understand vue files.
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
// Otherwise the parser will complain that it doesn't know vue files.
extraFileExtensions: ["vue"],
},
},
},
// Tell the vue parser that it should use the ts parser instead of the js parser.
{ files: ["**/*.vue"], languageOptions: { parserOptions: { parser: tseslint.parser } } },
);

View file

@ -6,5 +6,5 @@
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
"include": ["vite.config.ts", "eslint.config.js"]
}