@jkba/eslint-config-angular 1.7.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/eslint.config.js +62 -188
- package/package.json +6 -10
package/README.md
CHANGED
|
@@ -11,17 +11,15 @@ Opinionated ESLint config for Angular projects
|
|
|
11
11
|
```sh
|
|
12
12
|
npm i -D \
|
|
13
13
|
prettier \
|
|
14
|
-
|
|
15
|
-
@angular-eslint/eslint-plugin-template \
|
|
16
|
-
@angular-eslint/template-parser \
|
|
17
|
-
@typescript-eslint/eslint-plugin \
|
|
18
|
-
@typescript-eslint/parser \
|
|
14
|
+
angular-eslint \
|
|
19
15
|
eslint-plugin-import \
|
|
20
16
|
eslint-config-prettier \
|
|
21
17
|
eslint-plugin-prettier \
|
|
22
18
|
eslint-plugin-rxjs \
|
|
23
19
|
eslint-plugin-rxjs-angular \
|
|
24
20
|
eslint-import-resolver-typescript \
|
|
21
|
+
@eslint/js \
|
|
22
|
+
typescript-eslint \
|
|
25
23
|
@jkba/eslint-config-angular
|
|
26
24
|
|
|
27
25
|
```
|
package/eslint.config.js
CHANGED
|
@@ -1,194 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
overrides: [
|
|
3
|
-
{
|
|
4
|
-
files: [
|
|
5
|
-
'*.ts'
|
|
6
|
-
],
|
|
7
|
-
parser: '@typescript-eslint/parser',
|
|
8
|
-
parserOptions: {
|
|
9
|
-
ecmaVersion: 2019,
|
|
10
|
-
project: './tsconfig.json',
|
|
11
|
-
sourceType: 'module',
|
|
12
|
-
},
|
|
13
|
-
extends: [
|
|
14
|
-
'eslint:recommended',
|
|
15
|
-
'plugin:@typescript-eslint/stylistic-type-checked',
|
|
16
|
-
'plugin:@typescript-eslint/strict-type-checked',
|
|
17
|
-
'plugin:@angular-eslint/recommended',
|
|
18
|
-
'plugin:@angular-eslint/template/process-inline-templates',
|
|
19
|
-
'plugin:rxjs/recommended', // For some unknown weird reason, this plugin needs to be installed in child project as well.
|
|
20
|
-
'plugin:import/recommended',
|
|
21
|
-
'plugin:import/typescript',
|
|
1
|
+
// @ts-check
|
|
22
2
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
settings: {
|
|
29
|
-
// Reference https://www.npmjs.com/package/eslint-plugin-import
|
|
30
|
-
'import/resolver': {
|
|
31
|
-
// You will also need to install and configure the TypeScript resolver
|
|
32
|
-
// See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
|
|
33
|
-
'typescript': true,
|
|
34
|
-
'node': true,
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
rules: {
|
|
38
|
-
'no-implicit-coercion': 'error',
|
|
39
|
-
'no-self-compare': 'error',
|
|
40
|
-
'no-unmodified-loop-condition': 'error',
|
|
41
|
-
'no-unreachable-loop': 'error',
|
|
42
|
-
'default-case': 'warn',
|
|
43
|
-
'eqeqeq': 'error',
|
|
44
|
-
'max-classes-per-file': 'error',
|
|
45
|
-
'no-warning-comments': [ 'error', { 'terms': ['todo', 'fixme'], 'location': 'anywhere' } ],
|
|
46
|
-
'no-console': 'error',
|
|
47
|
-
'prefer-template': 'error',
|
|
48
|
-
'arrow-body-style': ['error', 'as-needed'],
|
|
3
|
+
const eslint = require('@eslint/js');
|
|
4
|
+
const tseslint = require('typescript-eslint');
|
|
5
|
+
const angular = require('angular-eslint');
|
|
6
|
+
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
|
|
7
|
+
const importPlugin = require('eslint-plugin-import');
|
|
49
8
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
9
|
+
const config = tseslint.config(
|
|
10
|
+
eslint.configs.recommended,
|
|
11
|
+
tseslint.configs.recommended,
|
|
12
|
+
{
|
|
13
|
+
files: ['**/*.ts'],
|
|
14
|
+
processor: angular.processInlineTemplates,
|
|
15
|
+
extends: [
|
|
16
|
+
eslint.configs.recommended,
|
|
17
|
+
tseslint.configs.stylisticTypeChecked,
|
|
18
|
+
tseslint.configs.strictTypeChecked,
|
|
19
|
+
angular.configs.tsRecommended,
|
|
20
|
+
// 'plugin:rxjs/recommended', // For some unknown weird reason, this plugin needs to be installed in child project as well.
|
|
21
|
+
importPlugin.flatConfigs?.recommended,
|
|
22
|
+
importPlugin.flatConfigs?.typescript,
|
|
23
|
+
],
|
|
24
|
+
settings: {
|
|
25
|
+
// Reference https://www.npmjs.com/package/eslint-plugin-import
|
|
26
|
+
'import/resolver': {
|
|
27
|
+
// You will also need to install and configure the TypeScript resolver
|
|
28
|
+
// See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
|
|
29
|
+
'typescript': true,
|
|
30
|
+
'node': true,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
files: ['**/*.html'],
|
|
36
|
+
extends: [
|
|
37
|
+
...angular.configs.templateRecommended,
|
|
38
|
+
...angular.configs.templateAccessibility,
|
|
39
|
+
],
|
|
40
|
+
rules: {
|
|
41
|
+
'@angular-eslint/template/attributes-order': 'error',
|
|
42
|
+
'@angular-eslint/template/no-inline-styles': 'warn', // For me, it is only a suggestion
|
|
43
|
+
'@angular-eslint/template/conditional-complexity': [
|
|
44
|
+
'error', { 'maxComplexity': 3 } // Max 3 is enough, create derived variable with proper naming
|
|
45
|
+
],
|
|
46
|
+
'@angular-eslint/template/i18n': 'error',
|
|
47
|
+
'@angular-eslint/template/no-any': 'error',
|
|
48
|
+
'@angular-eslint/template/no-duplicate-attributes': 'error',
|
|
49
|
+
'@angular-eslint/template/no-interpolation-in-attributes': 'error',
|
|
50
|
+
'@angular-eslint/template/prefer-self-closing-tags': 'error',
|
|
51
|
+
'@angular-eslint/template/use-track-by-function': 'error',
|
|
52
|
+
'@angular-eslint/template/prefer-control-flow': 'error'
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
// Prettier rule must always be the very last!
|
|
56
|
+
// This rule might intentionally disable some rules declared above due to conflicts
|
|
57
|
+
eslintPluginPrettierRecommended
|
|
58
|
+
);
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
* Handled by https://typescript-eslint.io/rules/no-unused-vars/
|
|
58
|
-
* You must disable the base rule as it can report incorrect errors
|
|
59
|
-
*/
|
|
60
|
-
'no-unused-vars': 'off',
|
|
60
|
+
module.exports = config;
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
'rxjs-angular/prefer-composition': 'off', // I prefer takeUntilDestroyed() operator
|
|
64
|
-
'rxjs-angular/prefer-takeuntil': [
|
|
65
|
-
'warn',
|
|
66
|
-
{
|
|
67
|
-
alias: ['takeUntilDestroyed'],
|
|
68
|
-
checkDestroy: false,
|
|
69
|
-
checkComplete: false,
|
|
70
|
-
}
|
|
71
|
-
],
|
|
62
|
+
// notes
|
|
72
63
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
'functions': false,
|
|
78
|
-
'methods': false,
|
|
79
|
-
'names': {
|
|
80
|
-
'^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate)$': false
|
|
81
|
-
},
|
|
82
|
-
'parameters': true,
|
|
83
|
-
'properties': true,
|
|
84
|
-
'strict': false,
|
|
85
|
-
'types': {
|
|
86
|
-
'^EventEmitter$': false,
|
|
87
|
-
'^Store$': false
|
|
88
|
-
},
|
|
89
|
-
'variables': true
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
'rxjs/no-exposed-subjects': [ 'error', { 'allowProtected': true } ],
|
|
93
|
-
'rxjs/no-compat': 'error',
|
|
94
|
-
'rxjs/throw-error': 'error',
|
|
95
|
-
|
|
96
|
-
'@typescript-eslint/no-unused-vars': ['error', { 'args': 'after-used' }],
|
|
97
|
-
'@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }], // Ignore `Validators.required` etc.
|
|
98
|
-
'@typescript-eslint/no-confusing-void-expression': 'off', // I just simply disagree with this rule
|
|
99
|
-
'@typescript-eslint/explicit-member-accessibility': [
|
|
100
|
-
'error', { 'overrides': { 'constructors': 'no-public' } }
|
|
101
|
-
],
|
|
102
|
-
"@typescript-eslint/prefer-optional-chain": "error",
|
|
103
|
-
|
|
104
|
-
'@angular-eslint/no-input-rename': 'off', // I just simply disagree with this rule. Especially while using "transform" property.
|
|
105
|
-
'@angular-eslint/sort-ngmodule-metadata-arrays': 'error',
|
|
106
|
-
'@angular-eslint/prefer-on-push-component-change-detection': 'error',
|
|
107
|
-
'@angular-eslint/use-component-view-encapsulation': 'warn', // For me, it is only a suggestion
|
|
108
|
-
'@angular-eslint/prefer-output-readonly': 'error', // TODO: https://github.com/jmeinlschmidt/eslint-config-angular/issues/14
|
|
109
|
-
'@angular-eslint/contextual-decorator': 'error',
|
|
110
|
-
'@angular-eslint/component-max-inline-declarations': [ 'error', { 'template': 20 } ],
|
|
111
|
-
'@angular-eslint/no-attribute-decorator': 'error',
|
|
112
|
-
'@angular-eslint/no-conflicting-lifecycle': 'error',
|
|
113
|
-
'@angular-eslint/no-empty-lifecycle-method': 'error',
|
|
114
|
-
'@angular-eslint/no-forward-ref': 'warn', // For me, it is only a suggestion
|
|
115
|
-
'@angular-eslint/no-input-prefix': 'error',
|
|
116
|
-
'@angular-eslint/no-lifecycle-call': 'error',
|
|
117
|
-
'@angular-eslint/no-pipe-impure': 'error',
|
|
118
|
-
'@angular-eslint/no-queries-metadata-property': 'error',
|
|
119
|
-
'@angular-eslint/prefer-standalone-component': 'error',
|
|
120
|
-
'@angular-eslint/relative-url-prefix': 'error',
|
|
121
|
-
// '@angular-eslint/require-localize-metadata': 'error', // TODO: https://github.com/jmeinlschmidt/eslint-config-angular/issues/13
|
|
122
|
-
'@angular-eslint/use-component-selector': 'error',
|
|
123
|
-
"@angular-eslint/component-selector": [
|
|
124
|
-
"error",
|
|
125
|
-
{
|
|
126
|
-
"type": "element",
|
|
127
|
-
"prefix": "app",
|
|
128
|
-
"style": "kebab-case",
|
|
129
|
-
}
|
|
130
|
-
],
|
|
131
|
-
"@angular-eslint/directive-selector": [
|
|
132
|
-
"error",
|
|
133
|
-
{
|
|
134
|
-
"type": "attribute",
|
|
135
|
-
"prefix": "app",
|
|
136
|
-
"style": "kebab-case", // I just don't really agree with using camelCase. Material isn't using it neither.
|
|
137
|
-
}
|
|
138
|
-
],
|
|
139
|
-
|
|
140
|
-
'import/no-absolute-path': 'error',
|
|
141
|
-
'import/newline-after-import': [ 'error', { 'count': 1 } ],
|
|
142
|
-
'import/order': [
|
|
143
|
-
'error',
|
|
144
|
-
{
|
|
145
|
-
'groups': [
|
|
146
|
-
['builtin', 'external'],
|
|
147
|
-
'internal',
|
|
148
|
-
'parent',
|
|
149
|
-
'sibling',
|
|
150
|
-
'index',
|
|
151
|
-
],
|
|
152
|
-
'newlines-between': 'always',
|
|
153
|
-
'alphabetize': {
|
|
154
|
-
'order': 'asc',
|
|
155
|
-
'caseInsensitive': true
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
|
-
'import/no-useless-path-segments': ['error', { noUselessIndex: true }],
|
|
160
|
-
// 'import/no-deprecated': 'error', // Throws false-positive for RxJS,
|
|
161
|
-
'import/no-self-import': 'error',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
files: [
|
|
166
|
-
'*.html'
|
|
167
|
-
],
|
|
168
|
-
parser: '@angular-eslint/template-parser',
|
|
169
|
-
extends: [
|
|
170
|
-
'plugin:@angular-eslint/template/accessibility',
|
|
171
|
-
'plugin:@angular-eslint/template/recommended',
|
|
64
|
+
// these two are not supported anymore
|
|
65
|
+
// "eslint-plugin-rxjs": ">=5",
|
|
66
|
+
// "eslint-plugin-rxjs-angular": ">=2",
|
|
172
67
|
|
|
173
|
-
|
|
174
|
-
// This rule might intentionally disable some rules declared above due to conflicts
|
|
175
|
-
'plugin:prettier/recommended',
|
|
176
|
-
],
|
|
177
|
-
plugins: ['@angular-eslint/template'],
|
|
178
|
-
rules: {
|
|
179
|
-
'@angular-eslint/template/attributes-order': 'error',
|
|
180
|
-
'@angular-eslint/template/no-inline-styles': 'warn', // For me, it is only a suggestion
|
|
181
|
-
'@angular-eslint/template/conditional-complexity': [
|
|
182
|
-
'error', { 'maxComplexity': 3 } // Max 3 is enough, create derived variable with proper naming
|
|
183
|
-
],
|
|
184
|
-
'@angular-eslint/template/i18n': 'error',
|
|
185
|
-
'@angular-eslint/template/no-any': 'error',
|
|
186
|
-
'@angular-eslint/template/no-duplicate-attributes': 'error',
|
|
187
|
-
'@angular-eslint/template/no-interpolation-in-attributes': 'error',
|
|
188
|
-
'@angular-eslint/template/prefer-self-closing-tags': 'error',
|
|
189
|
-
'@angular-eslint/template/use-track-by-function': 'error',
|
|
190
|
-
'@angular-eslint/template/prefer-control-flow': 'error'
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
}
|
|
68
|
+
// todo, test if we really need peer deps
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jkba/eslint-config-angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Opinionated ESLint config for Angular projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,19 +32,15 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/jmeinlschmidt/eslint-config-angular#readme",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"@
|
|
38
|
-
"@typescript-eslint/eslint-plugin": ">=6",
|
|
39
|
-
"@typescript-eslint/parser": ">=6",
|
|
40
|
-
"eslint": ">=8",
|
|
35
|
+
"angular-eslint": "^19",
|
|
36
|
+
"eslint": "^9",
|
|
37
|
+
"@eslint/js": "^9",
|
|
41
38
|
"eslint-config-prettier": ">=8",
|
|
42
39
|
"eslint-import-resolver-typescript": ">=3.5.5",
|
|
43
40
|
"eslint-plugin-import": ">=2.27.0",
|
|
44
41
|
"eslint-plugin-prettier": ">=5",
|
|
45
|
-
"eslint-plugin-rxjs": ">=5",
|
|
46
|
-
"eslint-plugin-rxjs-angular": ">=2",
|
|
47
42
|
"prettier": ">=3",
|
|
48
|
-
"typescript": ">=4"
|
|
43
|
+
"typescript": ">=4",
|
|
44
|
+
"typescript-eslint": "^8"
|
|
49
45
|
}
|
|
50
46
|
}
|