Merge pull request #177 from yin1999/setup-format-check
ci(ui): setup format check tool
diff --git a/.github/workflows/dubboctl-ui-update.yaml b/.github/workflows/dubboctl-ui-update.yaml
index 07e154a..373a1e8 100644
--- a/.github/workflows/dubboctl-ui-update.yaml
+++ b/.github/workflows/dubboctl-ui-update.yaml
@@ -38,6 +38,29 @@
- Makefile
jobs:
+ lint:
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ working-directory: ui-vue3
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Setup Node.js environment
+ uses: actions/setup-node@v4
+ with:
+ node-version-file: "ui-vue3/.nvmrc"
+
+ - name: Install dependencies
+ run: yarn --frozen-lockfile
+
+ - name: Lint
+ run: |
+ # disable eslint for now as the new ui is under heavy development
+ # when the new ui is ready, we can enable eslint again (please also update the .lintstagedrc.json file)
+ # yarn lint
+ yarn prettier-check
+
update-ui:
runs-on: ubuntu-latest
if: github.repository == 'apache/dubbo-kubernetes'
diff --git a/.licenserc.yaml b/.licenserc.yaml
index 4d7dd0a..30350fc 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -81,6 +81,7 @@
- '**/testdata/**'
- '**/deploy.tpl'
- '**/docs/**'
+ - '**/.husky/pre-commit'
- '**/.nvmrc'
- '**/**.txtar'
- '**/**gen.go'
diff --git a/ui-vue3/.husky/pre-commit b/ui-vue3/.husky/pre-commit
new file mode 100644
index 0000000..36af219
--- /dev/null
+++ b/ui-vue3/.husky/pre-commit
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+npx lint-staged
diff --git a/ui-vue3/.lintstagedrc.json b/ui-vue3/.lintstagedrc.json
new file mode 100644
index 0000000..adec306
--- /dev/null
+++ b/ui-vue3/.lintstagedrc.json
@@ -0,0 +1,6 @@
+{
+ "*.{vue,ts,json}": [
+ // "lint:fix",
+ "prettier-format"
+ ]
+}
diff --git a/ui-vue3/package.json b/ui-vue3/package.json
index 2a3778d..c1ab225 100644
--- a/ui-vue3/package.json
+++ b/ui-vue3/package.json
@@ -6,13 +6,15 @@
"scripts": {
"dev": "vite",
"check:i18n": "node --loader ts-node/esm src/base/i18n/sortI18n.ts",
- "build": "prettier --write src/ && vite build",
"preview": "vite preview",
"test:unit": "vitest",
- "build-only": "vite build",
+ "build": "vite build",
"type-check": "vue-tsc --build --force",
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
- "format": "prettier --write src/"
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore",
+ "lint:fix": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
+ "prepare": "husky install",
+ "prettier-format": "prettier --write src/",
+ "prettier-check": "prettier --check src/"
},
"resolutions": {
"jackspeak": "2.1.1"
@@ -54,6 +56,7 @@
"eslint": "^8.49.0",
"eslint-plugin-cypress": "^2.15.1",
"eslint-plugin-vue": "^9.17.0",
+ "husky": "^9.0.6",
"jsdom": "^23.0.1",
"npm-run-all2": "^6.1.1",
"prettier": "^3.0.3",
diff --git a/ui-vue3/yarn.lock b/ui-vue3/yarn.lock
index fbecaf6..12b3784 100644
--- a/ui-vue3/yarn.lock
+++ b/ui-vue3/yarn.lock
@@ -3371,6 +3371,11 @@
resolved "https://registry.npmmirror.com/human-signals/-/human-signals-5.0.0.tgz#42665a284f9ae0dade3ba41ebc37eb4b852f3a28"
integrity sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==
+husky@^9.0.6:
+ version "9.0.6"
+ resolved "https://registry.npmmirror.com/husky/-/husky-9.0.6.tgz#cee0245d60480b12279cf492ec6cfc1aeb7fa759"
+ integrity sha512-EEuw/rfTiMjOfuL7pGO/i9otg1u36TXxqjIA6D9qxVjd/UXoDOsLor/BSFf5hTK50shwzCU3aVVwdXDp/lp7RA==
+
iconv-lite@0.6, iconv-lite@0.6.3, iconv-lite@^0.6.3:
version "0.6.3"
resolved "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"