-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.json
126 lines (126 loc) · 4.99 KB
/
.eslintrc.json
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
/**
* -----------------------------------------------------
* NOTES ON CONFIGURATION STRUCTURE
* -----------------------------------------------------
*
* Out of the box, ESLint does not support TypeScript or HTML. Naturally those are the two
* main file types we care about in Angular projects, so we have to do a little extra work
* to configure ESLint exactly how we need to.
*
* Fortunately, ESLint gives us an "overrides" configuration option which allows us to set
* different lint tooling (parser, plugins, rules etc) for different file types, which is
* critical because our .ts files require a different parser and different rules to our
* .html (and our inline Component) templates.
*/
{
"root": true,
// Additional projects are linted separately
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
/**
* -----------------------------------------------------
* TYPESCRIPT FILES (COMPONENTS, SERVICES ETC) (.ts)
* -----------------------------------------------------
*/
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.app.json",
"tsconfig.spec.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/ng-cli-compat",
/**
* NOTE:
*
* We strongly recommend using a dedicated code formatter, like Prettier, and not
* using a linter to enforce code formatting concerns.
*
* However, for maximum compatibility with how the Angular CLI has traditionally
* done things using TSLint, this code formatting related add-on config is provided.
*/
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
/**
* -----------------------------------------------------
* EXTRACT INLINE TEMPLATES (from within Component declarations)
* -----------------------------------------------------
*
* This extra extends is necessary to extract inline templates from within
* Component metadata, e.g.:
*
* @Component({
* template: `<h1>Hello, World!</h1>`
* })
* ...
*
* It works by extracting the template part of the file and treating it as
* if it were a full .html file, and it will therefore match the configuration
* specific for *.html above when it comes to actual rules etc.
*
* NOTE: This processor will skip a lot of work when it runs if you don't use
* inline templates in your projects currently, and when it runs on a non-Component
* file so there is no great benefit in removing it, but you can if you want to.
*/
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
/**
* Any TypeScript related rules you wish to use/reconfigure over and above the
* recommended set provided by the @angular-eslint project would go here.
*
* There are some examples below from the @angular-eslint plugin and ESLint core:
*/
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
/**
* -----------------------------------------------------
* COMPONENT TEMPLATES
* -----------------------------------------------------
*
* If you use inline templates, make sure you you have read the notes on the extends
* in the "*.ts" overrides above to understand how they relate to this configuration
* directly below.
*/
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {
/**
* Any template/HTML related rules you wish to use/reconfigure over and above the
* recommended set provided by the @angular-eslint project would go here.
*
* There is an example below from ESLint core (note, this specific example is not
* necessarily recommended for all projects):
*/
"max-len": ["off"]
}
}
]
}