-
Notifications
You must be signed in to change notification settings - Fork 5
/
eslint.config.js
190 lines (185 loc) · 7.57 KB
/
eslint.config.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
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
// @ts-check
const globals = require('globals');
// Allows us to bring in the recommended core rules from eslint itself
const eslint = require('@eslint/js');
// Allows us to use the typed utility for our config, and to bring in the recommended rules for TypeScript projects from typescript-eslint
const tseslint = require('typescript-eslint');
// Allows us to bring in the recommended rules for Angular projects from angular-eslint
const angular = require('angular-eslint');
const json = require('eslint-plugin-json');
const ignores = [
'dist/',
'tmp/',
'out-tsc/',
'bazel-out/',
'node_modules/',
'.idea/',
'.vscode/',
'.history/',
'.angular/',
'coverage/',
'coverage-ts/',
'package-lock.json',
];
// Export our config array, which is composed together thanks to the typed utility function from typescript-eslint
module.exports = tseslint.config(
{
ignores,
},
{
// Everything in this config object targets our TypeScript files (Components, Directives, Pipes etc)
files: ['**/*.ts'],
extends: [
// Apply the recommended core rules
eslint.configs.recommended,
// Apply the recommended TypeScript rules
...tseslint.configs.recommended,
// Optionally apply stylistic rules from typescript-eslint that improve code consistency
...tseslint.configs.stylistic,
// Apply the recommended Angular rules
...angular.configs.tsRecommended,
],
// Set the custom processor which will allow us to have our inline Component templates extracted
// and treated as if they are HTML files (and therefore have the .html config below applied to them)
processor: angular.processInlineTemplates,
// Override specific rules for TypeScript files (these will take priority over the extended configs above)
languageOptions: {
parserOptions: {
project: ['./tsconfig.eslint.json'],
},
},
rules: {
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: ['ngxLoaderIndicator', 'jsdaddy'],
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: 'jsdaddy',
style: 'kebab-case',
},
],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/ban-ts-comment': ['error', { minimumDescriptionLength: 10 }],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'no-array-constructor': 'off',
'no-useless-constructor': 'off',
'no-return-await': 'error',
'no-useless-catch': 'error',
'no-unused-labels': 'error',
'no-unneeded-ternary': 'error',
'no-undefined': 'error',
'no-undef-init': 'error',
'no-regex-spaces': 'error',
'no-proto': 'error',
'no-new-wrappers': 'error',
'no-unused-private-class-members': 'error',
'no-invalid-regexp': 'error',
curly: ['error', 'all'],
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/adjacent-overload-signatures': 'error',
'no-console': ['warn'],
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],
'no-unused-vars': 'off',
'no-duplicate-imports': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/indent': 0,
'@typescript-eslint/member-delimiter-style': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-use-before-define': 0,
'prefer-const': 1,
'prefer-spread': 1,
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true,
},
},
],
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'import/prefer-default-export': 'off',
'no-underscore-dangle': 'off',
'class-methods-use-this': 'off',
'lines-between-class-members': 'off',
'no-return-assign': 'off',
'no-param-reassign': [
'error',
{
props: false,
},
],
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
},
],
'no-plusplus': ['off'],
'@typescript-eslint/unbound-method': 'off',
'import/no-cycle': 'off',
'import/extensions': 'off',
},
},
{
// Everything in this config object targets our HTML files (external templates,
// and inline templates as long as we have the `processor` set on our TypeScript config above)
files: ['**/*.html'],
extends: [
// Apply the recommended Angular template rules
...angular.configs.templateRecommended,
// Apply the Angular template rules which focus on accessibility of our apps
...angular.configs.templateAccessibility,
],
rules: {},
},
{
files: ['**/*.js'],
extends: [eslint.configs.recommended],
languageOptions: {
sourceType: 'commonjs',
globals: {
...globals.node,
},
},
rules: {},
},
{
files: ['**/*.json'],
extends: [json.configs.recommended],
rules: {},
}
);