Skip to content

Commit 301336b

Browse files
committed
feat(template): replace pretty-quick with lint-staged, add tsconfig.json, fix eslint errors on index file
1 parent 8427dfd commit 301336b

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

generators/app/templates/.huskyrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hooks": {
3-
"pre-commit": "yarn format:stage && yarn lint",
3+
"pre-commit": "lint-staged",
44
"pre-push": "yarn build"
55
}
66
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"**/*.ts": ["yarn format", "yarn lint"]
3+
}

generators/app/templates/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
"start": "NODE_ENV=production node build/index.js",
1818
"purge": "rm -rf node_modules",
1919
"clean": "rm -rf build",
20-
"format": "prettier --write .",
21-
"format:check": "prettier --check .",
22-
"format:stage": "pretty-quick --staged",
20+
"format": "prettier --write --ignore-path .gitignore **/*.ts",
21+
"format:check": "prettier --check --ignore-path .gitignore **/*.ts",
2322
"lint": "eslint --quiet --ignore-path .gitignore **/*.ts",
2423
"release": "standard-version --no-verify",
2524
"release:major": "yarn release --release-as major",
@@ -43,16 +42,17 @@
4342
"@types/yup": "^0.26.3",
4443
"@typescript-eslint/eslint-plugin": "^2.25.0",
4544
"@typescript-eslint/parser": "^2.25.0",
45+
"eslint": "^6.8.0",
4646
"eslint-config-prettier": "^6.10.1",
47-
"eslint-config-standard": "^14.1.1",
47+
"eslint-config-standard-with-typescript": "^15.0.1",
4848
"eslint-plugin-import": "^2.20.1",
4949
"eslint-plugin-node": "^11.0.0",
5050
"eslint-plugin-promise": "^4.2.1",
5151
"eslint-plugin-standard": "^4.0.1",
52-
"eslint": "^6.8.0",
5352
"husky": "^1.2.1",
53+
"lint-staged": "^10.0.9",
5454
"prettier": "^2.0.2",
55-
"pretty-quick": "^2.0.1",
56-
"standard-version": "^4.4.0"
55+
"standard-version": "^4.4.0",
56+
"typescript": "^3.8.3"
5757
}
5858
}

generators/app/templates/src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ import logger from '@boringcodes/utils/logger';
44
import app from './app';
55

66
// declare env vars
7-
const host = process.env.HOST || 'localhost';
8-
const port = +process.env.PORT || 9000;
7+
const host =
8+
process.env.HOST !== null && process.env.HOST !== undefined
9+
? process.env.HOST
10+
: 'localhost';
11+
const port =
12+
process.env.PORT !== null && process.env.PORT !== undefined
13+
? +process.env.PORT
14+
: 9000;
915

1016
// start app
1117
app.listen(port, host, (err: Error) => {
12-
if (err) {
18+
if (err !== null && err !== undefined) {
1319
throw err;
1420
}
1521

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "node",
4+
"module": "commonjs",
5+
"target": "es6",
6+
"rootDir": "src",
7+
"outDir": "build",
8+
"esModuleInterop": true,
9+
"preserveConstEnums": true,
10+
"removeComments": true,
11+
"sourceMap": true,
12+
"strict": true
13+
},
14+
"include": [
15+
"**/*.ts"
16+
]
17+
}

0 commit comments

Comments
 (0)