diff --git a/tools/localization/.eslintrc.js b/tools/localization/.eslintrc.js deleted file mode 100644 index d3dd495cce9d..000000000000 --- a/tools/localization/.eslintrc.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - env: { - es2021: true, - node: true, - }, - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "prettier", - ], - parser: "@typescript-eslint/parser", - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - }, - plugins: ["@typescript-eslint"], - rules: { - "no-useless-escape": 0, - }, -}; diff --git a/tools/localization/eslint.config.mjs b/tools/localization/eslint.config.mjs new file mode 100644 index 000000000000..72a15fae01e4 --- /dev/null +++ b/tools/localization/eslint.config.mjs @@ -0,0 +1,43 @@ +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"; + +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/recommended", + "prettier", + ), + { + files: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"], + plugins: { + "@typescript-eslint": typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.node, + }, + + parser: tsParser, + ecmaVersion: "latest", + sourceType: "module", + }, + + rules: { + "no-useless-escape": 0, + }, + }, +]; diff --git a/tools/localization/package.json b/tools/localization/package.json index bb8c8516c14e..c2562feecd3c 100644 --- a/tools/localization/package.json +++ b/tools/localization/package.json @@ -9,7 +9,7 @@ "start": "node ./dist/index.js", "dev": "tsc --watch", "format": "npx prettier --write .", - "lint": "eslint src/ --ext .js,.jsx,.ts,.tsx --max-warnings=0", + "lint": "eslint src/ --max-warnings=0", "test": "jest --passWithNoTests" }, "repository": "https://github.com/ankidroid/Anki-Android", @@ -23,16 +23,19 @@ "typescript": "^5.3.3" }, "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.8.0", "@types/jest": "^29.5.12", - "@types/node": "^20.11.18", - "@typescript-eslint/eslint-plugin": "^7.0.0", - "@typescript-eslint/parser": "^7.0.1", - "eslint": "^8.56.0", + "@types/node": "^22.1.0", + "@typescript-eslint/eslint-plugin": "^8.0.0", + "@typescript-eslint/parser": "^8.0.0", + "eslint": "^9.8.0", "eslint-config-prettier": "^9.1.0", "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-n": "^17.2.1", - "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-promise": "^7.0.0", + "globals": "^15.9.0", "jest": "^29.7.0", "prettier": "^3.2.5", "ts-jest": "^29.1.2",