Skip to content

Commit 59d5dbc

Browse files
committed
build: add some tsrule to aid consistence and avoid code smells
1 parent 00266c2 commit 59d5dbc

File tree

2 files changed

+94
-19
lines changed

2 files changed

+94
-19
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"scripts": {
2323
"postinstall": "ngc -p ./angular-metadata.tsconfig.json && node --preserve-symlinks --preserve-symlinks-main ./tools/postinstall-patches.js && yarn ngcc",
24-
"lint": "tslint -c tslint.json '+(modules|tools)/**/*.ts' --exclude '**/+(node_modules|hello-world-app)/**/*'",
24+
"lint": "tslint -c tslint.json '+(modules|tools)/**/*.ts' -p tsconfig.json",
2525
"build": "npm run bazel:build",
2626
"prebuildifier": "bazel build --noshow_progress @com_github_bazelbuild_buildtools//buildifier",
2727
"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name BUILD -or -name BUILD.bazel -or -name WORKSPACE \\) ! -path \"*/node_modules/*\" | xargs buildifier -v",

tslint.json

+93-18
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,97 @@
33
"./tools/tslint-rules/"
44
],
55
"rules": {
6-
"max-line-length": [true, 100],
6+
"max-line-length": [
7+
true,
8+
100
9+
],
710
// Disable this flag because of SHA tslint#48b0c597f9257712c7d1f04b55ed0aa60e333f6a
811
// TSLint now shows warnings if types for properties are inferred. This rule needs to be
912
// disabled because all properties need to have explicit types set to work for Dgeni.
1013
"no-inferrable-types": false,
14+
"arrow-return-shorthand": true,
15+
"no-duplicate-imports": true,
16+
"no-angle-bracket-type-assertion": true,
17+
"no-conditional-assignment": true,
18+
"no-non-null-assertion": true,
19+
"no-unnecessary-qualifier": true,
20+
"no-string-throw": true,
21+
"encoding": true,
22+
"no-floating-promises": true,
23+
"no-import-side-effect": [
24+
true,
25+
{
26+
"ignore-module": "^(?!rxjs\/)"
27+
}
28+
],
29+
"align": [
30+
true,
31+
"elements",
32+
"members",
33+
"parameters",
34+
"statements"
35+
],
1136
"class-name": true,
1237
"comment-format": [
1338
true,
1439
"check-space"
1540
],
1641
"indent": [
1742
true,
18-
"spaces"
43+
"spaces",
44+
2
1945
],
46+
"array-type": [
47+
true,
48+
"array-simple"
49+
],
50+
"deprecation": {
51+
"severity": "warning"
52+
},
2053
"eofline": true,
54+
"import-spacing": false,
55+
"match-default-export-name": true,
56+
"newline-before-return": true,
57+
"no-consecutive-blank-lines": [
58+
true,
59+
2
60+
],
2161
"no-duplicate-variable": true,
2262
"no-eval": true,
2363
"no-arg": true,
24-
"no-internal-module": true,
25-
"no-trailing-whitespace": true,
2664
"no-bitwise": true,
2765
"no-shadowed-variable": true,
66+
"no-debugger": true,
67+
"no-console": true,
68+
"no-internal-module": true,
69+
"no-trailing-whitespace": true,
2870
"no-unused-expression": true,
2971
"no-var-keyword": true,
30-
"no-debugger": true,
3172
"one-line": [
3273
true,
3374
"check-catch",
3475
"check-else",
76+
"check-finally",
3577
"check-open-brace",
3678
"check-whitespace"
3779
],
80+
"ordered-imports": [
81+
true,
82+
{
83+
"import-sources-order": "lowercase-last",
84+
"named-imports-order": "lowercase-last"
85+
}
86+
],
87+
"prefer-const": true,
3888
"quotemark": [
3989
true,
4090
"single",
4191
"avoid-escape"
4292
],
43-
"semicolon": true,
93+
"semicolon": [
94+
true,
95+
"always"
96+
],
4497
"typedef-whitespace": [
4598
true,
4699
{
@@ -56,33 +109,52 @@
56109
true,
57110
"ban-keywords",
58111
"check-format",
59-
"allow-leading-underscore"
112+
"allow-leading-underscore",
113+
"allow-pascal-case"
60114
],
61115
"whitespace": [
62116
true,
63117
"check-branch",
64118
"check-decl",
119+
"check-module",
120+
"check-preblock",
65121
"check-operator",
66122
"check-separator",
67123
"check-type",
68-
"check-preblock"
124+
"check-typecast"
69125
],
70126
// Bans jasmine helper functions that will prevent the CI from properly running tests.
71127
"ban": [
72128
true,
73-
["fit"],
74-
["fdescribe"],
75-
["xit"],
76-
["xdescribe"],
77-
{"name": "Object.assign", "message": "Use the spread operator instead."}
129+
[
130+
"fit"
131+
],
132+
[
133+
"fdescribe"
134+
],
135+
[
136+
"xit"
137+
],
138+
[
139+
"xdescribe"
140+
],
141+
{
142+
"name": "Object.assign",
143+
"message": "Use the spread operator instead."
144+
}
78145
],
79146
// Disallows importing the whole RxJS library. Submodules can be still imported.
80147
// Avoids inconsistent linebreak styles in source files. Forces developers to use LF linebreaks.
81-
"linebreak-style": [true, "LF"],
148+
"linebreak-style": [
149+
true,
150+
"LF"
151+
],
82152
// Namespaces are no allowed, because of Closure compiler.
83153
"no-namespace": true,
84-
"jsdoc-format": [true, "check-multiline-start"],
85-
154+
"jsdoc-format": [
155+
true,
156+
"check-multiline-start"
157+
],
86158
// Custom Rules
87159
"ts-loader": true,
88160
"no-exposed-todo": true,
@@ -97,9 +169,12 @@
97169
"deletion-target": true
98170
},
99171
"linterOptions": {
172+
"format": "codeFrame",
100173
"exclude": [
101174
// Exclude schematic template files that can't be linted.
102-
"**/schematics/**/files/**/*"
175+
"**/schematics/**/files/**/*",
176+
"**/node_modules/**/*",
177+
"**/hello-world-app/**/*"
103178
]
104179
}
105-
}
180+
}

0 commit comments

Comments
 (0)