Skip to content

Commit 510f2b9

Browse files
🔧 chore(global):Configure husky + lint-staged
1 parent e8f38e2 commit 510f2b9

File tree

4 files changed

+305
-1
lines changed

4 files changed

+305
-1
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.lintstagedrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const path = require('path');
2+
3+
const buildEslintCommand = (filenames) =>
4+
`next lint --fix --file ${filenames
5+
.map((f) => path.relative(process.cwd(), f))
6+
.join(' --file ')}`;
7+
8+
module.exports = {
9+
'*.{js,jsx,ts,tsx}': [buildEslintCommand],
10+
'**/*.{js,jsx,tsx,ts,less,md,json}': ['prettier --write'],
11+
};

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint"
9+
"lint": "next lint",
10+
"prettier": "prettier --write .",
11+
"prepare": "husky install"
1012
},
1113
"dependencies": {
1214
"next": "14.2.14",
@@ -23,6 +25,8 @@
2325
"eslint-config-prettier": "^9.1.0",
2426
"eslint-plugin-simple-import-sort": "^12.1.1",
2527
"eslint-plugin-unused-imports": "^4.1.4",
28+
"husky": "^9.1.6",
29+
"lint-staged": "^15.2.10",
2630
"postcss": "^8",
2731
"prettier": "^3.3.3",
2832
"prettier-plugin-organize-imports": "^4.1.0",

0 commit comments

Comments
 (0)