@ethlete/eslint-plugin 0.1.0-next.0 → 0.1.0-next.1
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/CHANGELOG.md +6 -0
- package/package.json +3 -4
- package/src/configs/recommended.js +362 -0
- package/src/index.js +116 -0
- package/src/rules/angular-decorator-property-order.js +217 -0
- package/src/rules/enforce-routing-view-naming.js +84 -0
- package/src/rules/guard-return-newline.js +81 -0
- package/src/rules/inject-member-accessibility.js +286 -0
- package/src/rules/no-angular-router-api.js +158 -0
- package/src/rules/no-angular-seo-services.js +82 -0
- package/src/rules/no-direct-dom-manipulation.js +160 -0
- package/src/rules/no-document-cookie.js +55 -0
- package/src/rules/no-dom-query.js +81 -0
- package/src/rules/no-inject-chain.js +44 -0
- package/src/rules/no-legacy-angular-decorators.js +210 -0
- package/src/rules/no-locale-id.js +57 -0
- package/src/rules/no-member-alias.js +151 -0
- package/src/rules/no-native-observers.js +102 -0
- package/src/rules/no-pipe-logic.js +76 -0
- package/src/rules/no-public-property.js +39 -0
- package/src/rules/no-readonly-signal.js +119 -0
- package/src/rules/no-rxjs-in-effect.js +88 -0
- package/src/rules/no-screaming-case-local.js +113 -0
- package/src/rules/no-subscribe-in-pipe.js +89 -0
- package/src/rules/no-subscribe-with-body.js +95 -0
- package/src/rules/no-trivial-return-type.js +104 -0
- package/src/rules/no-trivial-wrapper-method.js +120 -0
- package/src/rules/no-type-only-import.js +79 -0
- package/src/rules/no-unused-class-member.js +209 -0
- package/src/rules/no-window-location.js +109 -0
- package/src/rules/prefer-clone-equal.js +112 -0
- package/src/rules/prefer-concise-angular-host-directives.js +225 -0
- package/src/rules/prefer-concise-angular-style-metadata.js +108 -0
- package/src/rules/prefer-element-dimensions.js +128 -0
- package/src/rules/prefer-linked-signal.js +124 -0
- package/src/rules/prefer-match-media.js +101 -0
- package/src/rules/prefer-rxjs-timer.js +82 -0
- package/src/rules/prefer-scroll-state.js +158 -0
- package/src/rules/prefer-viewport-size.js +75 -0
- package/src/rules/require-dollar-suffix.js +123 -0
- package/src/rules/require-view-encapsulation-none.js +101 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6ec51b4`](https://github.com/ethlete-io/ethdk/commit/6ec51b49497ba53bf34ec0aabcf519957ba0e412) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix plugin not including js files
|
|
8
|
+
|
|
3
9
|
## 0.1.0-next.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethlete/eslint-plugin",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -9,6 +9,5 @@
|
|
|
9
9
|
"@typescript-eslint/eslint-plugin": ">=8.0.0",
|
|
10
10
|
"eslint": ">=9.0.0",
|
|
11
11
|
"tslib": "2.8.1"
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Flat config entries for TypeScript files.
|
|
6
|
+
* Covers all lintable rules from the Ethlete styleguide.
|
|
7
|
+
*
|
|
8
|
+
* @type {import('eslint').Linter.Config}
|
|
9
|
+
*/
|
|
10
|
+
const recommendedTs = {
|
|
11
|
+
files: ['**/*.ts'],
|
|
12
|
+
plugins: {
|
|
13
|
+
// The plugin itself is injected by the caller (see index.js)
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
// ── TypeScript ──────────────────────────────────────────────────────────
|
|
17
|
+
|
|
18
|
+
// No interface — use type
|
|
19
|
+
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
|
|
20
|
+
|
|
21
|
+
// No any
|
|
22
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
23
|
+
|
|
24
|
+
// No declared-but-never-read variables, parameters, or imports
|
|
25
|
+
// Args prefixed with _ are exempt (intentionally unused callback params)
|
|
26
|
+
'no-unused-vars': 'off', // disabled in favour of the TS-aware version below
|
|
27
|
+
'@typescript-eslint/no-unused-vars': [
|
|
28
|
+
'error',
|
|
29
|
+
{
|
|
30
|
+
vars: 'all',
|
|
31
|
+
args: 'all',
|
|
32
|
+
argsIgnorePattern: '^_',
|
|
33
|
+
caughtErrors: 'all',
|
|
34
|
+
caughtErrorsIgnorePattern: '^_',
|
|
35
|
+
ignoreRestSiblings: true,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
|
|
39
|
+
// ── Naming & formatting ─────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
// No var
|
|
42
|
+
'no-var': 'error',
|
|
43
|
+
|
|
44
|
+
// No unnecessary let — default to const
|
|
45
|
+
'prefer-const': 'error',
|
|
46
|
+
|
|
47
|
+
// Never declare multiple variables in one statement
|
|
48
|
+
'one-var': ['error', 'never'],
|
|
49
|
+
|
|
50
|
+
// Always === / !==
|
|
51
|
+
eqeqeq: ['error', 'always'],
|
|
52
|
+
|
|
53
|
+
// Max two function parameters
|
|
54
|
+
'max-params': ['error', 2],
|
|
55
|
+
|
|
56
|
+
// No _ or # prefixes; enforce camelCase / PascalCase / UPPER_CASE
|
|
57
|
+
'@typescript-eslint/naming-convention': [
|
|
58
|
+
'error',
|
|
59
|
+
{
|
|
60
|
+
selector: 'default',
|
|
61
|
+
leadingUnderscore: 'forbid',
|
|
62
|
+
trailingUnderscore: 'forbid',
|
|
63
|
+
format: null,
|
|
64
|
+
},
|
|
65
|
+
// Allow any format for object literal properties that require quotes
|
|
66
|
+
// (e.g. Angular host binding keys: '[class.foo]', '(click)', '[attr.aria-label]')
|
|
67
|
+
{
|
|
68
|
+
selector: 'objectLiteralProperty',
|
|
69
|
+
modifiers: ['requiresQuotes'],
|
|
70
|
+
format: null,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
selector: ['variable', 'parameter', 'property', 'parameterProperty', 'accessor'],
|
|
74
|
+
leadingUnderscore: 'forbid',
|
|
75
|
+
trailingUnderscore: 'forbid',
|
|
76
|
+
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
selector: 'typeLike',
|
|
80
|
+
leadingUnderscore: 'forbid',
|
|
81
|
+
trailingUnderscore: 'forbid',
|
|
82
|
+
format: ['PascalCase'],
|
|
83
|
+
},
|
|
84
|
+
// Generic type parameters must be T-prefixed: TValue, TResult — never bare T
|
|
85
|
+
{
|
|
86
|
+
selector: 'typeParameter',
|
|
87
|
+
leadingUnderscore: 'forbid',
|
|
88
|
+
trailingUnderscore: 'forbid',
|
|
89
|
+
prefix: ['T'],
|
|
90
|
+
format: ['PascalCase'],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
selector: 'enumMember',
|
|
94
|
+
leadingUnderscore: 'forbid',
|
|
95
|
+
trailingUnderscore: 'forbid',
|
|
96
|
+
format: ['UPPER_CASE', 'PascalCase'],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
|
|
100
|
+
// ── Banned syntax ───────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
'no-restricted-syntax': [
|
|
103
|
+
'error',
|
|
104
|
+
// No enum — use const object + derived union type
|
|
105
|
+
{
|
|
106
|
+
selector: 'TSEnumDeclaration',
|
|
107
|
+
message: 'No enums. Use a const object + derived union type instead.',
|
|
108
|
+
},
|
|
109
|
+
// No standalone function declarations / expressions — use arrow functions
|
|
110
|
+
{
|
|
111
|
+
selector: 'FunctionDeclaration',
|
|
112
|
+
message: 'No function declarations. Use arrow functions instead.',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
selector: "FunctionExpression:not([parent.type='Property']):not([parent.type='MethodDefinition'])",
|
|
116
|
+
message: 'No function expressions outside of object methods or class methods. Use arrow functions.',
|
|
117
|
+
},
|
|
118
|
+
// No arrow properties in classes — use regular methods
|
|
119
|
+
{
|
|
120
|
+
selector: 'PropertyDefinition > ArrowFunctionExpression',
|
|
121
|
+
message: 'No arrow function properties in classes. Use regular methods.',
|
|
122
|
+
},
|
|
123
|
+
// No async/await — use RxJS
|
|
124
|
+
{
|
|
125
|
+
selector: 'FunctionDeclaration[async=true]',
|
|
126
|
+
message: 'No async/await. Use RxJS for all async operations.',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
selector: 'ArrowFunctionExpression[async=true]',
|
|
130
|
+
message: 'No async/await. Use RxJS for all async operations.',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
selector: 'FunctionExpression[async=true]',
|
|
134
|
+
message: 'No async/await. Use RxJS for all async operations.',
|
|
135
|
+
},
|
|
136
|
+
// No public keyword on class members
|
|
137
|
+
{
|
|
138
|
+
selector: "MethodDefinition[accessibility='public']",
|
|
139
|
+
message: 'No public keyword on class members.',
|
|
140
|
+
},
|
|
141
|
+
// No static class members
|
|
142
|
+
{
|
|
143
|
+
selector: 'MethodDefinition[static=true]',
|
|
144
|
+
message: 'No static class members.',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
selector: 'PropertyDefinition[static=true]',
|
|
148
|
+
message: 'No static class members.',
|
|
149
|
+
},
|
|
150
|
+
// No # prefix — use private keyword
|
|
151
|
+
{
|
|
152
|
+
selector: "PropertyDefinition[key.type='PrivateIdentifier']",
|
|
153
|
+
message: 'No # prefix on class members. Use the private keyword instead.',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
selector: "MethodDefinition[key.type='PrivateIdentifier']",
|
|
157
|
+
message: 'No # prefix on class members. Use the private keyword instead.',
|
|
158
|
+
},
|
|
159
|
+
// No constructor injection — use inject()
|
|
160
|
+
{
|
|
161
|
+
selector: 'TSParameterProperty[accessibility]',
|
|
162
|
+
message: 'No constructor injection. Use inject() instead.',
|
|
163
|
+
},
|
|
164
|
+
// No legacy Angular lifecycle hooks
|
|
165
|
+
{
|
|
166
|
+
selector:
|
|
167
|
+
'MethodDefinition[key.name=/^ngOnChanges$|^ngAfterViewInit$|^ngAfterContentInit$|^ngAfterContentChecked$|^ngAfterViewChecked$|^ngDoCheck$/]',
|
|
168
|
+
message:
|
|
169
|
+
'No legacy Angular lifecycle hooks. Use afterNextRender, inject(DestroyRef).onDestroy, or constructor-based effects instead.',
|
|
170
|
+
},
|
|
171
|
+
// No @Injectable — use createRootProvider / createProvider from @ethlete/core
|
|
172
|
+
{
|
|
173
|
+
selector: "Decorator[expression.callee.name='Injectable'], Decorator[expression.name='Injectable']",
|
|
174
|
+
message: 'No @Injectable services. Use createRootProvider / createProvider from @ethlete/core instead.',
|
|
175
|
+
},
|
|
176
|
+
// No route guards — handle access control inside the component itself
|
|
177
|
+
{
|
|
178
|
+
selector:
|
|
179
|
+
'TSClassImplements > Identifier.expression[name=/^CanActivate$|^CanDeactivate$|^CanActivateChild$|^CanMatch$|^CanLoad$/]',
|
|
180
|
+
message: 'No route guards. Handle access control inside the component itself.',
|
|
181
|
+
},
|
|
182
|
+
// No route resolvers — use the query library to fetch data
|
|
183
|
+
{
|
|
184
|
+
selector: "TSClassImplements > Identifier.expression[name='Resolve']",
|
|
185
|
+
message: 'No route resolvers. Use the query library to fetch data instead.',
|
|
186
|
+
},
|
|
187
|
+
// No barrel imports — import directly from the source file
|
|
188
|
+
{
|
|
189
|
+
selector: 'ImportDeclaration[source.value=/(^|[/])index$/]',
|
|
190
|
+
message:
|
|
191
|
+
'No barrel imports (index files). Import directly from the source file to avoid breaking lazy loading.',
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
|
|
195
|
+
// ── Native DOM globals ──────────────────────────────────────────────────
|
|
196
|
+
|
|
197
|
+
// No direct document/window access — use inject(DOCUMENT) / inject(WINDOW) instead
|
|
198
|
+
'no-restricted-globals': [
|
|
199
|
+
'error',
|
|
200
|
+
{
|
|
201
|
+
name: 'document',
|
|
202
|
+
message: "Use inject(DOCUMENT) from '@angular/common' instead of the global document.",
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'window',
|
|
206
|
+
message: 'Avoid accessing the global window directly. Use platform detection or a dedicated injection token.',
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
|
|
210
|
+
// ── Custom plugin rules ─────────────────────────────────────────────────
|
|
211
|
+
|
|
212
|
+
// No inject(X).member chaining — assign to a const first
|
|
213
|
+
'ethlete/no-inject-chain': 'error',
|
|
214
|
+
|
|
215
|
+
// No public properties except explicit injected external APIs
|
|
216
|
+
'ethlete/no-public-property': 'error',
|
|
217
|
+
|
|
218
|
+
// No explicit trivial return types TypeScript can infer
|
|
219
|
+
'ethlete/no-trivial-return-type': 'error',
|
|
220
|
+
|
|
221
|
+
// Empty line required before return in multi-statement if-blocks (guard clauses)
|
|
222
|
+
'ethlete/guard-return-newline': 'error',
|
|
223
|
+
|
|
224
|
+
// No code in subscribe() callbacks — use tap() instead
|
|
225
|
+
'ethlete/no-subscribe-with-body': 'error',
|
|
226
|
+
|
|
227
|
+
// Observable variables/properties must end with $
|
|
228
|
+
'ethlete/require-dollar-suffix': 'error',
|
|
229
|
+
|
|
230
|
+
// No .subscribe() inside a .pipe() callback
|
|
231
|
+
'ethlete/no-subscribe-in-pipe': 'error',
|
|
232
|
+
|
|
233
|
+
// No .subscribe() inside effect() or computed()
|
|
234
|
+
'ethlete/no-rxjs-in-effect': 'error',
|
|
235
|
+
|
|
236
|
+
// No readonly on reactive class properties (signals, inputs, computed, inject, etc.)
|
|
237
|
+
'ethlete/no-readonly-signal': 'error',
|
|
238
|
+
|
|
239
|
+
// No SCREAMING_CASE variable names inside function bodies
|
|
240
|
+
'ethlete/no-screaming-case-local': 'error',
|
|
241
|
+
|
|
242
|
+
// Prefer RxJS timer/interval/fromEvent over setTimeout/setInterval/addEventListener
|
|
243
|
+
'ethlete/prefer-rxjs-timer': 'error',
|
|
244
|
+
|
|
245
|
+
// Prefer linkedSignal over signal + .set() inside effect()
|
|
246
|
+
'ethlete/prefer-linked-signal': 'warn',
|
|
247
|
+
|
|
248
|
+
// No trivial wrapper methods that only forward all args to another call
|
|
249
|
+
'ethlete/no-trivial-wrapper-method': 'error',
|
|
250
|
+
|
|
251
|
+
// No direct DOM manipulation — use injectRenderer() from @ethlete/core instead
|
|
252
|
+
'ethlete/no-direct-dom-manipulation': 'error',
|
|
253
|
+
|
|
254
|
+
// No raw IntersectionObserver / MutationObserver / ResizeObserver — use @ethlete/core signal utils
|
|
255
|
+
'ethlete/no-native-observers': 'error',
|
|
256
|
+
|
|
257
|
+
// Prefer injectViewportSize() over window.innerWidth / innerHeight / outerWidth / outerHeight
|
|
258
|
+
'ethlete/prefer-viewport-size': 'warn',
|
|
259
|
+
|
|
260
|
+
// Prefer injectMediaQueryIsMatched() / injectBreakpointIsMatched() etc. over .matchMedia()
|
|
261
|
+
'ethlete/prefer-match-media': 'error',
|
|
262
|
+
|
|
263
|
+
// Prefer signalElementDimensions() / signalHostElementDimensions() in reactive contexts
|
|
264
|
+
'ethlete/prefer-element-dimensions': 'warn',
|
|
265
|
+
|
|
266
|
+
// Prefer signalElementScrollState() / signalHostElementScrollState() in reactive contexts
|
|
267
|
+
'ethlete/prefer-scroll-state': 'warn',
|
|
268
|
+
|
|
269
|
+
// No `import type { Foo }` or `import { type Foo }` — use regular value imports
|
|
270
|
+
'ethlete/no-type-only-import': 'error',
|
|
271
|
+
|
|
272
|
+
// No legacy Angular decorators — use signal-based APIs (input, output, viewChild, etc.)
|
|
273
|
+
// and host: {} bindings (instead of @HostBinding / @HostListener)
|
|
274
|
+
'ethlete/no-legacy-angular-decorators': 'error',
|
|
275
|
+
|
|
276
|
+
// No Angular Title/Meta services — use @ethlete/core SEO utilities instead
|
|
277
|
+
// (injectTitleBinding, injectMetaBinding, injectLinkBinding, etc.)
|
|
278
|
+
'ethlete/no-angular-seo-services': 'error',
|
|
279
|
+
|
|
280
|
+
// No JSON.parse(JSON.stringify()), structuredClone, or lodash cloneDeep / isEqual
|
|
281
|
+
// — use clone() / equal() from '@ethlete/core' instead
|
|
282
|
+
'ethlete/prefer-clone-equal': 'error',
|
|
283
|
+
|
|
284
|
+
// No direct document.cookie access
|
|
285
|
+
// — use getCookie / setCookie / hasCookie / deleteCookie from '@ethlete/core' instead
|
|
286
|
+
'ethlete/no-document-cookie': 'error',
|
|
287
|
+
|
|
288
|
+
// Injected providers must be private by default, and protected only when
|
|
289
|
+
// referenced from an Angular template or host binding.
|
|
290
|
+
'ethlete/inject-member-accessibility': 'error',
|
|
291
|
+
|
|
292
|
+
// No ActivatedRoute (fully replaced by inject* router utilities from @ethlete/core)
|
|
293
|
+
// No inject(Router) for state reading — use injectUrl/injectRoute/injectQueryParam etc.
|
|
294
|
+
'ethlete/no-angular-router-api': 'warn',
|
|
295
|
+
|
|
296
|
+
// No window.location.* reads for URL state — use injectUrl/injectRoute/injectQueryParam etc.
|
|
297
|
+
// No new URLSearchParams(window.location.search) — use injectQueryParams()
|
|
298
|
+
'ethlete/no-window-location': 'warn',
|
|
299
|
+
|
|
300
|
+
// No inject(LOCALE_ID) — use injectLocale() from '@ethlete/core'
|
|
301
|
+
'ethlete/no-locale-id': 'error',
|
|
302
|
+
|
|
303
|
+
// No class members that are pure aliases for a nested property of another member
|
|
304
|
+
// — widen the accessibility of the source member instead
|
|
305
|
+
'ethlete/no-member-alias': 'error',
|
|
306
|
+
|
|
307
|
+
// No declared-but-never-read private/protected class members
|
|
308
|
+
'ethlete/no-unused-class-member': 'error',
|
|
309
|
+
|
|
310
|
+
// No direct DOM query methods (querySelector, getElementById, etc.)
|
|
311
|
+
// — use viewChild() / viewChildren() or contentChild() / contentChildren() instead
|
|
312
|
+
'ethlete/no-dom-query': 'error',
|
|
313
|
+
|
|
314
|
+
// ── Angular outputs ─────────────────────────────────────────────────────
|
|
315
|
+
|
|
316
|
+
// No on-prefixed outputs (onSelectDate → selectDate)
|
|
317
|
+
'@angular-eslint/no-output-on-prefix': 'error',
|
|
318
|
+
|
|
319
|
+
// No outputs named after native DOM events (change, click, etc.)
|
|
320
|
+
'@angular-eslint/no-output-native': 'error',
|
|
321
|
+
|
|
322
|
+
// ── Angular components ──────────────────────────────────────────────────
|
|
323
|
+
|
|
324
|
+
// Always use ChangeDetectionStrategy.OnPush
|
|
325
|
+
'@angular-eslint/prefer-on-push-component-change-detection': 'error',
|
|
326
|
+
|
|
327
|
+
// Always use ViewEncapsulation.None (angular-eslint's use-component-view-encapsulation does the
|
|
328
|
+
// opposite — it disallows None, so we use our own custom rule instead)
|
|
329
|
+
'ethlete/require-view-encapsulation-none': 'error',
|
|
330
|
+
|
|
331
|
+
// Keep Angular @Component / @Directive metadata in a consistent order
|
|
332
|
+
'ethlete/angular-decorator-property-order': 'error',
|
|
333
|
+
|
|
334
|
+
// Prefer shorthand hostDirectives entries and keep extended host directive configs ordered
|
|
335
|
+
'ethlete/prefer-concise-angular-host-directives': 'error',
|
|
336
|
+
|
|
337
|
+
// Prefer concise Angular style metadata when there is only one entry
|
|
338
|
+
'ethlete/prefer-concise-angular-style-metadata': 'error',
|
|
339
|
+
|
|
340
|
+
// No logic in pipe transform — assign to an external utility function instead
|
|
341
|
+
'ethlete/no-pipe-logic': 'error',
|
|
342
|
+
|
|
343
|
+
// Routing components must use paths containing "-view" and class names ending in "ViewComponent"
|
|
344
|
+
'ethlete/enforce-routing-view-naming': 'error',
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Flat config entries for Angular HTML template files.
|
|
350
|
+
* @type {import('eslint').Linter.Config}
|
|
351
|
+
*/
|
|
352
|
+
const recommendedTemplate = {
|
|
353
|
+
files: ['**/*.html'],
|
|
354
|
+
rules: {
|
|
355
|
+
// No $any() in templates
|
|
356
|
+
'@angular-eslint/template/no-any': 'error',
|
|
357
|
+
// Prefer plain attribute over unnecessary property binding for static strings: etIcon="foo" not [etIcon]="'foo'"
|
|
358
|
+
'@angular-eslint/template/prefer-static-string-properties': 'error',
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
module.exports = { recommendedTs, recommendedTemplate };
|
package/src/index.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const noInjectChain = require('./rules/no-inject-chain');
|
|
5
|
+
const noTrivialReturnType = require('./rules/no-trivial-return-type');
|
|
6
|
+
const noSubscribeInPipe = require('./rules/no-subscribe-in-pipe');
|
|
7
|
+
const noRxjsInEffect = require('./rules/no-rxjs-in-effect');
|
|
8
|
+
const noReadonlySignal = require('./rules/no-readonly-signal');
|
|
9
|
+
const noScreamingCaseLocal = require('./rules/no-screaming-case-local');
|
|
10
|
+
const preferRxjsTimer = require('./rules/prefer-rxjs-timer');
|
|
11
|
+
const preferLinkedSignal = require('./rules/prefer-linked-signal');
|
|
12
|
+
const noTrivialWrapperMethod = require('./rules/no-trivial-wrapper-method');
|
|
13
|
+
const noDirectDomManipulation = require('./rules/no-direct-dom-manipulation');
|
|
14
|
+
const noNativeObservers = require('./rules/no-native-observers');
|
|
15
|
+
const preferViewportSize = require('./rules/prefer-viewport-size');
|
|
16
|
+
const preferMatchMedia = require('./rules/prefer-match-media');
|
|
17
|
+
const preferElementDimensions = require('./rules/prefer-element-dimensions');
|
|
18
|
+
const preferScrollState = require('./rules/prefer-scroll-state');
|
|
19
|
+
const noTypeOnlyImport = require('./rules/no-type-only-import');
|
|
20
|
+
const guardReturnNewline = require('./rules/guard-return-newline');
|
|
21
|
+
const noSubscribeWithBody = require('./rules/no-subscribe-with-body');
|
|
22
|
+
const requireDollarSuffix = require('./rules/require-dollar-suffix');
|
|
23
|
+
const noPipeLogic = require('./rules/no-pipe-logic');
|
|
24
|
+
const enforceRoutingViewNaming = require('./rules/enforce-routing-view-naming');
|
|
25
|
+
const requireViewEncapsulationNone = require('./rules/require-view-encapsulation-none');
|
|
26
|
+
const noLegacyAngularDecorators = require('./rules/no-legacy-angular-decorators');
|
|
27
|
+
const noAngularSeoServices = require('./rules/no-angular-seo-services');
|
|
28
|
+
const preferCloneEqual = require('./rules/prefer-clone-equal');
|
|
29
|
+
const noDocumentCookie = require('./rules/no-document-cookie');
|
|
30
|
+
const injectMemberAccessibility = require('./rules/inject-member-accessibility');
|
|
31
|
+
const noPublicProperty = require('./rules/no-public-property');
|
|
32
|
+
const noAngularRouterApi = require('./rules/no-angular-router-api');
|
|
33
|
+
const noWindowLocation = require('./rules/no-window-location');
|
|
34
|
+
const noLocaleId = require('./rules/no-locale-id');
|
|
35
|
+
const noMemberAlias = require('./rules/no-member-alias');
|
|
36
|
+
const noUnusedClassMember = require('./rules/no-unused-class-member');
|
|
37
|
+
const noDomQuery = require('./rules/no-dom-query');
|
|
38
|
+
const angularDecoratorPropertyOrder = require('./rules/angular-decorator-property-order');
|
|
39
|
+
const preferConciseAngularHostDirectives = require('./rules/prefer-concise-angular-host-directives');
|
|
40
|
+
const preferConciseAngularStyleMetadata = require('./rules/prefer-concise-angular-style-metadata');
|
|
41
|
+
const { recommendedTs, recommendedTemplate } = require('./configs/recommended');
|
|
42
|
+
|
|
43
|
+
/** @type {import('eslint').ESLint.Plugin} */
|
|
44
|
+
const plugin = {
|
|
45
|
+
meta: {
|
|
46
|
+
name: '@ethlete/eslint-plugin',
|
|
47
|
+
version: '0.0.1',
|
|
48
|
+
},
|
|
49
|
+
rules: {
|
|
50
|
+
'no-inject-chain': noInjectChain,
|
|
51
|
+
'no-trivial-return-type': noTrivialReturnType,
|
|
52
|
+
'no-subscribe-in-pipe': noSubscribeInPipe,
|
|
53
|
+
'no-rxjs-in-effect': noRxjsInEffect,
|
|
54
|
+
'no-readonly-signal': noReadonlySignal,
|
|
55
|
+
'no-screaming-case-local': noScreamingCaseLocal,
|
|
56
|
+
'prefer-rxjs-timer': preferRxjsTimer,
|
|
57
|
+
'prefer-linked-signal': preferLinkedSignal,
|
|
58
|
+
'no-trivial-wrapper-method': noTrivialWrapperMethod,
|
|
59
|
+
'no-direct-dom-manipulation': noDirectDomManipulation,
|
|
60
|
+
'no-native-observers': noNativeObservers,
|
|
61
|
+
'prefer-viewport-size': preferViewportSize,
|
|
62
|
+
'prefer-match-media': preferMatchMedia,
|
|
63
|
+
'prefer-element-dimensions': preferElementDimensions,
|
|
64
|
+
'prefer-scroll-state': preferScrollState,
|
|
65
|
+
'no-type-only-import': noTypeOnlyImport,
|
|
66
|
+
'guard-return-newline': guardReturnNewline,
|
|
67
|
+
'no-subscribe-with-body': noSubscribeWithBody,
|
|
68
|
+
'require-dollar-suffix': requireDollarSuffix,
|
|
69
|
+
'no-pipe-logic': noPipeLogic,
|
|
70
|
+
'enforce-routing-view-naming': enforceRoutingViewNaming,
|
|
71
|
+
'require-view-encapsulation-none': requireViewEncapsulationNone,
|
|
72
|
+
'no-legacy-angular-decorators': noLegacyAngularDecorators,
|
|
73
|
+
'no-angular-seo-services': noAngularSeoServices,
|
|
74
|
+
'prefer-clone-equal': preferCloneEqual,
|
|
75
|
+
'no-document-cookie': noDocumentCookie,
|
|
76
|
+
'inject-member-accessibility': injectMemberAccessibility,
|
|
77
|
+
'no-public-property': noPublicProperty,
|
|
78
|
+
'no-angular-router-api': noAngularRouterApi,
|
|
79
|
+
'no-window-location': noWindowLocation,
|
|
80
|
+
'no-locale-id': noLocaleId,
|
|
81
|
+
'no-member-alias': noMemberAlias,
|
|
82
|
+
'no-unused-class-member': noUnusedClassMember,
|
|
83
|
+
'no-dom-query': noDomQuery,
|
|
84
|
+
'angular-decorator-property-order': angularDecoratorPropertyOrder,
|
|
85
|
+
'prefer-concise-angular-host-directives': preferConciseAngularHostDirectives,
|
|
86
|
+
'prefer-concise-angular-style-metadata': preferConciseAngularStyleMetadata,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Inject the plugin reference into the configs so consumers don't have to
|
|
91
|
+
/** @type {import('eslint').Linter.Config} */
|
|
92
|
+
const recommendedTsWithPlugin = {
|
|
93
|
+
...recommendedTs,
|
|
94
|
+
plugins: { ethlete: plugin },
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** @type {import('eslint').Linter.Config} */
|
|
98
|
+
const recommendedTemplateWithPlugin = {
|
|
99
|
+
...recommendedTemplate,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const configs = {
|
|
103
|
+
/** TypeScript rules (merged into a files: ['**\/*.ts'] block) */
|
|
104
|
+
recommendedTs: recommendedTsWithPlugin,
|
|
105
|
+
/** Angular template rules (merged into a files: ['**\/*.html'] block) */
|
|
106
|
+
recommendedTemplate: recommendedTemplateWithPlugin,
|
|
107
|
+
/**
|
|
108
|
+
* Both together as a flat array — the most common usage:
|
|
109
|
+
* export default [...baseConfig, ...ethlete.configs.recommended]
|
|
110
|
+
*/
|
|
111
|
+
recommended: [recommendedTsWithPlugin, recommendedTemplateWithPlugin],
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const ethletePlugin = { ...plugin, configs };
|
|
115
|
+
|
|
116
|
+
module.exports = ethletePlugin;
|