From 26bba4e2ff28e667263495817ddde16c1463d6ae Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Fri, 20 Dec 2024 16:09:18 +0000 Subject: [PATCH] Configure eslint --- plugin/eslint.config.mjs | 95 +++++++++++++++++----------------------- plugin/package-lock.json | 28 ++++++++++-- plugin/package.json | 5 +-- 3 files changed, 68 insertions(+), 60 deletions(-) diff --git a/plugin/eslint.config.mjs b/plugin/eslint.config.mjs index 18cfb5b4..018146cf 100644 --- a/plugin/eslint.config.mjs +++ b/plugin/eslint.config.mjs @@ -1,59 +1,46 @@ -import typescriptEslint from "@typescript-eslint/eslint-plugin"; -import globals from "globals"; -import tsParser from "@typescript-eslint/parser"; -import path from "node:path"; -import { fileURLToPath } from "node:url"; -import js from "@eslint/js"; -import { FlatCompat } from "@eslint/eslintrc"; +import eslint from "@eslint/js"; +import tseslint from "typescript-eslint"; import unusedImports from "eslint-plugin-unused-imports"; -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 [ - ...compat.extends( - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended" - ), - { - plugins: { - "@typescript-eslint": typescriptEslint, - "unused-imports": unusedImports, - }, - - languageOptions: { - globals: { - ...globals.node, +export default tseslint.config({ + plugins: { + "unused-imports": unusedImports, + }, + extends: [eslint.configs.recommended, tseslint.configs.all], + ignores: ["**/types.ts"], + rules: { + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/no-floating-promises": "error", + "@typescript-eslint/parameter-properties": "off", + "@typescript-eslint/require-await": "off", + "@typescript-eslint/class-methods-use-this": "off", + "@typescript-eslint/consistent-return": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/max-params": [ + "error", + { + max: 5, }, - - parser: tsParser, - ecmaVersion: 5, - sourceType: "module", - }, - - rules: { - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": "off", - "unused-imports/no-unused-imports": "error", - "unused-imports/no-unused-vars": [ - "warn", - { - vars: "all", - varsIgnorePattern: "^_", - args: "after-used", - argsIgnorePattern: "^_", - }, - ], - - "@typescript-eslint/ban-ts-comment": "off", - "no-prototype-builtins": "off", - "@typescript-eslint/no-empty-function": "off", + ], + "unused-imports/no-unused-imports": "error", + "@typescript-eslint/no-magic-numbers": "off", + "@typescript-eslint/prefer-readonly-parameter-types": "off", + "@typescript-eslint/naming-convention": "off", + "unused-imports/no-unused-vars": [ + "warn", + { + vars: "all", + varsIgnorePattern: "^_", + args: "after-used", + argsIgnorePattern: "^_", + }, + ], + }, + languageOptions: { + parserOptions: { + projectService: true, + tsconfigRootDir: import.meta.dirname, }, }, -]; +}); diff --git a/plugin/package-lock.json b/plugin/package-lock.json index effaa73c..54d24aac 100644 --- a/plugin/package-lock.json +++ b/plugin/package-lock.json @@ -10,8 +10,6 @@ "license": "MIT", "devDependencies": { "@types/node": "^16.11.6", - "@typescript-eslint/eslint-plugin": "8.18.0", - "@typescript-eslint/parser": "8.18.0", "builtin-modules": "3.3.0", "esbuild": "0.24.0", "esbuild-plugin-wasm-pack": "^1.1.0", @@ -22,7 +20,8 @@ "openapi-typescript": "7.4.4", "p-queue": "^8.0.1", "tslib": "2.4.0", - "typescript": "5.7.2" + "typescript": "5.7.2", + "typescript-eslint": "8.18.0" } }, "node_modules/@babel/code-frame": { @@ -2483,6 +2482,29 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.18.0.tgz", + "integrity": "sha512-Xq2rRjn6tzVpAyHr3+nmSg1/9k9aIHnJ2iZeOH7cfGOWqTkXTm3kwpQglEuLGdNrYvPF+2gtAs+/KF5rjVo+WQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.18.0", + "@typescript-eslint/parser": "8.18.0", + "@typescript-eslint/utils": "8.18.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/plugin/package.json b/plugin/package.json index 7e094db9..585cd430 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -14,8 +14,7 @@ "license": "MIT", "devDependencies": { "@types/node": "^16.11.6", - "@typescript-eslint/eslint-plugin": "8.18.0", - "@typescript-eslint/parser": "8.18.0", + "typescript-eslint": "8.18.0", "builtin-modules": "3.3.0", "esbuild": "0.24.0", "esbuild-plugin-wasm-pack": "^1.1.0", @@ -28,4 +27,4 @@ "typescript": "5.7.2", "p-queue": "^8.0.1" } -} +} \ No newline at end of file