forked from mgechev/codelyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.json
More file actions
384 lines (384 loc) · 15.9 KB
/
rules.json
File metadata and controls
384 lines (384 loc) · 15.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
[
{
"ruleName": "angular-whitespace",
"type": "style",
"description": "Ensures the proper formatting of Angular expressions.",
"rationale": "Having whitespace in the right places in an Angular expression makes the template more readable.",
"optionsDescription": "\nArguments may be optionally provided:\n* `\"check-interpolation\"` checks for whitespace before and after the interpolation characters\n* `\"check-pipe\"` checks for whitespace before and after a pipe\n* `\"check-semicolon\"` checks for whitespace after semicolon",
"options": {
"type": "array",
"items": {
"type": "string",
"enum": [
"check-interpolation",
"check-pipe",
"check-semicolon"
]
},
"minLength": 0,
"maxLength": 3
},
"optionExamples": [
"[true, \"check-interpolation\"]"
],
"typescriptOnly": true
},
{
"ruleName": "banana-in-box",
"type": "functionality",
"description": "Ensure that the two-way data binding syntax is correct.",
"rationale": "The parens \"()\" should have been inside the brackets \"[]\".",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "component-class-suffix",
"type": "style",
"description": "Classes decorated with @Component must have suffix \"Component\" (or custom) in their name.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-02-03.",
"rationale": "Consistent conventions make it easy to quickly identify and reference assets of different types.",
"options": {
"type": "array",
"items": {
"type": "string"
}
},
"optionExamples": [
"true",
"[true, \"Component\", \"View\"]"
],
"optionsDescription": "Supply a list of allowed component suffixes. Defaults to \"Component\".",
"typescriptOnly": true
},
{
"ruleName": "component-selector",
"type": "style",
"description": "Component selectors should follow given naming rules.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-02-07, https://angular.io/styleguide#style-05-02, and https://angular.io/styleguide#style-05-03.",
"rationale": "\n* Consistent conventions make it easy to quickly identify and reference assets of different types.\n* Makes it easier to promote and share the component in other apps.\n* Components are easy to identify in the DOM.\n* Keeps the element names consistent with the specification for Custom Elements.\n* Components have templates containing HTML and optional Angular template syntax.\n * They display content. Developers place components on the page as they would native HTML elements and WebComponents.\n* It is easier to recognize that a symbol is a component by looking at the template's HTML.\n",
"options": {
"type": "array",
"items": [
{
"enum": [
"element",
"attribute"
]
},
{
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "string"
}
]
},
{
"enum": [
"kebab-case",
"camelCase"
]
}
],
"minItems": 3,
"maxItems": 3
},
"optionExamples": [
"[\"element\", \"my-prefix\", \"kebab-case\"]",
"[\"element\", [\"ng\", \"ngx\"], \"kebab-case\"]",
"[\"attribute\", \"myPrefix\", \"camelCase\"]"
],
"optionsDescription": "\nOptions accept three obligatory items as an array:\n\n1. `\"element\"` or `\"attribute\"` forces components either to be elements or attributes.\n2. A single prefix (string) or array of prefixes (strings) which have to be used in component selectors.\n3. `\"kebab-case\"` or `\"camelCase\"` allows you to pick a case.\n",
"typescriptOnly": true
},
{
"ruleName": "contextual-life-cycle",
"type": "functionality",
"description": "Ensure that classes use allowed life cycle method in its body",
"rationale": "Some life cycle methods can only be used in certain class types.\n For example, ngOnInit() hook method should not be used in an @Injectable class.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "decorator-not-allowed",
"type": "functionality",
"description": "Ensure that classes use allowed decorator in its body",
"rationale": "Some decorators can only be used in certain class types.\n For example, an @Input should not be used in an @Injectable class.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "directive-class-suffix",
"type": "style",
"description": "Classes decorated with @Directive must have suffix \"Directive\" (or custom) in their name.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-02-03.",
"rationale": "Consistent conventions make it easy to quickly identify and reference assets of different types.",
"options": {
"type": "array",
"items": {
"type": "string"
}
},
"optionExamples": [
"true",
"[true, \"Directive\", \"MySuffix\"]"
],
"optionsDescription": "Supply a list of allowed component suffixes. Defaults to \"Directive\".",
"typescriptOnly": true
},
{
"ruleName": "directive-selector",
"type": "style",
"description": "Directive selectors should follow given naming rules.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-02-06 and https://angular.io/styleguide#style-02-08.",
"rationale": "\n* Consistent conventions make it easy to quickly identify and reference assets of different types.\n* Makes it easier to promote and share the directive in other apps.\n* Directives are easy to identify in the DOM.\n* It is easier to recognize that a symbol is a directive by looking at the template's HTML.\n",
"options": {
"type": "array",
"items": [
{
"enum": [
"element",
"attribute"
]
},
{
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "string"
}
]
},
{
"enum": [
"kebab-case",
"camelCase"
]
}
],
"minItems": 3,
"maxItems": 3
},
"optionExamples": [
"[\"element\", \"my-prefix\", \"kebab-case\"]",
"[\"element\", [\"ng\", \"ngx\"], \"kebab-case\"]",
"[\"attribute\", \"myPrefix\", \"camelCase\"]"
],
"optionsDescription": "\nOptions accept three obligatory items as an array:\n\n1. `\"element\"` or `\"attribute\"` forces components either to be elements or attributes.\n2. A single prefix (string) or array of prefixes (strings) which have to be used in directive selectors.\n3. `\"kebab-case\"` or `\"camelCase\"` allows you to pick a case.\n",
"typescriptOnly": true
},
{
"ruleName": "i18n",
"type": "maintainability",
"description": "Ensures following best practices for i18n.",
"rationale": "Makes the code more maintainable in i18n sense.",
"optionsDescription": "\nArguments may be optionally provided:\n* `\"check-id\"` Makes sure i18n attributes have ID specified\n* `\"check-text\"` Makes sure there are no elements with text content but no i18n attribute\n ",
"options": {
"type": "array",
"items": {
"type": "string",
"enum": [
"check-id",
"check-text"
]
},
"minLength": 0,
"maxLength": 3
},
"optionExamples": [
"[true, \"check-id\"]"
],
"typescriptOnly": true
},
{
"ruleName": "import-destructuring-spacing",
"type": "style",
"description": "Ensure consistent and tidy imports.",
"rationale": "Imports are easier for the reader to look at when they're tidy.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "no-attribute-parameter-decorator",
"type": "maintainability",
"description": "Disallow usage of @Attribute decorator",
"rationale": "@Attribute is considered bad practice. Use @Input instead.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "no-forward-ref",
"type": "maintainability",
"description": "Disallows usage of forward references for DI.",
"rationale": "The flow of DI is disrupted by using `forwardRef` and might make code more difficult to understand.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "no-input-rename",
"type": "maintainability",
"description": "Disallows renaming directive inputs by providing a string to the decorator.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-05-13.",
"rationale": "Two names for the same property (one private, one public) is inherently confusing.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "no-output-on-prefix",
"type": "maintainability",
"description": "Name events without the prefix on",
"descriptionDetails": "See more at https://angular.io/guide/styleguide#dont-prefix-output-properties",
"rationale": "Angular allows for an alternative syntax on-*. If the event itself was prefixed with on\n this would result in an on-onEvent binding expression",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "no-output-rename",
"type": "maintainability",
"description": "Disallows renaming directive outputs by providing a string to the decorator.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-05-13.",
"rationale": "Two names for the same property (one private, one public) is inherently confusing.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "no-unused-css",
"type": "maintainability",
"description": "Disallows having an unused CSS rule in the component's stylesheet.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "pipe-impure",
"type": "functionality",
"description": "Pipes cannot be declared as impure.",
"rationale": "Impure pipes do not perform well because they are run on every change detection cycle.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "pipe-naming",
"type": "style",
"description": "Enforce consistent case and prefix for pipes.",
"rationale": "Consistent conventions make it easy to quickly identify and reference assets of different types.",
"options": {
"type": "array",
"items": [
{
"enum": [
"kebab-case",
"attribute"
]
},
{
"type": "string"
}
],
"minItems": 1
},
"optionExamples": [
"[\"camelCase\", \"myPrefix\"]",
"[\"camelCase\", \"myPrefix\", \"myOtherPrefix\"]",
"[\"kebab-case\", \"my-prefix\"]"
],
"optionsDescription": "\n* The first item in the array is `\"kebab-case\"` or `\"camelCase\"`, which allows you to pick a case.\n* The rest of the arguments are supported prefixes (given as strings). They are optional.",
"typescriptOnly": true
},
{
"ruleName": "templates-no-negated-async",
"type": "functionality",
"description": "Ensures that strict equality is used when evaluating negations on async pipe outout.",
"rationale": "Async pipe evaluate to `null` before the observable or promise emits, which can lead to layout thrashing as components load. Prefer strict `=== false` checks instead.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "use-host-property-decorator",
"type": "style",
"description": "Use @HostProperty decorator rather than the `host` property of `@Component` and `@Directive` metadata.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-06-03.",
"rationale": "The property associated with `@HostBinding` or the method associated with `@HostListener` can be modified only in a single place: in the directive's class. If you use the `host` metadata property, you must modify both the property declaration inside the controller, and the metadata associated with the directive.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "use-input-property-decorator",
"type": "style",
"description": "Use `@Input` decorator rather than the `inputs` property of `@Component` and `@Directive` metadata.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-05-12.",
"rationale": "\n* It is easier and more readable to identify which properties in a class are inputs.\n* If you ever need to rename the property name associated with `@Input`, you can modify it in a single place.\n* The metadata declaration attached to the directive is shorter and thus more readable.\n* Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an input.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "use-life-cycle-interface",
"type": "maintainability",
"description": "Ensure that components implement life cycle interfaces if they use them.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-09-01.",
"rationale": "Interfaces prescribe typed method signatures. Use those signatures to flag spelling and syntax mistakes.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "use-output-property-decorator",
"type": "style",
"description": "Use `@Output` decorator rather than the `outputs` property of `@Component` and `@Directive` metadata.",
"descriptionDetails": "See more at https://angular.io/styleguide#style-05-12.",
"rationale": "\n* It is easier and more readable to identify which properties in a class are events.\n* If you ever need to rename the event name associated with `@Output`, you can modify it in a single place.\n* The metadata declaration attached to the directive is shorter and thus more readable.\n* Placing the decorator on the same line usually makes for shorter code and still easily identifies the property as an output.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "use-pipe-decorator",
"type": "maintainability",
"description": "Ensure that classes implementing PipeTransform interface, use Pipe decorator",
"rationale": "Interfaces prescribe typed method signatures. Use those signatures to flag spelling and syntax mistakes.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "use-pipe-transform-interface",
"type": "maintainability",
"description": "Ensure that pipes implement PipeTransform interface.",
"rationale": "Interfaces prescribe typed method signatures. Use those signatures to flag spelling and syntax mistakes.",
"options": null,
"optionsDescription": "Not configurable.",
"typescriptOnly": true
},
{
"ruleName": "use-view-encapsulation",
"type": "maintainability",
"description": "Disallows using of ViewEncapsulation.None",
"rationale": "",
"options": null,
"optionsDescription": "Not configurable",
"typescriptOnly": true
}
]