Skip to content

Commit

Permalink
Add pre-commit hook with lint check
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoPicolo committed Jul 23, 2022
1 parent 7f13cee commit 17e8cab
Show file tree
Hide file tree
Showing 6 changed files with 414 additions and 7 deletions.
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 --no-install lint-staged
13 changes: 13 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const path = require('path');

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

module.exports = {
'*.{js,jsx,ts,tsx}': [
'prettier --write',
buildEslintCommand,
],
};
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"prepare": "husky install"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"dependencies": {
"@chakra-ui/react": "^2.2.3",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"framer-motion": "^6",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"next": "12.2.2",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
32 changes: 30 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,36 @@
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"baseUrl": "src",
"paths": {
"@aws/*": ["aws/*"],
"@components/*": ["components/*"],
"@hooks": ["hooks"],
"@hooks/*": ["hooks/*"],
"@contexts/*": ["contexts/*"],
"@constants": ["constants"],
"@constants/*": ["constants/*"],
"@services/*": ["services/*"],
"@database/*": ["database/*"],
"@lib/*": ["lib/*"],
"@pages/*": ["pages/*"],
"@templates/*": ["templates/*"],
"@layouts/*": ["layouts/*"],
"@styles/*": ["styles/*"],
"@UI/*": ["UI/*"],
"@utils": ["utils"],
"@utils/*": ["utils/*"],
"@public/*": ["../public/*"]
},
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": [
"node_modules",
".next",
"out",
"bin",
".lintstagedrc.js",
"coverage"
],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
Loading

0 comments on commit 17e8cab

Please sign in to comment.