Skip to content

Commit fccfa26

Browse files
committed
chore: added husky and other pre-commit linters/code formaters
Enforce conventional commit messages , and format/linting on staged files before a commit happens.
1 parent bd06a55 commit fccfa26

File tree

8 files changed

+85
-39
lines changed

8 files changed

+85
-39
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_size = 4
7+
end_of_line = lf
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true

.eslintrc.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
module.exports = {
2-
env: {
3-
commonjs: true,
4-
es2021: true,
5-
node: true,
6-
},
7-
extends: 'airbnb-base',
8-
overrides: [
9-
],
10-
parserOptions: {
11-
ecmaVersion: 'latest',
12-
},
13-
rules: {
14-
},
2+
env: {
3+
commonjs: true,
4+
es2021: true,
5+
node: true,
6+
},
7+
extends: ['airbnb-base', 'prettier'],
8+
overrides: [],
9+
parserOptions: {
10+
ecmaVersion: 'latest',
11+
},
12+
rules: {},
1513
};

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.husky/prepare-commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
exec < /dev/tty && git cz --hook || true

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"proseWrap": "never",
3+
"singleQuote": true,
4+
"trailingComma": "es5"
5+
}

lint-staged.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable import/no-commonjs */
2+
module.exports = {
3+
'**/*.(ts|js)': (filenames) => [
4+
`yarn lint --fix ${filenames.join(' ')}`,
5+
`yarn format ${filenames.join(' ')}`,
6+
],
7+
};

package.json

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
{
2-
"name": "queue-xec-master",
3-
"version": "2.0.2",
4-
"description": "Master queue, push jobs and gathers results from online workers.",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8-
},
9-
"author": "KosM",
10-
"license": "MIT",
11-
"dependencies": {
12-
"bugout": "^0.0.13",
13-
"commander": "^8.2.0",
14-
"crypto": "^1.0.1",
15-
"dotenv": "^10.0.0",
16-
"envfile": "^6.17.0",
17-
"eslint": "^7.32.0 || ^8.2.0",
18-
"events": "^3.3.0",
19-
"moment": "^2.29.4",
20-
"prompts": "^2.4.1"
21-
},
22-
"devDependencies": {
23-
"eslint-config-airbnb-base": "^15.0.0",
24-
"eslint-plugin-import": "^2.25.2"
25-
}
2+
"name": "queue-xec-master",
3+
"version": "2.0.2",
4+
"description": "Master queue, push jobs and gathers results from online workers.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"lint": "eslint --ext .js,.ts .",
9+
"format": "prettier --write .",
10+
"prepare": "husky install"
11+
},
12+
"author": "KosM",
13+
"license": "MIT",
14+
"dependencies": {
15+
"bugout": "^0.0.13",
16+
"commander": "^8.2.0",
17+
"crypto": "^1.0.1",
18+
"dotenv": "^10.0.0",
19+
"envfile": "^6.17.0",
20+
"eslint": "^7.32.0 || ^8.2.0",
21+
"events": "^3.3.0",
22+
"moment": "^2.29.4",
23+
"prompts": "^2.4.1"
24+
},
25+
"devDependencies": {
26+
"cz-conventional-changelog": "^3.3.0",
27+
"eslint-config-airbnb-base": "^15.0.0",
28+
"eslint-config-prettier": "^8.5.0",
29+
"eslint-plugin-import": "^2.25.2",
30+
"husky": "^8.0.1",
31+
"lint-staged": "^13.0.3",
32+
"prettier": "2.7.1"
33+
},
34+
"config": {
35+
"commitizen": {
36+
"path": "./node_modules/cz-conventional-changelog"
37+
}
38+
},
39+
"husky": {
40+
"hooks": {
41+
"prepare-commit-msg": "exec < /dev/tty && npx cz --hook || true"
42+
}
43+
}
2644
}

payload.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"data": {
3-
"example": [1 , 2 ,3]
3+
"example": [1, 2, 3]
44
}
5-
}
5+
}

0 commit comments

Comments
 (0)