Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

chore(ui): Add lint-staged

robin414550991933
diff --git a/ui/.eslintrc.js b/ui/.eslintrc.js
index 6ecb4b49..7013efbc 100644
--- a/ui/.eslintrc.js
+++ b/ui/.eslintrc.js
@@ -23,8 +23,9 @@ module.exports = {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
- plugins: ['react', '@typescript-eslint'],
+ plugins: ['react', '@typescript-eslint', 'prettier'],
rules: {
+ 'prettier/prettier': 'error',
'no-unused-vars': 'off',
'no-console': 'off',
'import/prefer-default-export': 'off',
diff --git a/ui/.lintstagedrc.json b/ui/.lintstagedrc.json
index 8f3e37e6..fce648a8 100644
--- a/ui/.lintstagedrc.json
+++ b/ui/.lintstagedrc.json
@@ -1,5 +1,14 @@
{
- "*.{js,jsx,ts,tsx}": ["eslint --cache --fix"],
- "*.{js,jsx,less,md,json}": ["prettier --write"],
- "*.ts?(x)": ["prettier --parser=typescript --write"]
+ "*.{js,jsx,ts,tsx}": [
+ "cd ui && eslint --cache --fix",
+ "git add"
+ ],
+ "*.{js,jsx,scss,md,json}": [
+ "cd ui && prettier --write",
+ "git add"
+ ],
+ "*.ts?(x)": [
+ "cd ui && prettier --parser=typescript --write",
+ "git add"
+ ]
}
diff --git a/ui/package.json b/ui/package.json
index 4dd40263..801ac693 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -9,7 +9,8 @@
"lint": "eslint . --cache --fix --ext .ts,.tsx",
"prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
"prepare": "cd .. && husky install",
- "preinstall": "node ./scripts/preinstall.js"
+ "preinstall": "node ./scripts/preinstall.js",
+ "pre-commit": "lint-staged"
},
"dependencies": {
"axios": "^0.27.2",