Bugzilla – Attachment 174963 Details for
Bug 38524
Add support for Vue.js and TypeScript to ESLint config to be able to actually enforce coding guideline JS8
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38524: Enable ESLint for .ts and .vue files
Bug-38524-Enable-ESLint-for-ts-and-vue-files.patch (text/plain), 4.93 KB, created by
Victor Grousset/tuxayo
on 2024-11-25 00:11:07 UTC
(
hide
)
Description:
Bug 38524: Enable ESLint for .ts and .vue files
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-11-25 00:11:07 UTC
Size:
4.93 KB
patch
obsolete
>From bbb55d4ca92a9279d298be4906f67184f1028843 Mon Sep 17 00:00:00 2001 >From: Victor Grousset/tuxayo <victor@tuxayo.net> >Date: Sat, 19 Oct 2024 15:13:58 +0200 >Subject: [PATCH] Bug 38524: Enable ESLint for .ts and .vue files > >Test plan: >1. Apply only bug 38167 and it's dependency (assuming they are not in main) >2. Restart KTD or run > sudo yarn install --modules-folder /kohadevbox/node_modules >3. Run the following and see that it doesn't lint > eslint t/cypress/integration/AdditionalFields_spec.ts > eslint koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue >4. Apply the patches of this ticket >5. restart KTD > (it tests that the provisionning works well to get all > the JS libs) >6. Run the following and see that it lints > eslint t/cypress/integration/AdditionalFields_spec.ts > eslint ./t/cypress/integration/ERM/DataProviders_spec.ts > eslint ./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts > eslint koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsReportBuilder.vue > eslint ./koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue > >Various files tested here give an idea of the output, feel free to try others. >And report stuff that should obviously be silenced due to making too much >noise and having low value or being contrary to our current practices. >Non obvious stuff to fix might be put in a follow-up ticket. > >--------- > >This was removed from config: >indent: ["error", 4], > >Because this check was finding it redundant: >npx eslint-config-prettier koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >check which is documented here: >https://github.com/prettier/eslint-config-prettier?tab=readme-ov-file#cli-helper-tool > >To doubled check, I sabotaged some indentation in a .js/.ts section on these files >koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >koha-tmpl/intranet-tmpl/prog/js/ajax.js >And without `indent: ["error", 4]` the prettier rule was still reporting the issue. >And with `indent: ["error", 4]` the issue was reported twice. >This looks enough to confirm it's redundant to keep it. > >---- > >For the same reason as above, the following was removed: >semi: ["error", "always"], >tested by removing a semicolon in >koha-tmpl/intranet-tmpl/prog/js/ajax.js >t/cypress/integration/Auth/csrf.ts > >---- > >This was removed: >"linebreak-style": ["error", "unix"], > >Because it's the default of prettier >https://prettier.io/docs/en/options.html#end-of-line >--- > eslint.config.mjs | 40 ++++++++++++++++++++++------------------ > package.json | 2 ++ > 2 files changed, 24 insertions(+), 18 deletions(-) > >diff --git a/eslint.config.mjs b/eslint.config.mjs >index 6de0fdf936..6aabe7e208 100644 >--- a/eslint.config.mjs >+++ b/eslint.config.mjs >@@ -1,8 +1,11 @@ > import prettier from "eslint-plugin-prettier"; >+import eslintConfigPrettier from "eslint-config-prettier"; > import globals from "globals"; > import path from "node:path"; > import { fileURLToPath } from "node:url"; > import js from "@eslint/js"; >+import pluginVue from "eslint-plugin-vue"; >+import ts from "typescript-eslint"; > import { FlatCompat } from "@eslint/eslintrc"; > > const __filename = fileURLToPath(import.meta.url); >@@ -10,25 +13,26 @@ const __dirname = path.dirname(__filename); > const compat = new FlatCompat({ > baseDirectory: __dirname, > recommendedConfig: js.configs.recommended, >- allConfig: js.configs.all >+ allConfig: js.configs.all, > }); > >-export default [...compat.extends("eslint:recommended", "eslint-config-prettier"), { >- plugins: { >- prettier, >- }, >- >- languageOptions: { >- globals: { >- ...globals.browser, >- ...globals.jquery, >+export default [ >+ ...compat.extends("eslint:recommended", "eslint-config-prettier"), >+ ...ts.configs.recommended, >+ ...pluginVue.configs["flat/recommended"], >+ eslintConfigPrettier, >+ { >+ plugins: { >+ prettier, >+ }, >+ languageOptions: { >+ globals: { >+ ...globals.browser, >+ ...globals.jquery, >+ }, >+ }, >+ rules: { >+ "prettier/prettier": ["error"], > }, > }, >- >- rules: { >- indent: ["error", 4], >- "linebreak-style": ["error", "unix"], >- semi: ["error", "always"], >- "prettier/prettier": ["error"], >- }, >-}]; >\ No newline at end of file >+]; >diff --git a/package.json b/package.json >index b27241b1ca..1d271e9913 100644 >--- a/package.json >+++ b/package.json >@@ -75,6 +75,7 @@ > "eslint": "^9.12.0", > "eslint-config-prettier": "^9.1.0", > "eslint-plugin-prettier": "^5.1.3", >+ "eslint-plugin-vue": "^9.29.0", > "gulp-tap": "^1.0.1", > "html-webpack-plugin": "^5.5.0", > "node-sass-tilde-importer": "^1.0.2", >@@ -87,6 +88,7 @@ > "swagger-cli": "^4.0.4", > "ts-loader": "^9.2.7", > "typescript": "^4.6.2", >+ "typescript-eslint": "^8.9.0", > "vinyl-source-stream": "^2.0.0", > "vue-loader": "^17.0.0", > "watchify": "^4.0.0", >-- >2.47.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38524
: 174963 |
174964