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 <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Victor Grousset 2024-10-14 19:17:04 +02:00 committed by Katrin Fischer
parent 7469403a01
commit e83a605f25
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 34 additions and 30 deletions

View file

@ -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"
]
}
}

34
eslint.config.mjs Normal file
View file

@ -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"],
},
}];