Bug 38149 - Make ESLint config compatible with version 9 and have ESLint and Prettier installed by default
Summary: Make ESLint config compatible with version 9 and have ESLint and Prettier ins...
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Victor Grousset/tuxayo
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on:
Blocks: 38167
  Show dependency treegraph
 
Reported: 2024-10-11 02:39 UTC by Victor Grousset/tuxayo
Modified: 2025-02-04 02:21 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes the Koha ESLint configuration (used for finding JavaScript errors) so that it is compatible with ESLint v9, changes the packages used so that ESLint and prettier are installed by default, and tidies some files that require updating after the prettier upgrade.
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 38149: Make ESLint config compatible with version 9 (1.33 KB, patch)
2024-10-11 02:42 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: Add ESLint & prettier to package.json (30.85 KB, patch)
2024-10-11 02:42 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: Make ESLint config compatible with version 9 (1.33 KB, patch)
2024-10-21 02:03 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: Add ESLint & prettier to package.json (964 bytes, patch)
2024-10-21 02:03 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: [DO NOT PUSH] yarn.lock changes (30.17 KB, patch)
2024-10-21 02:03 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: Make ESLint config compatible with version 9 (1.39 KB, patch)
2024-11-12 17:18 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 38149: Add ESLint & prettier to package.json (1.00 KB, patch)
2024-11-12 17:19 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 38149: [DO NOT PUSH] yarn.lock changes (30.23 KB, patch)
2024-11-12 17:19 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 38149: Make ESLint config compatible with version 9 (1.39 KB, patch)
2024-11-20 18:58 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: Add ESLint & prettier to package.json (1.00 KB, patch)
2024-11-20 18:58 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: [DO NOT PUSH] yarn.lock changes (30.56 KB, patch)
2024-11-20 18:58 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: Make ESLint config compatible with version 9 (1.39 KB, patch)
2024-12-13 02:56 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: Add ESLint & prettier to package.json (1.00 KB, patch)
2024-12-13 02:56 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: [DO NOT PUSH] yarn.lock changes (30.20 KB, patch)
2024-12-13 02:56 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review
Bug 38149: Make ESLint config compatible with version 9 (1.45 KB, patch)
2025-01-07 15:25 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38149: Add ESLint & prettier to package.json (1.07 KB, patch)
2025-01-07 15:25 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 38149: Adjust tidy of some vue and js files after prettier upgrade (39.99 KB, patch)
2025-01-16 08:37 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38149: Make ESLint config compatible with version 9 (1.52 KB, patch)
2025-01-16 11:22 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38149: Add ESLint & prettier to package.json (1.14 KB, patch)
2025-01-16 11:22 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 38149: Adjust tidy of some vue and js files after prettier upgrade (40.06 KB, patch)
2025-01-16 11:22 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Grousset/tuxayo 2024-10-11 02:39:57 UTC
To make it easier to check guideline JS8

https://wiki.koha-community.org/wiki/Coding_Guidelines#JS8:_Follow_guidelines_set_by_ESLint

And be one step closer to able to enforce it on .vue and .ts files
Comment 1 Victor Grousset/tuxayo 2024-10-11 02:42:56 UTC
Created attachment 172682 [details] [review]
Bug 38149: Make ESLint config compatible with version 9

Test plan
1. Apply patch
2. Start KTD (to check that stuff is installed automatically)
3. Run this:
   ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js
4. You should see errors from prettier in addition to others

QA notes:
1. Run this:
   yarn why eslint; yarn why prettier; yarn why eslint-config-prettier; yarn why eslint-plugin-prettier
2. See that the version are the latest from NPM website
3. See that they are in devDependencies
Comment 2 Victor Grousset/tuxayo 2024-10-11 02:42:59 UTC
Created attachment 172683 [details] [review]
Bug 38149: Add ESLint & prettier to package.json

And upgrade eslint-plugin-prettier
Comment 3 Victor Grousset/tuxayo 2024-10-11 03:24:27 UTC
This is the 2nd time I'm really messing with node stuff so I don't know what I'm doing.🙃 Don't trust anything you see! The process was throwing things at the wall and see what stuck. 🫠

I don't know if there aren't too much changes in lock files.
I did `yarn add prettier eslint --dev`
And `yarn upgrade eslint-plugin-prettier` (I think) so package.json still has the old version but the lock has the latest so it's fine. But I don't know if package.json should still be manually updated.


----

Some things I did to double check stuff:

Before applying the test plan, deleting the node_modules directory. To avoid keep manually installed stuff and wrongly thinking things worked.

.eslintrc.json
+        ],
+        "prettier/prettier": [
+            "error"
Sabotaged one and then the other of these lines and see that it errors to confirm it's not dead config.

     "extends": [
         "eslint:recommended",
-        "prettier"
+        "eslint-config-prettier"
+    ],
+    "plugins": [
+        "eslint-plugin-prettier"
Same here.

-------

Next steps after this:
1. Migrate to the flat config file to avoid having that ugly ESLINT_USE_FLAT_CONFIG='false'
2. Add the necessary stuff to be able to use ESLint on .vue and .ts files.
3. Open a ticket in QA tools (try to implement, at least partially) about having the same check with ESLint as we have with perltidy. (comparing number of messy line before and after the patches)
4. ????
5. PROFIT!!! (Finally JS8 will be fully and easily checkable!!!!! :D)
Comment 4 Jonathan Druart 2024-10-15 08:19:46 UTC
yarn.lock changes should be in a separate patch.
Comment 5 Victor Grousset/tuxayo 2024-10-21 02:03:16 UTC
Created attachment 173010 [details] [review]
Bug 38149: Make ESLint config compatible with version 9

Test plan
1. Apply patch
2. Start KTD (to check that stuff is installed automatically)
3. Run this:
   ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js
4. You should see errors from prettier in addition to others

QA notes:
1. Run this:
   yarn why eslint; yarn why prettier; yarn why eslint-config-prettier; yarn why eslint-plugin-prettier
2. See that the version are the latest from NPM website
3. See that they are in devDependencies
Comment 6 Victor Grousset/tuxayo 2024-10-21 02:03:18 UTC
Created attachment 173011 [details] [review]
Bug 38149: Add ESLint & prettier to package.json

And upgrade eslint-plugin-prettier
Comment 7 Victor Grousset/tuxayo 2024-10-21 02:03:21 UTC
Created attachment 173012 [details] [review]
Bug 38149: [DO NOT PUSH] yarn.lock changes
Comment 8 Victor Grousset/tuxayo 2024-10-21 02:04:10 UTC
(In reply to Jonathan Druart from comment #4)
> yarn.lock changes should be in a separate patch.

Indeed, thanks
Comment 9 Paul Derscheid 2024-11-12 17:18:58 UTC
Created attachment 174426 [details] [review]
Bug 38149: Make ESLint config compatible with version 9

Test plan
1. Apply patch
2. Start KTD (to check that stuff is installed automatically)
3. Run this:
   ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js
4. You should see errors from prettier in addition to others

QA notes:
1. Run this:
   yarn why eslint; yarn why prettier; yarn why eslint-config-prettier; yarn why eslint-plugin-prettier
2. See that the version are the latest from NPM website
3. See that they are in devDependencies

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 10 Paul Derscheid 2024-11-12 17:19:02 UTC
Created attachment 174427 [details] [review]
Bug 38149: Add ESLint & prettier to package.json

And upgrade eslint-plugin-prettier

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 11 Paul Derscheid 2024-11-12 17:19:05 UTC
Created attachment 174428 [details] [review]
Bug 38149: [DO NOT PUSH] yarn.lock changes

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 12 Victor Grousset/tuxayo 2024-11-20 18:58:03 UTC
Created attachment 174852 [details] [review]
Bug 38149: Make ESLint config compatible with version 9

Test plan
1. Apply patch
2. Start KTD (to check that stuff is installed automatically)
3. Run this:
   ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js
4. You should see errors from prettier in addition to others

QA notes:
1. Run this:
   yarn why eslint; yarn why prettier; yarn why eslint-config-prettier; yarn why eslint-plugin-prettier
2. See that the version are the latest from NPM website
3. See that they are in devDependencies

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 13 Victor Grousset/tuxayo 2024-11-20 18:58:06 UTC
Created attachment 174853 [details] [review]
Bug 38149: Add ESLint & prettier to package.json

And upgrade eslint-plugin-prettier

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 14 Victor Grousset/tuxayo 2024-11-20 18:58:09 UTC
Created attachment 174854 [details] [review]
Bug 38149: [DO NOT PUSH] yarn.lock changes

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 15 Victor Grousset/tuxayo 2024-11-20 18:58:38 UTC
Rebased.
Comment 16 Victor Grousset/tuxayo 2024-12-13 02:56:00 UTC
Created attachment 175424 [details] [review]
Bug 38149: Make ESLint config compatible with version 9

Test plan
1. Apply patch
2. Start KTD (to check that stuff is installed automatically)
3. Run this:
   ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js
4. You should see errors from prettier in addition to others

QA notes:
1. Run this:
   yarn why eslint; yarn why prettier; yarn why eslint-config-prettier; yarn why eslint-plugin-prettier
2. See that the version are the latest from NPM website
3. See that they are in devDependencies

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 17 Victor Grousset/tuxayo 2024-12-13 02:56:02 UTC
Created attachment 175425 [details] [review]
Bug 38149: Add ESLint & prettier to package.json

And upgrade eslint-plugin-prettier

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 18 Victor Grousset/tuxayo 2024-12-13 02:56:05 UTC
Created attachment 175426 [details] [review]
Bug 38149: [DO NOT PUSH] yarn.lock changes

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 19 Victor Grousset/tuxayo 2024-12-13 02:56:55 UTC
Updated prettier from 3.3.3 to 3.4.2
Comment 20 Martin Renvoize (ashimema) 2025-01-07 15:25:47 UTC
Created attachment 176193 [details] [review]
Bug 38149: Make ESLint config compatible with version 9

Test plan
1. Apply patch
2. Start KTD (to check that stuff is installed automatically)
3. Run this:
   ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js
4. You should see errors from prettier in addition to others

QA notes:
1. Run this:
   yarn why eslint; yarn why prettier; yarn why eslint-config-prettier; yarn why eslint-plugin-prettier
2. See that the version are the latest from NPM website
3. See that they are in devDependencies

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 21 Martin Renvoize (ashimema) 2025-01-07 15:25:49 UTC
Created attachment 176194 [details] [review]
Bug 38149: Add ESLint & prettier to package.json

And upgrade eslint-plugin-prettier

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 22 Katrin Fischer 2025-01-10 16:37:17 UTC
It looks like this (or 38167) make the tidy tests fail. I need help to resolve this, so holding back on push.

Test Summary Report
-------------------
xt/js_tidy.t                   (Wstat: 256 (exited 1) Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
xt/vue_tidy.t                  (Wstat: 256 (exited 1) Tests: 2 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Comment 23 Jonathan Druart 2025-01-15 14:45:23 UTC
Maybe this should wait for bug 38664, I am doing the upgrade of prettier with the needed fixes already.

As well as moving the prettier config to .prettierrc.js

Maybe join the force there?
Comment 24 Jonathan Druart 2025-01-16 08:32:32 UTC
Note: We are here upgrading prettier from 2.7.1 to 3.4.2.
Comment 25 Jonathan Druart 2025-01-16 08:37:50 UTC
Created attachment 176587 [details] [review]
Bug 38149: Adjust tidy of some vue and js files after prettier upgrade

Fix xt/js_tidy.t and xt/vue_tidy.t
Comment 26 Jonathan Druart 2025-01-16 11:22:51 UTC
Created attachment 176634 [details] [review]
Bug 38149: Make ESLint config compatible with version 9

Test plan
1. Apply patch
2. Start KTD (to check that stuff is installed automatically)
3. Run this:
   ESLINT_USE_FLAT_CONFIG='false' eslint koha-tmpl/intranet-tmpl/prog/js/ajax.js
4. You should see errors from prettier in addition to others

QA notes:
1. Run this:
   yarn why eslint; yarn why prettier; yarn why eslint-config-prettier; yarn why eslint-plugin-prettier
2. See that the version are the latest from NPM website
3. See that they are in devDependencies

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 27 Jonathan Druart 2025-01-16 11:22:54 UTC
Created attachment 176635 [details] [review]
Bug 38149: Add ESLint & prettier to package.json

And upgrade eslint-plugin-prettier

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 28 Jonathan Druart 2025-01-16 11:22:58 UTC
Created attachment 176636 [details] [review]
Bug 38149: Adjust tidy of some vue and js files after prettier upgrade

Fix xt/js_tidy.t and xt/vue_tidy.t

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 29 Jonathan Druart 2025-01-16 11:23:17 UTC
Good to go, I will adjust 38664 on top of this.
Comment 30 Katrin Fischer 2025-01-16 14:56:59 UTC
Pushed for 25.05!

Well done everyone, thank you!