Bug 33625 - Enforce formatting on vue .js and .ts files
Summary: Enforce formatting on vue .js and .ts files
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on: 32030 32130
Blocks:
  Show dependency treegraph
 
Reported: 2023-04-27 09:11 UTC by Jonathan Druart
Modified: 2024-07-04 20:37 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00
Circulation function:


Attachments
Bug 33625: Add test (1.88 KB, patch)
2023-05-02 09:19 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33625: Pretty .js files for vue (66.82 KB, patch)
2023-05-02 09:19 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33625: Add test (1.95 KB, patch)
2023-05-02 11:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33625: Pretty .js files for vue (66.85 KB, patch)
2023-05-02 11:07 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 33625: Adjust test to deal with cypress tests (2.14 KB, patch)
2023-05-17 12:25 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 33625: Tidy remaining cypress test files (6.36 KB, patch)
2023-05-17 12:25 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 Jonathan Druart 2023-04-27 09:11:54 UTC
We have a pre-commit git hook, a QA test and an unit test (in xt/vue_tidy.t) to make sure .vue files will always be correctly formatted, but we don't have anything for the .js  and .ts files that were pretty at the beginning but are no longer.

It should be:
t/cypress/**/*.ts
koha-tmpl/intranet-tmpl/prog/js/vue/*.js
koha-tmpl/intranet-tmpl/prog/js/vue/**/*.js (maybe exclude dist?)

With the following command:
yarn run prettier --trailing-comma es5 --arrow-parens avoid --write FILES
Comment 1 Jonathan Druart 2023-05-02 08:49:20 UTC
See https://gitlab.com/koha-community/qa-test-tools/-/issues/66
Comment 3 Jonathan Druart 2023-05-02 09:19:32 UTC
Created attachment 150508 [details] [review]
Bug 33625: Add test
Comment 4 Jonathan Druart 2023-05-02 09:19:35 UTC
Created attachment 150509 [details] [review]
Bug 33625: Pretty .js files for vue

Test plan:
= Koha =
Apply the first patch, prove xt/vue_tidy.t and notice the failure
Apply this patch, now it passes

= QA test =
Apply the change to the merge request linked with this qa-test-tools' issue:
https://gitlab.com/koha-community/qa-test-tools/-/issues/62
inside your ktd container (at /kohadevbox/qa-test-tools/)
Edit a .js within koha-tmpl/intranet-tmpl/prog/js/vue and a .ts file
(cypress test) with something not pretty
Commit and run the QA script
=> It's failing!
Pretty the change, commit again, run the QA script
=> It's happy!

= KTD - git hook =
Go to the merge request linked with this ktd's issue:
https://gitlab.com/koha-community/koha-testing-docker/-/issues/374
Copy the modified git hook to .git/hooks/ktd/pre-commit
Edit a .js within koha-tmpl/intranet-tmpl/prog/js/vue and a .ts file
(cypress test) with something not pretty
Commit
=> Notice that the commit content is pretty!
Comment 5 Martin Renvoize (ashimema) 2023-05-02 11:07:30 UTC
Created attachment 150513 [details] [review]
Bug 33625: Add test

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize (ashimema) 2023-05-02 11:07:34 UTC
Created attachment 150514 [details] [review]
Bug 33625: Pretty .js files for vue

Test plan:
= Koha =
Apply the first patch, prove xt/vue_tidy.t and notice the failure
Apply this patch, now it passes

= QA test =
Apply the change to the merge request linked with this qa-test-tools' issue:
https://gitlab.com/koha-community/qa-test-tools/-/issues/62
inside your ktd container (at /kohadevbox/qa-test-tools/)
Edit a .js within koha-tmpl/intranet-tmpl/prog/js/vue and a .ts file
(cypress test) with something not pretty
Commit and run the QA script
=> It's failing!
Pretty the change, commit again, run the QA script
=> It's happy!

= KTD - git hook =
Go to the merge request linked with this ktd's issue:
https://gitlab.com/koha-community/koha-testing-docker/-/issues/374
Copy the modified git hook to .git/hooks/ktd/pre-commit
Edit a .js within koha-tmpl/intranet-tmpl/prog/js/vue and a .ts file
(cypress test) with something not pretty
Commit
=> Notice that the commit content is pretty!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Martin Renvoize (ashimema) 2023-05-02 11:08:19 UTC
Straight to QA.. all working and a good improvement as per other bugs of a similar nature.

Passing QA
Comment 8 Jonathan Druart 2023-05-16 09:51:40 UTC
Pushed to master for 23.05
Comment 9 Jonathan Druart 2023-05-17 12:25:43 UTC
Created attachment 151331 [details] [review]
Bug 33625: Adjust test to deal with cypress tests

Cypress test files were ignored.
This patch also deals with files in git index only.
Comment 10 Jonathan Druart 2023-05-17 12:25:46 UTC
Created attachment 151332 [details] [review]
Bug 33625: Tidy remaining cypress test files
Comment 11 Tomás Cohen Arazi (tcohen) 2023-05-17 13:25:58 UTC
Follow-ups pushed. Thanks
Comment 12 Matt Blenkinsop 2023-06-08 15:55:41 UTC
Enhancement - not backporting to 22.11.x