Skip to content

Commit

Permalink
Migrated EsLint to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
stagrim committed Nov 22, 2024
1 parent 9262ace commit b30cfeb
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 104 deletions.
15 changes: 0 additions & 15 deletions .eslintignore

This file was deleted.

84 changes: 0 additions & 84 deletions .eslintrc.cjs

This file was deleted.

102 changes: 102 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import parser from "svelte-eslint-parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: [
"**/.DS_Store",
"**/node_modules",
"build",
".svelte-kit",
"package",
"**/.env",
"**/.env.*",
"!**/.env.example",
".vscode",
"src/translations/paraglide",
"**/pnpm-lock.yaml",
"**/package-lock.json",
"**/yarn.lock",
],
}, ...compat.extends(
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/stylistic",
"plugin:svelte/recommended",
"plugin:svelte/prettier",
"prettier",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
},

linterOptions: {
reportUnusedDisableDirectives: true,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
},

parser: tsParser,
ecmaVersion: 2020,
sourceType: "module",

parserOptions: {
extraFileExtensions: [".svelte"],
},
},

rules: {
"eslint-comments/require-description": "warn",

"no-restricted-imports": ["warn", {
patterns: [{
group: ["../**/*[a-zA-Z0-9_-]*/*"],
message: "\nIt looks like you're importing from a different subtree. Consider whether the imported code should really be shared. Suggestions:\n1) Write new code specific to your usage.\n2) Move the imported code to a shared location, e.g. a parent folder.\n3) Verify that you're using the correct path alias, e.g. $lib.",
}, {
importNamePattern: "^(goto|redirect)",
group: ["$app/navigation", "sveltekit-flash-message/server", "@sveltejs/kit"],
message: "Use the goto and redirect wrappers from $lib/utils/redirect instead",
}, {
importNamePattern: "^(superForm)",
group: ["sveltekit-superforms", "sveltekit-superforms/client"],
message: "Use the superForm from $lib/utils/client/superForms instead",
}],
}],

"@typescript-eslint/consistent-type-definitions": "off",

"@typescript-eslint/array-type": ["error", {
default: "array-simple",
}],
},
}, {
files: ["**/*.svelte"],

languageOptions: {
parser: parser,
ecmaVersion: 5,
sourceType: "script",

parserOptions: {
parser: "@typescript-eslint/parser",
},
},
}];
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
},
"devDependencies": {
"@clack/prompts": "^0.7.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.15.0",
"@event-calendar/core": "^3.6.2",
"@event-calendar/resource-timeline": "^3.6.2",
"@faker-js/faker": "^9.2.0",
Expand Down Expand Up @@ -69,6 +71,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-svelte": "^2.46.0",
"globals": "^15.12.0",
"husky": "^9.1.6",
"postcss": "^8.4.47",
"postcss-import": "^16.1.0",
Expand Down
31 changes: 26 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b30cfeb

Please sign in to comment.