From 1430d1204745c61c0edd8d885c024a3c69b6ed7c 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 BZ38700 will conflict with BZ38149 on yarn.lock solve conflict with sudo yarn install --modules-folder /kohadevbox/node_modules git bz apply --continue git will only continue for 38700 and don't actually apply this (38167) So retry git bz apply 38167 Don't apply the dependecies are they are already there. This time you're good :) (the conflict can't be durably solved because 38770 need to be applied independently or with BZ38149 depending on what other bug needs to be tested :/ ) 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 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.1