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: Signed Off
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: Testopia
URL:
Keywords:
Depends on:
Blocks: 38167
  Show dependency treegraph
 
Reported: 2024-10-11 02:39 UTC by Victor Grousset/tuxayo
Modified: 2024-11-20 18:58 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
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

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.