From d7804ccb7fd0db99f8de8ef3f316e69fef63eac5 Mon Sep 17 00:00:00 2001 From: Victor Grousset/tuxayo Date: Mon, 14 Oct 2024 19:17:04 +0200 Subject: [PATCH] Bug 38167: Migrate ESLint config to new flat format Test: 1. Do not apply 2. eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js 3. It should fail 4. ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js 5. It should work 6. Apply patches 7. Restart KTD to have a clean state of dependencies and check that provisionning still works. 8. ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js 9. It should fail 10. eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js 11. It should work 12 Double check rspack still works: rspack build Because we removed babel. Signed-off-by: Paul Derscheid --- .eslintrc.json | 30 ------------------------------ eslint.config.mjs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 30 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index e7f78af690..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "env": { - "browser": true, - "jquery": true - }, - "extends": [ - "eslint:recommended", - "eslint-config-prettier" - ], - "plugins": [ - "eslint-plugin-prettier" - ], - "rules": { - "indent": [ - "error", - 4 - ], - "linebreak-style": [ - "error", - "unix" - ], - "semi": [ - "error", - "always" - ], - "prettier/prettier": [ - "error" - ] - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000000..6de0fdf936 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,34 @@ +import prettier from "eslint-plugin-prettier"; +import globals from "globals"; +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", "eslint-config-prettier"), { + plugins: { + prettier, + }, + + languageOptions: { + globals: { + ...globals.browser, + ...globals.jquery, + }, + }, + + rules: { + indent: ["error", 4], + "linebreak-style": ["error", "unix"], + semi: ["error", "always"], + "prettier/prettier": ["error"], + }, +}]; \ No newline at end of file -- 2.47.0