From c8a23e2b481d72389a420bbb3bc97e75db50f6c3 Mon Sep 17 00:00:00 2001 From: murashit Date: Fri, 22 May 2026 00:44:11 +0900 Subject: [PATCH] Tighten ESLint configuration --- eslint.config.mjs | 34 ++++++++++++++++++++++------------ package-lock.json | 4 ++-- package.json | 4 ++-- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 37ee648f..4830fff3 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,28 +1,31 @@ -import tsParser from "@typescript-eslint/parser"; -import tsPlugin from "@typescript-eslint/eslint-plugin"; +import js from "@eslint/js"; +import { defineConfig } from "eslint/config"; import obsidianmd from "eslint-plugin-obsidianmd"; +import tseslint from "typescript-eslint"; -const sourceFiles = ["src/**/*.ts", "src/**/*.tsx"]; +const typeScriptFiles = ["src/**/*.ts", "tests/**/*.ts"]; -export default [ +export default defineConfig([ { ignores: ["main.js", "node_modules/**", "src/generated/**"], }, + js.configs.recommended, + ...tseslint.configs.recommendedTypeChecked, ...obsidianmd.configs.recommended.map((config) => ({ ...config, basePath: "src", })), { - files: ["src/**/*.ts", "tests/**/*.ts"], + files: typeScriptFiles, languageOptions: { ecmaVersion: 2022, sourceType: "module", - parser: tsParser, parserOptions: { - project: "./tsconfig.json", + projectService: true, tsconfigRootDir: import.meta.dirname, }, globals: { + AbortSignal: "readonly", HTMLElement: "readonly", HTMLTextAreaElement: "readonly", KeyboardEvent: "readonly", @@ -32,9 +35,6 @@ export default [ requestAnimationFrame: "readonly", }, }, - plugins: { - "@typescript-eslint": tsPlugin, - }, rules: { "@typescript-eslint/consistent-type-imports": "error", "@typescript-eslint/no-explicit-any": "error", @@ -43,7 +43,17 @@ export default [ }, }, { - files: sourceFiles, + files: ["tests/**/*.ts"], + rules: { + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unnecessary-type-assertion": "off", + "@typescript-eslint/require-await": "off", + }, + }, + { + files: ["src/**/*.ts", "src/**/*.tsx"], plugins: { obsidianmd, }, @@ -57,4 +67,4 @@ export default [ ], }, }, -]; +]); diff --git a/package-lock.json b/package-lock.json index c09efa70..67e2c4e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,8 @@ "version": "1.1.0", "license": "Apache-2.0", "devDependencies": { + "@eslint/js": "^9.39.4", "@types/node": "^25.6.0", - "@typescript-eslint/eslint-plugin": "^8.59.2", - "@typescript-eslint/parser": "^8.59.2", "esbuild": "^0.28.0", "eslint": "^10.3.0", "eslint-plugin-obsidianmd": "^0.3.0", @@ -19,6 +18,7 @@ "obsidian": "~1.12.3", "prettier": "^3.8.3", "typescript": "^6.0.3", + "typescript-eslint": "^8.59.4", "vitest": "^4.1.7" } }, diff --git a/package.json b/package.json index 94e67ed5..2a7881d6 100644 --- a/package.json +++ b/package.json @@ -31,15 +31,15 @@ "check": "npm run typecheck && npm run test && npm run lint && npm run format:check && npm run build:prod" }, "devDependencies": { + "@eslint/js": "^9.39.4", "@types/node": "^25.6.0", - "@typescript-eslint/eslint-plugin": "^8.59.2", - "@typescript-eslint/parser": "^8.59.2", "esbuild": "^0.28.0", "eslint": "^10.3.0", "eslint-plugin-obsidianmd": "^0.3.0", "jsdom": "^29.1.1", "obsidian": "~1.12.3", "prettier": "^3.8.3", + "typescript-eslint": "^8.59.4", "typescript": "^6.0.3", "vitest": "^4.1.7" }