Skip to content

Commit bd9b22d

Browse files
committed
Add tslint.prod.json
Now two tslint configs exist. One for development, one for production. In development, the defaultSeverity is set to "warning". Thus, compiling does not fail when breaking a rule. In production defaultSeverity is set to "error", resulting in failing compilation. When running `npm run build` tests run before building. Solution for config setup taken from wmonk/create-react-app-typescript#329 (comment) wmonk/create-react-app-typescript#133 (comment)
1 parent 68c71e0 commit bd9b22d

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
"build:styleguide": "styleguidist build",
5050
"eject": "react-scripts-ts eject",
5151
"lint": "tslint --project tsconfig.json --config tslint.json && tsc --noEmit --project tsconfig.json",
52-
"pretest": "npm run lint",
53-
"prebuild": "rimraf dist/** && rimraf build/**",
52+
"lint:prod": "tslint --project tsconfig.json --config tslint.prod.json && tsc --noEmit --project tsconfig.json",
53+
"pretest": "npm run lint:prod",
54+
"prebuild": "rimraf dist/** && rimraf build/** && npm run test",
5455
"prepublishOnly": "npm run build",
5556
"release": "np --no-yarn && git push https://github.com/terrestris/geostyler.git master --tags",
5657
"styleguide": "styleguidist server",

tslint.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": [
33
"tslint-react"
44
],
5+
"defaultSeverity": "warning",
56
"rules": {
67
"align": [
78
true,
@@ -36,16 +37,7 @@
3637
"no-any": false,
3738
"no-arg": true,
3839
"no-bitwise": true,
39-
"no-console": [
40-
true,
41-
"log",
42-
"error",
43-
"debug",
44-
"info",
45-
"time",
46-
"timeEnd",
47-
"trace"
48-
],
40+
"no-console": false,
4941
"no-consecutive-blank-lines": true,
5042
"no-construct": true,
5143
"no-debugger": false,
@@ -55,7 +47,7 @@
5547
"no-shadowed-variable": true,
5648
"no-string-literal": true,
5749
"no-switch-case-fall-through": true,
58-
"no-trailing-whitespace": false,
50+
"no-trailing-whitespace": true,
5951
"no-unused-expression": true,
6052
"no-unused-variable": true,
6153
"no-use-before-declare": true,

tslint.prod.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": ["./tslint.json"],
3+
"defaultSeverity": "error",
4+
"rules": {
5+
"no-console": [
6+
true,
7+
"log",
8+
"error",
9+
"debug",
10+
"info",
11+
"time",
12+
"timeEnd",
13+
"trace"
14+
],
15+
"no-debugger": true
16+
}
17+
}

0 commit comments

Comments
 (0)