@angular-eslint/utils 17.3.1-alpha.2 → 17.3.1-alpha.4
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/dist/convert-annotated-source-to-failure-case.js +3 -4
- package/dist/eslint-plugin/ast-utils.js +17 -13
- package/dist/eslint-plugin/get-aria-attribute-keys.js +50 -49
- package/dist/eslint-plugin/get-native-event-names.js +175 -174
- package/dist/eslint-plugin/rule-fixes.js +2 -3
- package/dist/eslint-plugin-template/parser-services.js +4 -3
- package/dist/rules-tester.js +13 -9
- package/package.json +2 -2
|
@@ -21,9 +21,8 @@ exports.SPECIAL_UNDERLINE_CHARS = [
|
|
|
21
21
|
'@',
|
|
22
22
|
];
|
|
23
23
|
function convertAnnotatedSourceToFailureCase(errorOptions) {
|
|
24
|
-
var _a, _b;
|
|
25
24
|
const messages = 'messageId' in errorOptions
|
|
26
|
-
? [
|
|
25
|
+
? [{ ...errorOptions, char: '~' }]
|
|
27
26
|
: errorOptions.messages;
|
|
28
27
|
let parsedSource = '';
|
|
29
28
|
const errors = messages.map(({ char: currentValueChar, data, messageId, suggestions }) => {
|
|
@@ -50,9 +49,9 @@ function convertAnnotatedSourceToFailureCase(errorOptions) {
|
|
|
50
49
|
name: errorOptions.description,
|
|
51
50
|
code: parsedSource,
|
|
52
51
|
filename: errorOptions.filename,
|
|
53
|
-
options:
|
|
52
|
+
options: errorOptions.options ?? [],
|
|
54
53
|
errors,
|
|
55
|
-
only:
|
|
54
|
+
only: errorOptions.only ?? false,
|
|
56
55
|
output: errorOptions.annotatedOutput
|
|
57
56
|
? parseInvalidSource(errorOptions.annotatedOutput).source
|
|
58
57
|
: null,
|
|
@@ -35,7 +35,11 @@ var AngularPropertyAccessorDecorators;
|
|
|
35
35
|
AngularPropertyAccessorDecorators["ViewChild"] = "ViewChild";
|
|
36
36
|
AngularPropertyAccessorDecorators["ViewChildren"] = "ViewChildren";
|
|
37
37
|
})(AngularPropertyAccessorDecorators || (AngularPropertyAccessorDecorators = {}));
|
|
38
|
-
exports.AngularInnerClassDecorators =
|
|
38
|
+
exports.AngularInnerClassDecorators = {
|
|
39
|
+
...AngularConstructorParameterDecorators,
|
|
40
|
+
...AngularMethodDecorators,
|
|
41
|
+
...AngularPropertyAccessorDecorators,
|
|
42
|
+
};
|
|
39
43
|
var AngularLifecycleInterfaces;
|
|
40
44
|
(function (AngularLifecycleInterfaces) {
|
|
41
45
|
AngularLifecycleInterfaces["AfterContentChecked"] = "AfterContentChecked";
|
|
@@ -210,8 +214,7 @@ exports.getInterfaceName = getInterfaceName;
|
|
|
210
214
|
const getPipeDecorator = (node) => (0, exports.getDecorator)(node, 'Pipe');
|
|
211
215
|
exports.getPipeDecorator = getPipeDecorator;
|
|
212
216
|
function getInterfaces(node) {
|
|
213
|
-
|
|
214
|
-
return ((_a = node.implements) !== null && _a !== void 0 ? _a : [])
|
|
217
|
+
return (node.implements ?? [])
|
|
215
218
|
.map(({ expression }) => expression)
|
|
216
219
|
.filter(isIdentifierOrMemberExpression);
|
|
217
220
|
}
|
|
@@ -238,9 +241,8 @@ function getNearestNodeFrom({ parent }, predicate) {
|
|
|
238
241
|
}
|
|
239
242
|
exports.getNearestNodeFrom = getNearestNodeFrom;
|
|
240
243
|
const getClassName = (node) => {
|
|
241
|
-
var _a;
|
|
242
244
|
if (isClassDeclaration(node)) {
|
|
243
|
-
return
|
|
245
|
+
return node.id?.name;
|
|
244
246
|
}
|
|
245
247
|
if (node.parent) {
|
|
246
248
|
return (0, exports.getClassName)(node.parent);
|
|
@@ -249,12 +251,14 @@ const getClassName = (node) => {
|
|
|
249
251
|
};
|
|
250
252
|
exports.getClassName = getClassName;
|
|
251
253
|
const getDecorator = (node, decoratorName) => {
|
|
252
|
-
|
|
253
|
-
return (_a = node.decorators) === null || _a === void 0 ? void 0 : _a.find((decorator) => (0, exports.getDecoratorName)(decorator) === decoratorName);
|
|
254
|
+
return node.decorators?.find((decorator) => (0, exports.getDecoratorName)(decorator) === decoratorName);
|
|
254
255
|
};
|
|
255
256
|
exports.getDecorator = getDecorator;
|
|
256
257
|
const getAngularClassDecorator = ({ decorators, }) => {
|
|
257
|
-
return decorators
|
|
258
|
+
return decorators
|
|
259
|
+
?.map(exports.getDecoratorName)
|
|
260
|
+
.filter(utils_2.isNotNullOrUndefined)
|
|
261
|
+
.find(exports.isAngularClassDecorator);
|
|
258
262
|
};
|
|
259
263
|
exports.getAngularClassDecorator = getAngularClassDecorator;
|
|
260
264
|
const getDecoratorArgument = ({ expression, }) => {
|
|
@@ -306,13 +310,13 @@ function getPropertyDefinitionName({ computed, key, }) {
|
|
|
306
310
|
}
|
|
307
311
|
exports.getPropertyDefinitionName = getPropertyDefinitionName;
|
|
308
312
|
const getDecoratorProperty = (decorator, name) => {
|
|
309
|
-
|
|
310
|
-
|
|
313
|
+
return (0, exports.getDecoratorArgument)(decorator)
|
|
314
|
+
?.properties.filter(isProperty)
|
|
315
|
+
.find(({ key }) => utils_1.ASTUtils.isIdentifier(key) && key.name === name);
|
|
311
316
|
};
|
|
312
317
|
exports.getDecoratorProperty = getDecoratorProperty;
|
|
313
318
|
const getDecoratorPropertyValue = (decorator, name) => {
|
|
314
|
-
|
|
315
|
-
return (_a = (0, exports.getDecoratorProperty)(decorator, name)) === null || _a === void 0 ? void 0 : _a.value;
|
|
319
|
+
return (0, exports.getDecoratorProperty)(decorator, name)?.value;
|
|
316
320
|
};
|
|
317
321
|
exports.getDecoratorPropertyValue = getDecoratorPropertyValue;
|
|
318
322
|
const getDeclaredMethods = ({ body: { body }, }) => {
|
|
@@ -330,7 +334,7 @@ const getLifecycleInterfaceByMethodName = (methodName) => methodName.slice(2);
|
|
|
330
334
|
exports.getLifecycleInterfaceByMethodName = getLifecycleInterfaceByMethodName;
|
|
331
335
|
function isImportedFrom(identifier, moduleName) {
|
|
332
336
|
const importDeclarations = getImportDeclarations(identifier, moduleName);
|
|
333
|
-
return Boolean(importDeclarations
|
|
337
|
+
return Boolean(importDeclarations?.some((importDeclaration) => importDeclaration.specifiers.some((specifier) => isImportSpecifier(specifier) &&
|
|
334
338
|
specifier.imported.name === identifier.name &&
|
|
335
339
|
specifier.local.name === identifier.name)));
|
|
336
340
|
}
|
|
@@ -3,54 +3,55 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAriaAttributeKeys = void 0;
|
|
4
4
|
let ariaAttributeKeys = null;
|
|
5
5
|
function getAriaAttributeKeys() {
|
|
6
|
-
return (ariaAttributeKeys
|
|
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
|
-
|
|
6
|
+
return (ariaAttributeKeys ??
|
|
7
|
+
(ariaAttributeKeys = new Set([
|
|
8
|
+
// Source: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques
|
|
9
|
+
'aria-activedescendant',
|
|
10
|
+
'aria-atomic',
|
|
11
|
+
'aria-autocomplete',
|
|
12
|
+
'aria-busy',
|
|
13
|
+
'aria-checked',
|
|
14
|
+
'aria-colcount',
|
|
15
|
+
'aria-colindex',
|
|
16
|
+
'aria-colspan',
|
|
17
|
+
'aria-controls',
|
|
18
|
+
'aria-current',
|
|
19
|
+
'aria-describedby',
|
|
20
|
+
'aria-details',
|
|
21
|
+
'aria-disabled',
|
|
22
|
+
'aria-dragged',
|
|
23
|
+
'aria-dropeffect',
|
|
24
|
+
'aria-errormessage',
|
|
25
|
+
'aria-expanded',
|
|
26
|
+
'aria-flowto',
|
|
27
|
+
'aria-haspopup',
|
|
28
|
+
'aria-hidden',
|
|
29
|
+
'aria-invalid',
|
|
30
|
+
'aria-label',
|
|
31
|
+
'aria-labelledby',
|
|
32
|
+
'aria-level',
|
|
33
|
+
'aria-live',
|
|
34
|
+
'aria-modal',
|
|
35
|
+
'aria-multiline',
|
|
36
|
+
'aria-multiselectable',
|
|
37
|
+
'aria-orientation',
|
|
38
|
+
'aria-owns',
|
|
39
|
+
'aria-placeholder',
|
|
40
|
+
'aria-posinset',
|
|
41
|
+
'aria-pressed',
|
|
42
|
+
'aria-readonly',
|
|
43
|
+
'aria-relevant',
|
|
44
|
+
'aria-required',
|
|
45
|
+
'aria-rowcount',
|
|
46
|
+
'aria-rowindex',
|
|
47
|
+
'aria-rowspan',
|
|
48
|
+
'aria-selected',
|
|
49
|
+
'aria-setsize',
|
|
50
|
+
'aria-sort',
|
|
51
|
+
'aria-valuemax',
|
|
52
|
+
'aria-valuemin',
|
|
53
|
+
'aria-valuenow',
|
|
54
|
+
'aria-valuetext',
|
|
55
|
+
])));
|
|
55
56
|
}
|
|
56
57
|
exports.getAriaAttributeKeys = getAriaAttributeKeys;
|
|
@@ -3,179 +3,180 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getNativeEventNames = void 0;
|
|
4
4
|
let nativeEventNames = null;
|
|
5
5
|
function getNativeEventNames() {
|
|
6
|
-
return (nativeEventNames
|
|
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
|
-
|
|
6
|
+
return (nativeEventNames ??
|
|
7
|
+
(nativeEventNames = new Set([
|
|
8
|
+
// Source: https://developer.mozilla.org/en-US/docs/Web/Events
|
|
9
|
+
'abort',
|
|
10
|
+
'afterprint',
|
|
11
|
+
'animationend',
|
|
12
|
+
'animationiteration',
|
|
13
|
+
'animationstart',
|
|
14
|
+
'appinstalled',
|
|
15
|
+
'audioprocess',
|
|
16
|
+
'audioend',
|
|
17
|
+
'audiostart',
|
|
18
|
+
'beforeprint',
|
|
19
|
+
'beforeunload',
|
|
20
|
+
'beginEvent',
|
|
21
|
+
'blocked',
|
|
22
|
+
'blur',
|
|
23
|
+
'boundary',
|
|
24
|
+
'cached',
|
|
25
|
+
'canplay',
|
|
26
|
+
'canplaythrough',
|
|
27
|
+
'change',
|
|
28
|
+
'chargingchange',
|
|
29
|
+
'chargingtimechange',
|
|
30
|
+
'checking',
|
|
31
|
+
'click',
|
|
32
|
+
'close',
|
|
33
|
+
'complete',
|
|
34
|
+
'compositionend',
|
|
35
|
+
'compositionstart',
|
|
36
|
+
'compositionupdate',
|
|
37
|
+
'contextmenu',
|
|
38
|
+
'copy',
|
|
39
|
+
'cut',
|
|
40
|
+
'dblclick',
|
|
41
|
+
'devicechange',
|
|
42
|
+
'devicelight',
|
|
43
|
+
'devicemotion',
|
|
44
|
+
'deviceorientation',
|
|
45
|
+
'deviceproximity',
|
|
46
|
+
'dischargingtimechange',
|
|
47
|
+
'DOMAttributeNameChanged',
|
|
48
|
+
'DOMAttrModified',
|
|
49
|
+
'DOMCharacterDataModified',
|
|
50
|
+
'DOMContentLoaded',
|
|
51
|
+
'DOMElementNameChanged',
|
|
52
|
+
'focus',
|
|
53
|
+
'focusin',
|
|
54
|
+
'focusout',
|
|
55
|
+
'DOMNodeInserted',
|
|
56
|
+
'DOMNodeInsertedIntoDocument',
|
|
57
|
+
'DOMNodeRemoved',
|
|
58
|
+
'DOMNodeRemovedFromDocument',
|
|
59
|
+
'DOMSubtreeModified',
|
|
60
|
+
'downloading',
|
|
61
|
+
'drag',
|
|
62
|
+
'dragend',
|
|
63
|
+
'dragenter',
|
|
64
|
+
'dragleave',
|
|
65
|
+
'dragover',
|
|
66
|
+
'dragstart',
|
|
67
|
+
'drop',
|
|
68
|
+
'durationchange',
|
|
69
|
+
'emptied',
|
|
70
|
+
'end',
|
|
71
|
+
'ended',
|
|
72
|
+
'endEvent',
|
|
73
|
+
'error',
|
|
74
|
+
'fullscreenchange',
|
|
75
|
+
'fullscreenerror',
|
|
76
|
+
'gamepadconnected',
|
|
77
|
+
'gamepaddisconnected',
|
|
78
|
+
'gotpointercapture',
|
|
79
|
+
'hashchange',
|
|
80
|
+
'lostpointercapture',
|
|
81
|
+
'input',
|
|
82
|
+
'invalid',
|
|
83
|
+
'keydown',
|
|
84
|
+
'keypress',
|
|
85
|
+
'keyup',
|
|
86
|
+
'languagechange',
|
|
87
|
+
'levelchange',
|
|
88
|
+
'load',
|
|
89
|
+
'loadeddata',
|
|
90
|
+
'loadedmetadata',
|
|
91
|
+
'loadend',
|
|
92
|
+
'loadstart',
|
|
93
|
+
'mark',
|
|
94
|
+
'message',
|
|
95
|
+
'messageerror',
|
|
96
|
+
'mousedown',
|
|
97
|
+
'mouseenter',
|
|
98
|
+
'mouseleave',
|
|
99
|
+
'mousemove',
|
|
100
|
+
'mouseout',
|
|
101
|
+
'mouseover',
|
|
102
|
+
'mouseup',
|
|
103
|
+
'nomatch',
|
|
104
|
+
'notificationclick',
|
|
105
|
+
'noupdate',
|
|
106
|
+
'obsolete',
|
|
107
|
+
'offline',
|
|
108
|
+
'online',
|
|
109
|
+
'open',
|
|
110
|
+
'orientationchange',
|
|
111
|
+
'pagehide',
|
|
112
|
+
'pageshow',
|
|
113
|
+
'paste',
|
|
114
|
+
'pause',
|
|
115
|
+
'pointercancel',
|
|
116
|
+
'pointerdown',
|
|
117
|
+
'pointerenter',
|
|
118
|
+
'pointerleave',
|
|
119
|
+
'pointerlockchange',
|
|
120
|
+
'pointerlockerror',
|
|
121
|
+
'pointermove',
|
|
122
|
+
'pointerout',
|
|
123
|
+
'pointerover',
|
|
124
|
+
'pointerup',
|
|
125
|
+
'play',
|
|
126
|
+
'playing',
|
|
127
|
+
'popstate',
|
|
128
|
+
'progress',
|
|
129
|
+
'push',
|
|
130
|
+
'pushsubscriptionchange',
|
|
131
|
+
'ratechange',
|
|
132
|
+
'readystatechange',
|
|
133
|
+
'repeatEvent',
|
|
134
|
+
'reset',
|
|
135
|
+
'resize',
|
|
136
|
+
'resourcetimingbufferfull',
|
|
137
|
+
'result',
|
|
138
|
+
'resume',
|
|
139
|
+
'scroll',
|
|
140
|
+
'seeked',
|
|
141
|
+
'seeking',
|
|
142
|
+
'select',
|
|
143
|
+
'selectstart',
|
|
144
|
+
'selectionchange',
|
|
145
|
+
'show',
|
|
146
|
+
'soundend',
|
|
147
|
+
'soundstart',
|
|
148
|
+
'speechend',
|
|
149
|
+
'speechstart',
|
|
150
|
+
'stalled',
|
|
151
|
+
'start',
|
|
152
|
+
'storage',
|
|
153
|
+
'submit',
|
|
154
|
+
'success',
|
|
155
|
+
'suspend',
|
|
156
|
+
'SVGAbort',
|
|
157
|
+
'SVGError',
|
|
158
|
+
'SVGLoad',
|
|
159
|
+
'SVGResize',
|
|
160
|
+
'SVGScroll',
|
|
161
|
+
'SVGUnload',
|
|
162
|
+
'SVGZoom',
|
|
163
|
+
'timeout',
|
|
164
|
+
'timeupdate',
|
|
165
|
+
'touchcancel',
|
|
166
|
+
'touchend',
|
|
167
|
+
'touchmove',
|
|
168
|
+
'touchstart',
|
|
169
|
+
'transitionend',
|
|
170
|
+
'unload',
|
|
171
|
+
'updateready',
|
|
172
|
+
'upgradeneeded',
|
|
173
|
+
'userproximity',
|
|
174
|
+
'voiceschanged',
|
|
175
|
+
'versionchange',
|
|
176
|
+
'visibilitychange',
|
|
177
|
+
'volumechange',
|
|
178
|
+
'waiting',
|
|
179
|
+
'wheel',
|
|
180
|
+
])));
|
|
180
181
|
}
|
|
181
182
|
exports.getNativeEventNames = getNativeEventNames;
|
|
@@ -7,7 +7,7 @@ const utils_2 = require("../utils");
|
|
|
7
7
|
function getImportAddFix({ compatibleWithTypeOnlyImport = false, fixer, importName, moduleName, node, }) {
|
|
8
8
|
const fullImport = `import { ${importName} } from '${moduleName}';\n`;
|
|
9
9
|
const importDeclarations = (0, ast_utils_1.getImportDeclarations)(node, moduleName);
|
|
10
|
-
if (!
|
|
10
|
+
if (!importDeclarations?.length) {
|
|
11
11
|
return fixer.insertTextAfterRange([0, 0], fullImport);
|
|
12
12
|
}
|
|
13
13
|
const importDeclarationSpecifier = (0, ast_utils_1.getImportDeclarationSpecifier)(importDeclarations, importName);
|
|
@@ -25,8 +25,7 @@ function getImportAddFix({ compatibleWithTypeOnlyImport = false, fixer, importNa
|
|
|
25
25
|
}
|
|
26
26
|
exports.getImportAddFix = getImportAddFix;
|
|
27
27
|
function getImportRemoveFix(sourceCode, importDeclarations, importName, fixer) {
|
|
28
|
-
|
|
29
|
-
const { importDeclaration, importSpecifier } = (_a = (0, ast_utils_1.getImportDeclarationSpecifier)(importDeclarations, importName)) !== null && _a !== void 0 ? _a : {};
|
|
28
|
+
const { importDeclaration, importSpecifier } = (0, ast_utils_1.getImportDeclarationSpecifier)(importDeclarations, importName) ?? {};
|
|
30
29
|
if (!importDeclaration || !importSpecifier)
|
|
31
30
|
return undefined;
|
|
32
31
|
const isFirstImportSpecifier = importDeclaration.specifiers[0] === importSpecifier;
|
|
@@ -11,9 +11,10 @@ exports.getTemplateParserServices = getTemplateParserServices;
|
|
|
11
11
|
* If @angular-eslint/template-parser is not the configured parser when the function is invoked it will throw
|
|
12
12
|
*/
|
|
13
13
|
function ensureTemplateParser(context) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
!
|
|
14
|
+
if (!context.parserServices
|
|
15
|
+
?.convertNodeSourceSpanToLoc ||
|
|
16
|
+
!context.parserServices
|
|
17
|
+
?.convertElementSourceSpanToLoc) {
|
|
17
18
|
/**
|
|
18
19
|
* The user needs to have configured "parser" in their eslint config and set it
|
|
19
20
|
* to @angular-eslint/template-parser
|
package/dist/rules-tester.js
CHANGED
|
@@ -37,14 +37,17 @@ function isValidParser(parser) {
|
|
|
37
37
|
return VALID_PARSERS.includes(parser);
|
|
38
38
|
}
|
|
39
39
|
class RuleTester extends utils_1.TSESLint.RuleTester {
|
|
40
|
+
filename;
|
|
40
41
|
// as of eslint 6 you have to provide an absolute path to the parser
|
|
41
42
|
// but that's not as clean to type, this saves us trying to manually enforce
|
|
42
43
|
// that contributors require.resolve everything
|
|
43
44
|
constructor(options) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
super({
|
|
46
|
+
...options,
|
|
47
|
+
parser: require.resolve(options.parser),
|
|
48
|
+
});
|
|
49
|
+
if (options.parserOptions?.project) {
|
|
50
|
+
this.filename = path.join(options.parserOptions?.tsconfigRootDir ?? getFixturesRootDir(), 'file.ts');
|
|
48
51
|
}
|
|
49
52
|
// make sure that the parser doesn't hold onto file handles between tests
|
|
50
53
|
// on linux (i.e. our CI env), there can be very a limited number of watch handles available
|
|
@@ -55,7 +58,7 @@ class RuleTester extends utils_1.TSESLint.RuleTester {
|
|
|
55
58
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
56
59
|
require(options.parser).clearCaches();
|
|
57
60
|
}
|
|
58
|
-
catch
|
|
61
|
+
catch {
|
|
59
62
|
// ignored
|
|
60
63
|
}
|
|
61
64
|
});
|
|
@@ -67,20 +70,21 @@ class RuleTester extends utils_1.TSESLint.RuleTester {
|
|
|
67
70
|
const errorMessage = `Do not set the parser at the test level unless you want to use a parser other than ${VALID_PARSERS.join(', ')}`;
|
|
68
71
|
const parsedTests = {
|
|
69
72
|
valid: valid.map((test) => {
|
|
70
|
-
var _a;
|
|
71
73
|
if (typeof test !== 'string' && isValidParser(test.parser)) {
|
|
72
74
|
throw Error(errorMessage);
|
|
73
75
|
}
|
|
74
76
|
return typeof test === 'string'
|
|
75
77
|
? { code: test, filename: this.filename }
|
|
76
|
-
:
|
|
78
|
+
: { ...test, filename: test.filename ?? this.filename };
|
|
77
79
|
}),
|
|
78
80
|
invalid: invalid.map((test) => {
|
|
79
|
-
var _a;
|
|
80
81
|
if (isValidParser(test.parser)) {
|
|
81
82
|
throw Error(errorMessage);
|
|
82
83
|
}
|
|
83
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
...test,
|
|
86
|
+
filename: test.filename ?? this.filename,
|
|
87
|
+
};
|
|
84
88
|
}),
|
|
85
89
|
};
|
|
86
90
|
super.run(name, rule, parsedTests);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/utils",
|
|
3
|
-
"version": "17.3.1-alpha.
|
|
3
|
+
"version": "17.3.1-alpha.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"typescript": "*"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@angular-eslint/bundled-angular-compiler": "17.3.1-alpha.
|
|
23
|
+
"@angular-eslint/bundled-angular-compiler": "17.3.1-alpha.4",
|
|
24
24
|
"@typescript-eslint/utils": "7.2.0"
|
|
25
25
|
},
|
|
26
26
|
"gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
|