forked from factoriolab/factoriolab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.json
103 lines (101 loc) · 3.93 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
/**
* -----------------------------------------------------
* 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,
"overrides": [
/**
* -----------------------------------------------------
* TYPESCRIPT FILES (COMPONENTS, SERVICES ETC) (.ts)
* -----------------------------------------------------
*/
{
"files": ["*.ts"],
"parserOptions": {
"project": ["tsconfig.*?.json", "e2e/tsconfig.json"],
"createDefaultProgram": true
},
"extends": ["plugin:@angular-eslint/recommended"],
"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": "lab", "style": "camelCase" }
],
"@angular-eslint/component-selector": [
"error",
{ "type": "element", "prefix": "lab", "style": "kebab-case" }
],
"@typescript-eslint/explicit-function-return-type": ["error"],
"quotes": ["error", "single", { "allowTemplateLiterals": true }]
}
},
/**
* -----------------------------------------------------
* COMPONENT TEMPLATES
* -----------------------------------------------------
*
* If you use inline templates, make sure you read the notes on the configuration
* object after this one to understand how they relate to this configuration directly
* below.
*/
{
"files": ["*.component.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": ["error", { "code": 140 }]
}
},
/**
* -----------------------------------------------------
* EXTRACT INLINE TEMPLATES (from within .component.ts)
* -----------------------------------------------------
*
* This extra piece of configuration 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 *.component.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, so there is no great benefit
* in removing it, but you can if you want to.
*
* You won't specify any rules here. As noted above, the rules that are relevant
* to inline templates are the same as the ones defined for *.component.html.
*/
{
"files": ["*.component.ts"],
"extends": ["plugin:@angular-eslint/template/process-inline-templates"]
}
]
}