-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
147 lines (139 loc) · 5.47 KB
/
.eslintrc.js
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
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config
It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.
We recommend eventually switching this configuration to extend from
the recommended rule sets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md
Happy linting! 💖
*/
module.exports = {
/**
* -----------------------------------------------------
* 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.
*/
overrides: [
/**
* -----------------------------------------------------
* TYPESCRIPT FILES (COMPONENTS, SERVICES ETC) (.ts)
* -----------------------------------------------------
*/
{
files: ['*.ts'],
/**
* We use a dedicated tsconfig file for the compilation related to linting so that we
* have complete control over what gets included and we can maximize performance
*/
parser: "@angular-eslint/template-parser",
parserOptions: {
project: './tsconfig.eslint.json',
},
/**
* See packages/eslint-plugin/src/configs/README.md
* for what this recommended config contains.
*/
extends: [
'plugin:@angular-eslint/recommended',
"prettier",
"prettier/@typescript-eslint"
],
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:
*/
// ORIGINAL tslint_disabled.json -> "directive-selector": [true, "attribute", "app", "camelCase"],
'@angular-eslint/directive-selector': [
'error',
{ type: 'attribute', prefix: 'app', style: 'camelCase' },
],
// ORIGINAL tslint_disabled.json -> "component-selector": [true, "element", "app", "kebab-case"],
'@angular-eslint/component-selector': [
'error',
{ type: 'element', prefix: 'app', style: 'kebab-case' },
],
quotes: ['error', 'single', { allowTemplateLiterals: true }],
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/no-implied-eval": "off",
"@typescript-eslint/no-throw-literal": "off",
"strict": "off",
"import/first": "off",
"lines-around-directive": "off"
},
},
/**
* -----------------------------------------------------
* 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'],
parser: "@angular-eslint/template-parser",
/**
* See packages/eslint-plugin-template/src/configs/README.md
* for what this recommended config contains.
*/
extends: [
'plugin:@angular-eslint/template/recommended',
"prettier",
"prettier/@typescript-eslint"
],
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 }],
},
plugins: ["@angular-eslint/template"],
},
/**
* -----------------------------------------------------
* 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'],
},
],
};