From afa725df7ffc489177959adbcc153c984e6352b8 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 24 Oct 2025 16:35:01 +0200 Subject: [PATCH] Enhances ESLint configuration for TypeScript project Updates ESLint configuration to: - Use latest globals for Node.js and browser environments - Enable type-aware TypeScript ESLint rules - Improve parser and ecmaVersion settings - Add explicit TypeScript ESLint plugin Increases code quality and type safety for the project --- eslint.config.mjs | 20 +++++++++++--------- package-lock.json | 20 +++++++++++++++++--- package.json | 1 + 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index bdd509c..9494561 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,3 +1,4 @@ +import globals from 'globals'; import eslint from '@eslint/js'; import tseslint from 'typescript-eslint'; @@ -7,6 +8,7 @@ export default tseslint.config( ignores: [ 'node_modules/**', 'main.js', + 'dist/**', '*.config.js', '*.config.mjs' ] @@ -15,6 +17,8 @@ export default tseslint.config( eslint.configs.recommended, // TypeScript ESLint recommended rules ...tseslint.configs.recommended, + // Type-aware rules (requires tsconfig.json) + ...tseslint.configs.recommendedTypeChecked, // Project-specific configuration { files: ['**/*.ts'], @@ -22,19 +26,17 @@ export default tseslint.config( parser: tseslint.parser, parserOptions: { sourceType: 'module', - ecmaVersion: 2020 + ecmaVersion: 'latest', + project: ['./tsconfig.json'] }, globals: { - // Node.js globals - console: 'readonly', - process: 'readonly', - __dirname: 'readonly', - __filename: 'readonly', - Buffer: 'readonly', - setImmediate: 'readonly', - clearImmediate: 'readonly' + ...globals.node, + ...globals.browser } }, + plugins: { + '@typescript-eslint': tseslint.plugin + }, rules: { // Disable base rule in favor of TypeScript version 'no-unused-vars': 'off', diff --git a/package-lock.json b/package-lock.json index 49ea9f8..5f9e8c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "builtin-modules": "3.3.0", "esbuild": "0.17.3", "eslint": "^9.17.0", + "globals": "^16.4.0", "obsidian": "latest", "tslib": "2.4.0", "typescript": "5.7.3", @@ -513,6 +514,19 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/js": { "version": "9.38.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.38.0.tgz", @@ -1463,9 +1477,9 @@ } }, "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "version": "16.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.4.0.tgz", + "integrity": "sha512-ob/2LcVVaVGCYN+r14cnwnoDPUufjiYgSqRhiFD0Q1iI4Odora5RE8Iv1D24hAz5oMophRGkGz+yuvQmmUMnMw==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 7453192..a4f192a 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "builtin-modules": "3.3.0", "esbuild": "0.17.3", "eslint": "^9.17.0", + "globals": "^16.4.0", "obsidian": "latest", "tslib": "2.4.0", "typescript": "5.7.3",