Skip to content

Commit

Permalink
chore(git): pre-commit hook to lint & fmt
Browse files Browse the repository at this point in the history
Run `npm i` or `npm up` for this hook to start working.
  • Loading branch information
amithm7 committed Dec 29, 2021
1 parent 4dbdcd0 commit a10abb5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
9 changes: 5 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.git
.git/
.gitignore
.env
.env.example
.github
.vscode
.prettierrc
.github/
.vscode/
.prettierrc.json
.prettierignore
.eslintrc.cjs
.eslintcache

node_modules/
worker/
Expand Down
6 changes: 5 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
},

extends: [
// Google JS Style Guide Rules
// See: https://github.com/google/eslint-config-google
"google",
],
Expand All @@ -18,6 +19,9 @@ module.exports = {

plugins: ["prettier"],
rules: {
// Google JS rules, missing in "eslint-config-google" package
"eqeqeq": ["error", "smart"],

// Rules disabled to avoid conflicts with prettier
// See: https://github.com/prettier/eslint-config-prettier
"indent": 0,
Expand All @@ -34,6 +38,6 @@ module.exports = {
// Enforces rules from .prettierrc file.
// These should be fixed automatically with formatting.
// See: https://github.com/prettier/eslint-plugin-prettier
"prettier/prettier": "warn",
"prettier/prettier": "error",
},
};
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
dist/
node_modules/
worker/
test/data/cache
test/data/cache/

package-lock.json

# IDE
.vscode

# Local enviroment variables
.env

# Cache
.eslintcache
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
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"clean": "npm run clean:wrangler",
"clean:node": "rm -rf node_modules/ package-lock.json",
"clean:wrangler": "rm -rf worker/ dist/",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"prepare": "husky install"
},
"repository": {
"type": "git",
Expand All @@ -33,6 +34,12 @@
"eslint": "^8.5.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"lint-staged": "^12.1.4",
"prettier": "2.5.1",
"webpack": "^5.65.0"
},
"lint-staged": {
"*.js": "eslint --cache --fix"
}
}

0 comments on commit a10abb5

Please sign in to comment.