- Install eslint, prettier and related plugins - Add lint and format npm scripts - Configure eslint.config.js with Svelte + TypeScript rules - Configure .prettierrc with Svelte plugin - Fix code to comply with lint rules: - Use resolve() for navigation links - Use SvelteMap for reactive maps - Use writable instead of + - Remove unused imports and variables Note: ignoreGoto is set to true due to eslint-plugin-svelte#1327
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
import js from "@eslint/js";
|
|
import svelte from "eslint-plugin-svelte";
|
|
import ts from "typescript-eslint";
|
|
import globals from "globals";
|
|
|
|
export default [
|
|
{
|
|
ignores: [
|
|
".svelte-kit",
|
|
"node_modules",
|
|
"build",
|
|
"dist",
|
|
"**/paraglide/**",
|
|
"**/lib/paraglide/**",
|
|
],
|
|
},
|
|
js.configs.recommended,
|
|
...ts.configs.recommended,
|
|
...svelte.configs["flat/recommended"],
|
|
{
|
|
languageOptions: {
|
|
ecmaVersion: "latest",
|
|
sourceType: "module",
|
|
globals: {
|
|
...globals.browser,
|
|
},
|
|
},
|
|
rules: {
|
|
"svelte/no-at-html-tags": "off",
|
|
"svelte/require-each-key": "off",
|
|
// TODO: Set ignoreGoto to false when https://github.com/sveltejs/eslint-plugin-svelte/issues/1327 is fixed
|
|
// The rule doesn't detect resolve() when used with string concatenation for query params
|
|
"svelte/no-navigation-without-resolve": [
|
|
"error",
|
|
{ ignoreLinks: true, ignoreGoto: true },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: ["**/*.svelte"],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
parser: ts.parser,
|
|
},
|
|
},
|
|
},
|
|
];
|