@dsivd/prestations-ng 19.2.0-beta.2 → 19.2.0-beta.21
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/ANGULAR_SIGNALS.md +4 -0
- package/CHANGELOG.md +396 -0
- package/CONTRIBUTING.md +74 -4
- package/ESLINT_PLUGIN.md +103 -8
- package/GOOD_PRACTICES.md +731 -380
- package/INTRODUCTION_ANGULAR_SIGNALS.md +199 -154
- package/UPGRADING_V18.md +5 -5
- package/UPGRADING_V19.md +439 -18
- package/eslint/configs/spec-ts-recommended.mjs +34 -0
- package/eslint/configs/template-recommended.mjs +2 -0
- package/eslint/configs/template-rules.mjs +11 -2
- package/eslint/configs/ts-recommended.mjs +6 -0
- package/eslint/configs/ts-rules.mjs +6 -2
- package/eslint/form-reads.mjs +63 -0
- package/eslint/index.mjs +17 -0
- package/eslint/rules/index.mjs +4 -0
- package/eslint/rules/no-direct-signal-mutation.mjs +58 -20
- package/eslint/rules/no-item-track-in-form-list.mjs +99 -0
- package/eslint/rules/no-uninvoked-signal-in-template.mjs +8 -3
- package/eslint/rules/require-model-change.mjs +89 -0
- package/eslint/template-ast.mjs +12 -2
- package/fesm2022/dsivd-prestations-ng.mjs +2766 -2073
- package/fesm2022/dsivd-prestations-ng.mjs.map +1 -1
- package/package.json +1 -2
- package/schematics/migration-collection.json +5 -0
- package/schematics/ng-add/index.js +2 -4
- package/schematics/ng-update/migrations/update-13_2_0/index.js +7 -2
- package/schematics/ng-update/migrations/update-19_2_0/index.js +39 -0
- package/schematics/utility/add-allowed-common-js-dependencies.js +39 -29
- package/schematics/utility/form-signal/class-migration.js +396 -0
- package/schematics/utility/form-signal/edits.js +34 -0
- package/schematics/utility/form-signal/form-signal-migration.js +184 -0
- package/schematics/utility/form-signal/page-classes.js +129 -0
- package/schematics/utility/form-signal/template-migration.js +666 -0
- package/schematics/utility/remove-emit-decorator-metadata.js +8 -9
- package/src/eslint/configs/__tests__/configs.test.mjs +46 -2
- package/src/eslint/configs/spec-ts-recommended.mjs +34 -0
- package/src/eslint/configs/template-recommended.mjs +2 -0
- package/src/eslint/configs/template-rules.mjs +11 -2
- package/src/eslint/configs/ts-recommended.mjs +6 -0
- package/src/eslint/configs/ts-rules.mjs +6 -2
- package/src/eslint/form-reads.mjs +63 -0
- package/src/eslint/index.mjs +17 -0
- package/src/eslint/rules/__tests__/no-direct-signal-mutation.test.mjs +58 -0
- package/src/eslint/rules/__tests__/no-item-track-in-form-list.test.mjs +127 -0
- package/src/eslint/rules/__tests__/no-uninvoked-signal-in-template.test.mjs +6 -0
- package/src/eslint/rules/__tests__/require-model-change.test.mjs +93 -0
- package/src/eslint/rules/index.mjs +4 -0
- package/src/eslint/rules/no-direct-signal-mutation.mjs +58 -20
- package/src/eslint/rules/no-item-track-in-form-list.mjs +99 -0
- package/src/eslint/rules/no-uninvoked-signal-in-template.mjs +8 -3
- package/src/eslint/rules/require-model-change.mjs +89 -0
- package/src/eslint/template-ast.mjs +12 -2
- package/types/dsivd-prestations-ng.d.ts +652 -240
- package/dsivd-prestations-ng-19.2.0-beta.2.tgz +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import noDirectSignalMutation from './no-direct-signal-mutation.mjs';
|
|
2
|
+
import noItemTrackInFormList from './no-item-track-in-form-list.mjs';
|
|
2
3
|
import noUninvokedSignalInTemplate from './no-uninvoked-signal-in-template.mjs';
|
|
4
|
+
import requireModelChange from './require-model-change.mjs';
|
|
3
5
|
|
|
4
6
|
export default {
|
|
5
7
|
'no-direct-signal-mutation': noDirectSignalMutation,
|
|
8
|
+
'no-item-track-in-form-list': noItemTrackInFormList,
|
|
6
9
|
'no-uninvoked-signal-in-template': noUninvokedSignalInTemplate,
|
|
10
|
+
'require-model-change': requireModelChange,
|
|
7
11
|
};
|
|
@@ -9,7 +9,11 @@ import {
|
|
|
9
9
|
WRITABLE,
|
|
10
10
|
} from "../signal-kinds.mjs";
|
|
11
11
|
import { collectSignalKinds } from "../signal-names.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
handlerExpressionOf,
|
|
14
|
+
isComponentReceiver,
|
|
15
|
+
isTwoWayBinding,
|
|
16
|
+
} from "../template-ast.mjs";
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* ESLint rule to detect mutations of the value held by a signal.
|
|
@@ -17,7 +21,8 @@ import { handlerExpressionOf, isComponentReceiver } from "../template-ast.mjs";
|
|
|
17
21
|
* Suggests using .update() or .set() instead.
|
|
18
22
|
*
|
|
19
23
|
* Applies to TypeScript files and to Angular templates, where the mutation is also
|
|
20
|
-
* hidden in every two-way binding on a call result: [(ngModel)]="model().property"
|
|
24
|
+
* hidden in every two-way binding on a call result: [(ngModel)]="model().property", or on
|
|
25
|
+
* a name bound to it: [(model)]="form.property" inside @if (form(); as form).
|
|
21
26
|
*
|
|
22
27
|
* No signal's value is to be mutated, whatever its kind — a mutation notifies none of its
|
|
23
28
|
* dependents. A view query is the single exception: it hands out a DOM element or a
|
|
@@ -106,6 +111,9 @@ const TEMPLATE_MEMBER_READS = new Set([
|
|
|
106
111
|
"SafeKeyedRead",
|
|
107
112
|
]);
|
|
108
113
|
|
|
114
|
+
// Template wrappers that leave the value as is: `form()!`, `(form())`.
|
|
115
|
+
const TEMPLATE_WRAPPERS = new Set(["NonNullAssert", "ParenthesizedExpression"]);
|
|
116
|
+
|
|
109
117
|
// ── TypeScript ───────────────────────────────────────────────────────────────
|
|
110
118
|
|
|
111
119
|
function getCalledName(callee) {
|
|
@@ -140,9 +148,18 @@ function isObjectAssign(callee) {
|
|
|
140
148
|
);
|
|
141
149
|
}
|
|
142
150
|
|
|
151
|
+
// TypeScript wrappers that leave the value as is: `form()!`, `form() as Form`...
|
|
152
|
+
const TYPE_WRAPPERS = new Set([
|
|
153
|
+
"TSNonNullExpression",
|
|
154
|
+
"TSAsExpression",
|
|
155
|
+
"TSSatisfiesExpression",
|
|
156
|
+
"TSTypeAssertion",
|
|
157
|
+
]);
|
|
158
|
+
|
|
143
159
|
/**
|
|
144
160
|
* What a member chain is rooted at, the property and index reads stripped away:
|
|
145
161
|
* - `model().deep.property` => the `model()` call
|
|
162
|
+
* - `model()!.deep.property` => the `model()` call (a type wrapper keeps the value)
|
|
146
163
|
* - `users[0].name` => the `users` name
|
|
147
164
|
*
|
|
148
165
|
* Only reads are walked through. A chain rooted at anything else — `items().filter(f)`,
|
|
@@ -151,8 +168,12 @@ function isObjectAssign(callee) {
|
|
|
151
168
|
*/
|
|
152
169
|
function baseOf(node) {
|
|
153
170
|
let current = node;
|
|
154
|
-
while (
|
|
155
|
-
current
|
|
171
|
+
while (
|
|
172
|
+
current?.type === "MemberExpression" ||
|
|
173
|
+
TYPE_WRAPPERS.has(current?.type)
|
|
174
|
+
) {
|
|
175
|
+
current =
|
|
176
|
+
current.type === "MemberExpression" ? current.object : current.expression;
|
|
156
177
|
}
|
|
157
178
|
return current;
|
|
158
179
|
}
|
|
@@ -241,7 +262,7 @@ function boundNameSignalKind(identifier, scopeContext, seen) {
|
|
|
241
262
|
scopeContext.sourceCode.getScope(identifier),
|
|
242
263
|
identifier.name,
|
|
243
264
|
);
|
|
244
|
-
if (
|
|
265
|
+
if (variable?.defs.length !== 1 || seen.has(variable)) {
|
|
245
266
|
return undefined;
|
|
246
267
|
}
|
|
247
268
|
seen.add(variable);
|
|
@@ -297,18 +318,32 @@ function signalRootTemplateCallKind(node, templateContext) {
|
|
|
297
318
|
: undefined;
|
|
298
319
|
}
|
|
299
320
|
|
|
321
|
+
// The expression itself, a type wrapper stripped away: `form()!` is the `form()` call.
|
|
322
|
+
function unwrapTemplate(node) {
|
|
323
|
+
let current = node;
|
|
324
|
+
while (TEMPLATE_WRAPPERS.has(current?.type)) {
|
|
325
|
+
current = current.expression;
|
|
326
|
+
}
|
|
327
|
+
return current;
|
|
328
|
+
}
|
|
329
|
+
|
|
300
330
|
/**
|
|
301
331
|
* Expression a template name is bound to, `undefined` when the name is a component
|
|
302
332
|
* member. Mutating through such a name mutates whatever the expression yields:
|
|
303
|
-
* `@for (user of model().users)` hands out the elements of the signal's array
|
|
333
|
+
* `@for (user of model().users)` hands out the elements of the signal's array, and
|
|
334
|
+
* `@if (model(); as value)` the value of the signal itself.
|
|
304
335
|
*
|
|
305
|
-
* The item of a `@for`
|
|
306
|
-
*
|
|
307
|
-
* uses.
|
|
336
|
+
* The item of a `@for` and the alias of an `@if` are only bound inside their own block,
|
|
337
|
+
* which the ancestor walk enforces exactly, the nearest one shadowing the others; a `@let`
|
|
338
|
+
* is looked up by name, its declaration always preceding its uses.
|
|
308
339
|
*/
|
|
309
340
|
function boundTemplateExpression(read, templateContext) {
|
|
310
341
|
for (let current = read; current; current = current.parent) {
|
|
311
|
-
if (
|
|
342
|
+
if (
|
|
343
|
+
(current.type === "ForLoopBlock" && current.item?.name === read.name) ||
|
|
344
|
+
(current.type === "IfBlockBranch" &&
|
|
345
|
+
current.expressionAlias?.name === read.name)
|
|
346
|
+
) {
|
|
312
347
|
return current.expression?.ast ?? current.expression;
|
|
313
348
|
}
|
|
314
349
|
}
|
|
@@ -321,19 +356,21 @@ function boundTemplateExpression(read, templateContext) {
|
|
|
321
356
|
* a template name bound to either.
|
|
322
357
|
*/
|
|
323
358
|
function signalTemplateValueKind(node, templateContext, seen = new Set()) {
|
|
324
|
-
|
|
325
|
-
|
|
359
|
+
const value = unwrapTemplate(node);
|
|
360
|
+
if (value?.type === "Call" || value?.type === "SafeCall") {
|
|
361
|
+
return signalRootTemplateCallKind(value, templateContext);
|
|
326
362
|
}
|
|
327
|
-
if (!TEMPLATE_MEMBER_READS.has(
|
|
363
|
+
if (!TEMPLATE_MEMBER_READS.has(value?.type)) {
|
|
328
364
|
return undefined;
|
|
329
365
|
}
|
|
330
366
|
|
|
331
|
-
// Property and index reads are walked through
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
367
|
+
// Property and index reads are walked through, as are the type wrappers; anything else
|
|
368
|
+
// roots a value of its own.
|
|
369
|
+
let base = value;
|
|
370
|
+
while (TEMPLATE_MEMBER_READS.has(unwrapTemplate(base.receiver)?.type)) {
|
|
371
|
+
base = unwrapTemplate(base.receiver);
|
|
335
372
|
}
|
|
336
|
-
const receiver = base.receiver;
|
|
373
|
+
const receiver = unwrapTemplate(base.receiver);
|
|
337
374
|
|
|
338
375
|
if (receiver?.type === "Call" || receiver?.type === "SafeCall") {
|
|
339
376
|
return signalRootTemplateCallKind(receiver, templateContext);
|
|
@@ -492,8 +529,9 @@ export default {
|
|
|
492
529
|
|
|
493
530
|
BoundEvent(node) {
|
|
494
531
|
// `[(x)]="model().property"` makes Angular assign into the value of the signal.
|
|
495
|
-
// Reporting on the BoundEvent handler reports the binding exactly once.
|
|
496
|
-
|
|
532
|
+
// Reporting on the BoundEvent handler reports the binding exactly once. An
|
|
533
|
+
// explicit `(xChange)="…"` handler is a statement, checked as any other.
|
|
534
|
+
if (!isTwoWayBinding(node)) {
|
|
497
535
|
return;
|
|
498
536
|
}
|
|
499
537
|
const handler = handlerExpressionOf(node);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { isComponentReceiver } from "../template-ast.mjs";
|
|
2
|
+
import { astOf, readsForm, resolveRoot } from "../form-reads.mjs";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ESLint rule: a `@for` over a list of the form of the page whose rows edit their
|
|
6
|
+
* item must not track the rows by the item itself (`track child`).
|
|
7
|
+
*
|
|
8
|
+
* The form is never modified in place: writing a field of an item (`patchForm()`,
|
|
9
|
+
* `patchItem()`) replaces the item with a copy. A row tracked by its item is then destroyed and
|
|
10
|
+
* created again at every input, and the field being edited loses the focus. Track the rows by
|
|
11
|
+
* `$index`, or by an identifier of the item (`track child.id`), which the copy keeps.
|
|
12
|
+
*
|
|
13
|
+
* A row edits its item when one of its elements has a `model` read from it
|
|
14
|
+
* (`[model]="child.firstName"`, `[(model)]="child"`). A list only displayed is left alone.
|
|
15
|
+
* `$any(child)` counts as `child`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Whether the track expression of a `@for` is its item itself.
|
|
20
|
+
*/
|
|
21
|
+
function tracksItemItself(forBlock) {
|
|
22
|
+
let track = astOf(forBlock.trackBy);
|
|
23
|
+
if (
|
|
24
|
+
track?.type === "Call" &&
|
|
25
|
+
track.receiver?.name === "$any" &&
|
|
26
|
+
track.args?.length === 1
|
|
27
|
+
) {
|
|
28
|
+
track = track.args[0];
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
track?.type === "PropertyRead" &&
|
|
32
|
+
isComponentReceiver(track.receiver) &&
|
|
33
|
+
track.name === forBlock.item?.name
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
meta: {
|
|
39
|
+
type: "problem",
|
|
40
|
+
docs: {
|
|
41
|
+
description:
|
|
42
|
+
"Disallow tracking by the item itself the rows of a @for editing a list of the form",
|
|
43
|
+
category: "Possible Errors",
|
|
44
|
+
recommended: true,
|
|
45
|
+
},
|
|
46
|
+
hasSuggestions: true,
|
|
47
|
+
schema: [],
|
|
48
|
+
messages: {
|
|
49
|
+
itemTrack:
|
|
50
|
+
"The rows of this list of the form are tracked by their item ('track {{item}}'): writing a field replaces the item, so its row is created again and the field being edited loses the focus. Track the rows by $index or by an identifier of the item.",
|
|
51
|
+
trackByIndex: "Track the rows by $index",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
create(context) {
|
|
56
|
+
const candidates = [];
|
|
57
|
+
const editingBlocks = new Set();
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
ForLoopBlock(node) {
|
|
61
|
+
if (
|
|
62
|
+
tracksItemItself(node) &&
|
|
63
|
+
readsForm(astOf(node.expression), node.parent)
|
|
64
|
+
) {
|
|
65
|
+
candidates.push(node);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
Element(node) {
|
|
69
|
+
const model = node.inputs?.find((input) => input.name === "model");
|
|
70
|
+
const root = model && resolveRoot(astOf(model.value), node);
|
|
71
|
+
if (root?.forBlock) {
|
|
72
|
+
editingBlocks.add(root.forBlock);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"Program:exit"() {
|
|
76
|
+
for (const forBlock of candidates) {
|
|
77
|
+
if (!editingBlocks.has(forBlock)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const { start, end } = astOf(forBlock.trackBy).sourceSpan;
|
|
81
|
+
context.report({
|
|
82
|
+
messageId: "itemTrack",
|
|
83
|
+
data: { item: forBlock.item.name },
|
|
84
|
+
loc: {
|
|
85
|
+
start: context.sourceCode.getLocFromIndex(start),
|
|
86
|
+
end: context.sourceCode.getLocFromIndex(end),
|
|
87
|
+
},
|
|
88
|
+
suggest: [
|
|
89
|
+
{
|
|
90
|
+
messageId: "trackByIndex",
|
|
91
|
+
fix: (fixer) => fixer.replaceTextRange([start, end], "$index"),
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { resolveComponentPath } from "../component-path.mjs";
|
|
2
2
|
import { collectSignalNames } from "../signal-names.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
handlerExpressionOf,
|
|
5
|
+
isComponentReceiver,
|
|
6
|
+
isTwoWayBinding,
|
|
7
|
+
} from "../template-ast.mjs";
|
|
4
8
|
|
|
5
9
|
/**
|
|
6
10
|
* ESLint rule to detect signals referenced without being called in a template.
|
|
@@ -98,8 +102,9 @@ export default {
|
|
|
98
102
|
BoundEvent(node) {
|
|
99
103
|
// `[(x)]="expr"` generates a BoundEvent `xChange` whose handler IS the written
|
|
100
104
|
// target. Its span is the one of the twin BoundAttribute expression: marking
|
|
101
|
-
// the span neutralizes both copies at once.
|
|
102
|
-
|
|
105
|
+
// the span neutralizes both copies at once. An explicit `(xChange)="…"` handler
|
|
106
|
+
// is a statement, checked as any other.
|
|
107
|
+
if (isTwoWayBinding(node)) {
|
|
103
108
|
markHandled(handlerExpressionOf(node));
|
|
104
109
|
}
|
|
105
110
|
},
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { astOf, readsForm } from "../form-reads.mjs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ESLint rule: a `foehn-*` component given a field of the form of the page with a
|
|
5
|
+
* one-way `[model]` must also listen to `(modelChange)`. Without it, what the user enters never
|
|
6
|
+
* reaches the form: the component changes its own model only. With the form held by a signal,
|
|
7
|
+
* bind `[model]="form.firstName" (modelChange)="patchForm(['firstName'], $event)"`.
|
|
8
|
+
*
|
|
9
|
+
* Only the models read from the form are checked (`form()`, `form.x`, and the names bound to
|
|
10
|
+
* it by `@if (form(); as form)`, `@let form = this.form()` or `@for (child of form.children)`):
|
|
11
|
+
* a one-way `[model]` is legitimate elsewhere (a table displaying a list, a menu...).
|
|
12
|
+
* `[(model)]` declares both bindings and is never reported.
|
|
13
|
+
*
|
|
14
|
+
* Not reported either, as the input of the user can't be lost: a component always disabled
|
|
15
|
+
* (`disabled="true"`, `[disabled]="true"`), the components which never write their model, and a
|
|
16
|
+
* component listening to `(userInput)`, whose handler writes the form.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Components which never write their model: they only display it. */
|
|
20
|
+
const READ_ONLY_COMPONENTS = new Set(["foehn-input-hidden", "foehn-table"]);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Whether the component is always disabled: a disabled component doesn't write its model, unless
|
|
24
|
+
* it is given `updateModelWhenDisabled`. A bare `disabled` gives `''`, which doesn't disable it.
|
|
25
|
+
*/
|
|
26
|
+
function isAlwaysDisabled(node) {
|
|
27
|
+
const named = (name) => (binding) => binding.name === name;
|
|
28
|
+
const bindings = [...(node.attributes ?? []), ...(node.inputs ?? [])];
|
|
29
|
+
if (bindings.some(named("updateModelWhenDisabled"))) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const disabled = astOf(node.inputs?.find(named("disabled"))?.value);
|
|
33
|
+
return (
|
|
34
|
+
node.attributes?.find(named("disabled"))?.value === "true" ||
|
|
35
|
+
(disabled?.type === "LiteralPrimitive" && disabled.value === true)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
meta: {
|
|
41
|
+
type: "problem",
|
|
42
|
+
docs: {
|
|
43
|
+
description:
|
|
44
|
+
"Require (modelChange) next to a one-way [model] reading the form of the page",
|
|
45
|
+
category: "Possible Errors",
|
|
46
|
+
recommended: true,
|
|
47
|
+
},
|
|
48
|
+
schema: [],
|
|
49
|
+
messages: {
|
|
50
|
+
missing:
|
|
51
|
+
"'{{element}}' gets a field of the form with a one-way [model] without (modelChange): what the user enters never reaches the form. Add (modelChange), e.g. (modelChange)=\"patchForm([...], $event)\".",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
create(context) {
|
|
56
|
+
const offset = (location) =>
|
|
57
|
+
typeof location === "number" ? location : location.offset;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
Element(node) {
|
|
61
|
+
if (!node.name?.startsWith("foehn-")) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const model = node.inputs?.find((input) => input.name === "model");
|
|
65
|
+
if (
|
|
66
|
+
!model ||
|
|
67
|
+
READ_ONLY_COMPONENTS.has(node.name) ||
|
|
68
|
+
node.outputs?.some(
|
|
69
|
+
(output) =>
|
|
70
|
+
output.name === "modelChange" || output.name === "userInput",
|
|
71
|
+
) ||
|
|
72
|
+
isAlwaysDisabled(node) ||
|
|
73
|
+
!readsForm(astOf(model.value), node)
|
|
74
|
+
) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const span = model.sourceSpan;
|
|
78
|
+
context.report({
|
|
79
|
+
messageId: "missing",
|
|
80
|
+
data: { element: node.name },
|
|
81
|
+
loc: {
|
|
82
|
+
start: context.sourceCode.getLocFromIndex(offset(span.start)),
|
|
83
|
+
end: context.sourceCode.getLocFromIndex(offset(span.end)),
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Three subtleties of the Angular template AST that every template rule runs into.
|
|
3
|
+
* All are easy to get wrong, hence the shared names.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Whether a `BoundEvent` is the one generated by a two-way binding `[(x)]="expr"`, whose
|
|
8
|
+
* handler is the target Angular writes into, not a statement.
|
|
9
|
+
*
|
|
10
|
+
* Its name alone can't tell: an explicit `(xChange)="refresh()"` has the same name. The
|
|
11
|
+
* key can: `x` for the two-way binding, `xChange` for the explicit handler.
|
|
12
|
+
*/
|
|
13
|
+
export const isTwoWayBinding = (boundEvent) =>
|
|
14
|
+
boundEvent.name === `${boundEvent.keySpan?.details}Change`;
|
|
15
|
+
|
|
6
16
|
/**
|
|
7
17
|
* The expression carried by a `BoundEvent` handler.
|
|
8
18
|
*
|