Skip to content

Commit

Permalink
chore: migrate to ESLint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
Toromyx committed Jan 20, 2024
1 parent 201b3e6 commit 00ec3c3
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 93 deletions.
12 changes: 0 additions & 12 deletions .eslintignore

This file was deleted.

81 changes: 0 additions & 81 deletions .eslintrc.json

This file was deleted.

115 changes: 115 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import configJs from "@eslint/js";
import pluginTypescript from "@typescript-eslint/eslint-plugin";
import parserTypescript from "@typescript-eslint/parser";
import configPrettier from "eslint-config-prettier";
import pluginImport from "eslint-plugin-import";
import pluginPromise from "eslint-plugin-promise";
import pluginSvelte from "eslint-plugin-svelte";
import globals from "globals";
import parserSvelte from "svelte-eslint-parser";

/** @type {FlatConfig} */
const baseConfig = {
ignores: ["dist/**", "src-tauri/target/**"],
plugins: {
import: pluginImport,
promise: pluginPromise,
},
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
...configJs.configs.recommended.rules,
...pluginPromise.configs.recommended.rules,
...configPrettier.rules,
eqeqeq: "warn",
"guard-for-in": "warn",
"no-console": "warn",
"prefer-arrow-callback": "warn",

"import/order": [
"warn",
{
alphabetize: {
order: "asc",
},
},
],
"import/no-duplicates": "warn",

"promise/always-return": [
"warn",
{
ignoreLastCallback: true,
},
],
},
};

/** @type {FlatConfig[]} */
const config = [
{
...baseConfig,
files: ["**/*.js"],
},
{
...baseConfig,
files: ["**/*.ts"],
plugins: {
...baseConfig.plugins,
"@typescript-eslint": pluginTypescript,
},
languageOptions: {
...baseConfig.languageOptions,
parser: parserTypescript,
parserOptions: {
project: "./tsconfig.json",
},
},
settings: {
...pluginImport.configs.typescript.settings,
"import/resolver": {
typescript: true,
node: true,
},
},
rules: {
...baseConfig.rules,
...pluginTypescript.configs["eslint-recommended"].rules,
...pluginTypescript.configs.recommended.rules,
...pluginTypescript.configs["recommended-requiring-type-checking"].rules,
...pluginImport.configs.typescript.rules,
...configPrettier.rules,
"@typescript-eslint/consistent-type-imports": "warn",
},
},
{
...baseConfig,
files: ["**/*.d.ts"],
},
{
...baseConfig,
files: ["**/*.svelte"],
plugins: {
...baseConfig.plugins,
svelte: pluginSvelte,
},
languageOptions: {
...baseConfig.languageOptions,
parser: parserSvelte,
},
rules: {
...baseConfig.rules,
...pluginSvelte.configs.base.overrides[0].rules,
...pluginSvelte.configs.recommended.rules,
...pluginSvelte.configs.prettier.rules,
...configPrettier.rules,
},
},
];
export default config;
14 changes: 14 additions & 0 deletions package-lock.json

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

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@eslint/js": "^8.56.0",
"@sveltejs/vite-plugin-svelte": "^3.0",
"@tauri-apps/cli": "^1.2.2",
"@types/eslint": "^8.56.2",
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
Expand All @@ -54,10 +56,12 @@
"eslint-plugin-import": "^2.27.4",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-svelte": "^2.32.2",
"globals": "^13.24.0",
"madr": "^3.0.0",
"npm-audit-resolver": "^3.0.0-RC.0",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.0",
"svelte-eslint-parser": "^0.33.1",
"typescript": "^5.0.2",
"vite": "^5.0"
}
Expand Down

0 comments on commit 00ec3c3

Please sign in to comment.