Skip to content

Commit

Permalink
🐳 chore: add husky and lint-staged for pre-commit check
Browse files Browse the repository at this point in the history
  • Loading branch information
NotEvenANeko committed Apr 1, 2022
1 parent 86c6cc1 commit fadafce
Show file tree
Hide file tree
Showing 7 changed files with 382 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.eslintrc.js
next-config.js
.lintstagedrc.js
node_modules/
public/
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
14 changes: 14 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const path = require('path');

const buildEslintCommand = (filenames) =>
`next lint --fix --max-warnings=0 --file ${filenames
.map((f) => path.relative(process.cwd(), f))
.join(' --file ')}`;

module.exports = {
'!(.*).{js,jsx,ts,tsx}': [
'tsc-files --noEmit',
buildEslintCommand,
'prettier --write',
],
};
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
.eslintrc.js
next-config.js
node_modules/
public/
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"prepare": "husky install"
},
"dependencies": {
"next": "12.1.4",
Expand All @@ -23,7 +24,10 @@
"eslint-config-next": "12.1.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": ">=6",
"lint-staged": ">=10",
"prettier": "^2.6.1",
"tsc-files": "^1.1.3",
"typescript": "4.6.3"
}
}
Loading

0 comments on commit fadafce

Please sign in to comment.