@microsoft/fast-html 1.0.0-alpha.1 → 1.0.0-alpha.11

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.
Files changed (69) hide show
  1. package/README.md +100 -7
  2. package/dist/dts/components/index.d.ts +1 -0
  3. package/dist/dts/components/template.d.ts +74 -0
  4. package/dist/dts/components/utilities.d.ts +125 -0
  5. package/dist/dts/components/utilities.spec.d.ts +1 -0
  6. package/dist/dts/debug.d.ts +3 -0
  7. package/dist/dts/fixtures/attribute/attribute.spec.d.ts +1 -0
  8. package/dist/dts/fixtures/attribute/main.d.ts +1 -0
  9. package/dist/dts/fixtures/binding/binding.spec.d.ts +1 -0
  10. package/dist/dts/fixtures/binding/main.d.ts +1 -0
  11. package/dist/dts/fixtures/children/children.spec.d.ts +1 -0
  12. package/dist/dts/fixtures/children/main.d.ts +1 -0
  13. package/dist/dts/fixtures/dot-syntax/dot-syntax.spec.d.ts +1 -0
  14. package/dist/dts/fixtures/dot-syntax/main.d.ts +1 -0
  15. package/dist/dts/fixtures/event/event.spec.d.ts +1 -0
  16. package/dist/dts/fixtures/event/main.d.ts +1 -0
  17. package/dist/dts/fixtures/partial/main.d.ts +1 -0
  18. package/dist/dts/fixtures/partial/partial.spec.d.ts +1 -0
  19. package/dist/dts/fixtures/ref/main.d.ts +1 -0
  20. package/dist/dts/fixtures/ref/ref.spec.d.ts +1 -0
  21. package/dist/dts/fixtures/repeat/main.d.ts +1 -0
  22. package/dist/dts/fixtures/repeat/repeat.spec.d.ts +1 -0
  23. package/dist/dts/fixtures/slotted/main.d.ts +1 -0
  24. package/dist/dts/fixtures/slotted/slotted.spec.d.ts +1 -0
  25. package/dist/dts/fixtures/when/main.d.ts +1 -0
  26. package/dist/dts/fixtures/when/when.spec.d.ts +1 -0
  27. package/dist/dts/index.d.ts +1 -0
  28. package/dist/dts/interfaces.d.ts +7 -0
  29. package/dist/dts/tsdoc-metadata.json +11 -0
  30. package/dist/esm/components/index.js +1 -0
  31. package/dist/esm/components/template.js +259 -0
  32. package/dist/esm/components/utilities.js +465 -0
  33. package/dist/esm/components/utilities.spec.js +277 -0
  34. package/dist/esm/debug.js +3 -0
  35. package/dist/esm/fixtures/attribute/attribute.spec.js +23 -0
  36. package/dist/esm/fixtures/attribute/main.js +26 -0
  37. package/dist/esm/fixtures/binding/binding.spec.js +23 -0
  38. package/dist/esm/fixtures/binding/main.js +40 -0
  39. package/dist/esm/fixtures/children/children.spec.js +37 -0
  40. package/dist/esm/fixtures/children/main.js +31 -0
  41. package/dist/esm/fixtures/dot-syntax/dot-syntax.spec.js +9 -0
  42. package/dist/esm/fixtures/dot-syntax/main.js +23 -0
  43. package/dist/esm/fixtures/event/event.spec.js +28 -0
  44. package/dist/esm/fixtures/event/main.js +35 -0
  45. package/dist/esm/fixtures/partial/main.js +38 -0
  46. package/dist/esm/fixtures/partial/partial.spec.js +14 -0
  47. package/dist/esm/fixtures/ref/main.js +21 -0
  48. package/dist/esm/fixtures/ref/ref.spec.js +13 -0
  49. package/dist/esm/fixtures/repeat/main.js +27 -0
  50. package/dist/esm/fixtures/repeat/repeat.spec.js +29 -0
  51. package/dist/esm/fixtures/slotted/main.js +29 -0
  52. package/dist/esm/fixtures/slotted/slotted.spec.js +25 -0
  53. package/dist/esm/fixtures/when/main.js +198 -0
  54. package/dist/esm/fixtures/when/when.spec.js +82 -0
  55. package/dist/esm/index.js +4 -0
  56. package/dist/esm/interfaces.js +1 -0
  57. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  58. package/dist/fast-html.api.json +356 -0
  59. package/dist/fast-html.d.ts +78 -0
  60. package/dist/fast-html.untrimmed.d.ts +78 -0
  61. package/package.json +12 -6
  62. package/rules/attribute-directives.yml +38 -0
  63. package/rules/call-expression-with-event-argument.yml +41 -0
  64. package/rules/member-expression.yml +33 -0
  65. package/rules/tag-function-to-template-literal.yml +16 -0
  66. package/CHANGELOG.json +0 -26
  67. package/CHANGELOG.md +0 -14
  68. package/docs/api-report.api.md +0 -18
  69. package/webpack.common.config.js +0 -18
@@ -0,0 +1,356 @@
1
+ {
2
+ "metadata": {
3
+ "toolPackage": "@microsoft/api-extractor",
4
+ "toolVersion": "7.47.0",
5
+ "schemaVersion": 1011,
6
+ "oldestForwardsCompatibleVersion": 1001,
7
+ "tsdocConfig": {
8
+ "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
9
+ "noStandardTags": true,
10
+ "tagDefinitions": [
11
+ {
12
+ "tagName": "@alpha",
13
+ "syntaxKind": "modifier"
14
+ },
15
+ {
16
+ "tagName": "@beta",
17
+ "syntaxKind": "modifier"
18
+ },
19
+ {
20
+ "tagName": "@defaultValue",
21
+ "syntaxKind": "block"
22
+ },
23
+ {
24
+ "tagName": "@decorator",
25
+ "syntaxKind": "block",
26
+ "allowMultiple": true
27
+ },
28
+ {
29
+ "tagName": "@deprecated",
30
+ "syntaxKind": "block"
31
+ },
32
+ {
33
+ "tagName": "@eventProperty",
34
+ "syntaxKind": "modifier"
35
+ },
36
+ {
37
+ "tagName": "@example",
38
+ "syntaxKind": "block",
39
+ "allowMultiple": true
40
+ },
41
+ {
42
+ "tagName": "@experimental",
43
+ "syntaxKind": "modifier"
44
+ },
45
+ {
46
+ "tagName": "@inheritDoc",
47
+ "syntaxKind": "inline"
48
+ },
49
+ {
50
+ "tagName": "@internal",
51
+ "syntaxKind": "modifier"
52
+ },
53
+ {
54
+ "tagName": "@label",
55
+ "syntaxKind": "inline"
56
+ },
57
+ {
58
+ "tagName": "@link",
59
+ "syntaxKind": "inline",
60
+ "allowMultiple": true
61
+ },
62
+ {
63
+ "tagName": "@override",
64
+ "syntaxKind": "modifier"
65
+ },
66
+ {
67
+ "tagName": "@packageDocumentation",
68
+ "syntaxKind": "modifier"
69
+ },
70
+ {
71
+ "tagName": "@param",
72
+ "syntaxKind": "block",
73
+ "allowMultiple": true
74
+ },
75
+ {
76
+ "tagName": "@privateRemarks",
77
+ "syntaxKind": "block"
78
+ },
79
+ {
80
+ "tagName": "@public",
81
+ "syntaxKind": "modifier"
82
+ },
83
+ {
84
+ "tagName": "@readonly",
85
+ "syntaxKind": "modifier"
86
+ },
87
+ {
88
+ "tagName": "@remarks",
89
+ "syntaxKind": "block"
90
+ },
91
+ {
92
+ "tagName": "@returns",
93
+ "syntaxKind": "block"
94
+ },
95
+ {
96
+ "tagName": "@sealed",
97
+ "syntaxKind": "modifier"
98
+ },
99
+ {
100
+ "tagName": "@see",
101
+ "syntaxKind": "block"
102
+ },
103
+ {
104
+ "tagName": "@throws",
105
+ "syntaxKind": "block",
106
+ "allowMultiple": true
107
+ },
108
+ {
109
+ "tagName": "@typeParam",
110
+ "syntaxKind": "block",
111
+ "allowMultiple": true
112
+ },
113
+ {
114
+ "tagName": "@virtual",
115
+ "syntaxKind": "modifier"
116
+ },
117
+ {
118
+ "tagName": "@betaDocumentation",
119
+ "syntaxKind": "modifier"
120
+ },
121
+ {
122
+ "tagName": "@internalRemarks",
123
+ "syntaxKind": "block"
124
+ },
125
+ {
126
+ "tagName": "@preapproved",
127
+ "syntaxKind": "modifier"
128
+ }
129
+ ],
130
+ "supportForTags": {
131
+ "@alpha": true,
132
+ "@beta": true,
133
+ "@defaultValue": true,
134
+ "@decorator": true,
135
+ "@deprecated": true,
136
+ "@eventProperty": true,
137
+ "@example": true,
138
+ "@experimental": true,
139
+ "@inheritDoc": true,
140
+ "@internal": true,
141
+ "@label": true,
142
+ "@link": true,
143
+ "@override": true,
144
+ "@packageDocumentation": true,
145
+ "@param": true,
146
+ "@privateRemarks": true,
147
+ "@public": true,
148
+ "@readonly": true,
149
+ "@remarks": true,
150
+ "@returns": true,
151
+ "@sealed": true,
152
+ "@see": true,
153
+ "@throws": true,
154
+ "@typeParam": true,
155
+ "@virtual": true,
156
+ "@betaDocumentation": true,
157
+ "@internalRemarks": true,
158
+ "@preapproved": true
159
+ },
160
+ "reportUnsupportedHtmlElements": false
161
+ }
162
+ },
163
+ "kind": "Package",
164
+ "canonicalReference": "@microsoft/fast-html!",
165
+ "docComment": "",
166
+ "name": "@microsoft/fast-html",
167
+ "preserveMemberOrder": false,
168
+ "members": [
169
+ {
170
+ "kind": "EntryPoint",
171
+ "canonicalReference": "@microsoft/fast-html!",
172
+ "name": "",
173
+ "preserveMemberOrder": false,
174
+ "members": [
175
+ {
176
+ "kind": "Class",
177
+ "canonicalReference": "@microsoft/fast-html!TemplateElement:class",
178
+ "docComment": "/**\n * The <f-template> custom element that will provide view logic to the element\n */\n",
179
+ "excerptTokens": [
180
+ {
181
+ "kind": "Content",
182
+ "text": "declare class TemplateElement extends "
183
+ },
184
+ {
185
+ "kind": "Reference",
186
+ "text": "FASTElement",
187
+ "canonicalReference": "@microsoft/fast-element!FASTElement:interface"
188
+ },
189
+ {
190
+ "kind": "Content",
191
+ "text": " "
192
+ }
193
+ ],
194
+ "fileUrlPath": "dist/dts/components/template.d.ts",
195
+ "releaseTag": "Public",
196
+ "isAbstract": false,
197
+ "name": "TemplateElement",
198
+ "preserveMemberOrder": false,
199
+ "members": [
200
+ {
201
+ "kind": "Method",
202
+ "canonicalReference": "@microsoft/fast-html!TemplateElement#connectedCallback:member(1)",
203
+ "docComment": "",
204
+ "excerptTokens": [
205
+ {
206
+ "kind": "Content",
207
+ "text": "connectedCallback(): "
208
+ },
209
+ {
210
+ "kind": "Content",
211
+ "text": "void"
212
+ },
213
+ {
214
+ "kind": "Content",
215
+ "text": ";"
216
+ }
217
+ ],
218
+ "isStatic": false,
219
+ "returnTypeTokenRange": {
220
+ "startIndex": 1,
221
+ "endIndex": 2
222
+ },
223
+ "releaseTag": "Public",
224
+ "isProtected": false,
225
+ "overloadIndex": 1,
226
+ "parameters": [],
227
+ "isOptional": false,
228
+ "isAbstract": false,
229
+ "name": "connectedCallback"
230
+ },
231
+ {
232
+ "kind": "Property",
233
+ "canonicalReference": "@microsoft/fast-html!TemplateElement.elementOptions:member",
234
+ "docComment": "/**\n * A dictionary of custom element options\n */\n",
235
+ "excerptTokens": [
236
+ {
237
+ "kind": "Content",
238
+ "text": "static elementOptions: "
239
+ },
240
+ {
241
+ "kind": "Reference",
242
+ "text": "ElementOptions",
243
+ "canonicalReference": "@microsoft/fast-html!~ElementOptions:interface"
244
+ },
245
+ {
246
+ "kind": "Content",
247
+ "text": ";"
248
+ }
249
+ ],
250
+ "isReadonly": false,
251
+ "isOptional": false,
252
+ "releaseTag": "Public",
253
+ "name": "elementOptions",
254
+ "propertyTypeTokenRange": {
255
+ "startIndex": 1,
256
+ "endIndex": 2
257
+ },
258
+ "isStatic": true,
259
+ "isProtected": false,
260
+ "isAbstract": false
261
+ },
262
+ {
263
+ "kind": "Property",
264
+ "canonicalReference": "@microsoft/fast-html!TemplateElement#name:member",
265
+ "docComment": "/**\n * The name of the custom element this template will be applied to\n */\n",
266
+ "excerptTokens": [
267
+ {
268
+ "kind": "Content",
269
+ "text": "name?: "
270
+ },
271
+ {
272
+ "kind": "Content",
273
+ "text": "string"
274
+ },
275
+ {
276
+ "kind": "Content",
277
+ "text": ";"
278
+ }
279
+ ],
280
+ "isReadonly": false,
281
+ "isOptional": true,
282
+ "releaseTag": "Public",
283
+ "name": "name",
284
+ "propertyTypeTokenRange": {
285
+ "startIndex": 1,
286
+ "endIndex": 2
287
+ },
288
+ "isStatic": false,
289
+ "isProtected": false,
290
+ "isAbstract": false
291
+ },
292
+ {
293
+ "kind": "Method",
294
+ "canonicalReference": "@microsoft/fast-html!TemplateElement.options:member(1)",
295
+ "docComment": "",
296
+ "excerptTokens": [
297
+ {
298
+ "kind": "Content",
299
+ "text": "static options(elementOptions?: "
300
+ },
301
+ {
302
+ "kind": "Reference",
303
+ "text": "ElementOptions",
304
+ "canonicalReference": "@microsoft/fast-html!~ElementOptions:interface"
305
+ },
306
+ {
307
+ "kind": "Content",
308
+ "text": "): "
309
+ },
310
+ {
311
+ "kind": "Content",
312
+ "text": "typeof "
313
+ },
314
+ {
315
+ "kind": "Reference",
316
+ "text": "TemplateElement",
317
+ "canonicalReference": "@microsoft/fast-html!TemplateElement:class"
318
+ },
319
+ {
320
+ "kind": "Content",
321
+ "text": ";"
322
+ }
323
+ ],
324
+ "isStatic": true,
325
+ "returnTypeTokenRange": {
326
+ "startIndex": 3,
327
+ "endIndex": 5
328
+ },
329
+ "releaseTag": "Public",
330
+ "isProtected": false,
331
+ "overloadIndex": 1,
332
+ "parameters": [
333
+ {
334
+ "parameterName": "elementOptions",
335
+ "parameterTypeTokenRange": {
336
+ "startIndex": 1,
337
+ "endIndex": 2
338
+ },
339
+ "isOptional": true
340
+ }
341
+ ],
342
+ "isOptional": false,
343
+ "isAbstract": false,
344
+ "name": "options"
345
+ }
346
+ ],
347
+ "extendsTokenRange": {
348
+ "startIndex": 1,
349
+ "endIndex": 2
350
+ },
351
+ "implementsTokenRanges": []
352
+ }
353
+ ]
354
+ }
355
+ ]
356
+ }
@@ -0,0 +1,78 @@
1
+ import { FASTElement } from '@microsoft/fast-element';
2
+ import { ShadowRootOptions } from '@microsoft/fast-element';
3
+
4
+ /**
5
+ * A dictionary of element options the TemplateElement will use to update the registered element
6
+ */
7
+ declare interface ElementOptions {
8
+ [key: string]: {
9
+ shadowOptions: ShadowRootOptions | undefined;
10
+ };
11
+ }
12
+
13
+ /**
14
+ * The <f-template> custom element that will provide view logic to the element
15
+ */
16
+ export declare class TemplateElement extends FASTElement {
17
+ /**
18
+ * The name of the custom element this template will be applied to
19
+ */
20
+ name?: string;
21
+ /**
22
+ * A dictionary of custom element options
23
+ */
24
+ static elementOptions: ElementOptions;
25
+ private partials;
26
+ static options(elementOptions?: ElementOptions): typeof TemplateElement;
27
+ connectedCallback(): void;
28
+ /**
29
+ * Resolve strings and values from an innerHTML string
30
+ * @param innerHTML - The innerHTML.
31
+ * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
32
+ */
33
+ private resolveStringsAndValues;
34
+ /**
35
+ * Resolve a template or behavior
36
+ * @param strings - The strings array.
37
+ * @param values - The interpreted values.
38
+ */
39
+ private resolveTemplateOrBehavior;
40
+ /**
41
+ * Resolve a template directive
42
+ * @param behaviorConfig - The directive behavior configuration object.
43
+ * @param externalValues - The interpreted values from the parent.
44
+ * @param innerHTML - The innerHTML.
45
+ */
46
+ private resolveTemplateDirective;
47
+ /**
48
+ * Resolve a template directive
49
+ * @param name - The name of the directive.
50
+ * @param propName - The property name to pass to the directive.
51
+ * @param externalValues - The interpreted values from the parent.
52
+ */
53
+ private resolveAttributeDirective;
54
+ /**
55
+ * Resolver of a data binding
56
+ * @param innerHTML - The innerHTML.
57
+ * @param strings - The strings array.
58
+ * @param values - The interpreted values.
59
+ * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
60
+ * @param behaviorConfig - The binding behavior configuration object.
61
+ */
62
+ private resolveDataBinding;
63
+ /**
64
+ * Resolver of the innerHTML string
65
+ * @param innerHTML - The innerHTML.
66
+ * @param strings - The strings array.
67
+ * @param values - The interpreted values.
68
+ * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
69
+ */
70
+ private resolveInnerHTML;
71
+ /**
72
+ * Resolve all partial templates
73
+ * @param unresolvedInnerHTML - The innerHTML.
74
+ */
75
+ private resolveAllPartials;
76
+ }
77
+
78
+ export { }
@@ -0,0 +1,78 @@
1
+ import { FASTElement } from '@microsoft/fast-element';
2
+ import { ShadowRootOptions } from '@microsoft/fast-element';
3
+
4
+ /**
5
+ * A dictionary of element options the TemplateElement will use to update the registered element
6
+ */
7
+ declare interface ElementOptions {
8
+ [key: string]: {
9
+ shadowOptions: ShadowRootOptions | undefined;
10
+ };
11
+ }
12
+
13
+ /**
14
+ * The <f-template> custom element that will provide view logic to the element
15
+ */
16
+ export declare class TemplateElement extends FASTElement {
17
+ /**
18
+ * The name of the custom element this template will be applied to
19
+ */
20
+ name?: string;
21
+ /**
22
+ * A dictionary of custom element options
23
+ */
24
+ static elementOptions: ElementOptions;
25
+ private partials;
26
+ static options(elementOptions?: ElementOptions): typeof TemplateElement;
27
+ connectedCallback(): void;
28
+ /**
29
+ * Resolve strings and values from an innerHTML string
30
+ * @param innerHTML - The innerHTML.
31
+ * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
32
+ */
33
+ private resolveStringsAndValues;
34
+ /**
35
+ * Resolve a template or behavior
36
+ * @param strings - The strings array.
37
+ * @param values - The interpreted values.
38
+ */
39
+ private resolveTemplateOrBehavior;
40
+ /**
41
+ * Resolve a template directive
42
+ * @param behaviorConfig - The directive behavior configuration object.
43
+ * @param externalValues - The interpreted values from the parent.
44
+ * @param innerHTML - The innerHTML.
45
+ */
46
+ private resolveTemplateDirective;
47
+ /**
48
+ * Resolve a template directive
49
+ * @param name - The name of the directive.
50
+ * @param propName - The property name to pass to the directive.
51
+ * @param externalValues - The interpreted values from the parent.
52
+ */
53
+ private resolveAttributeDirective;
54
+ /**
55
+ * Resolver of a data binding
56
+ * @param innerHTML - The innerHTML.
57
+ * @param strings - The strings array.
58
+ * @param values - The interpreted values.
59
+ * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
60
+ * @param behaviorConfig - The binding behavior configuration object.
61
+ */
62
+ private resolveDataBinding;
63
+ /**
64
+ * Resolver of the innerHTML string
65
+ * @param innerHTML - The innerHTML.
66
+ * @param strings - The strings array.
67
+ * @param values - The interpreted values.
68
+ * @param self - Indicates that this should refer to itself instead of a property when creating bindings.
69
+ */
70
+ private resolveInnerHTML;
71
+ /**
72
+ * Resolve all partial templates
73
+ * @param unresolvedInnerHTML - The innerHTML.
74
+ */
75
+ private resolveAllPartials;
76
+ }
77
+
78
+ export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/fast-html",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.11",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Microsoft",
@@ -16,6 +16,10 @@
16
16
  "bugs": {
17
17
  "url": "https://github.com/Microsoft/fast/issues/new/choose"
18
18
  },
19
+ "files": [
20
+ "./dist",
21
+ "./rules/*.yml"
22
+ ],
19
23
  "scripts": {
20
24
  "clean": "tsc -b --clean src",
21
25
  "clean:dist": "node ../../../build/clean.js dist",
@@ -40,8 +44,9 @@
40
44
  "pretest": "npm run build && npm run build-server",
41
45
  "prettier:diff": "prettier --config ../../../.prettierrc \"**/*.{ts,html}\" --list-different",
42
46
  "prettier": "prettier --config ../../../.prettierrc --write \"**/*.{ts,html}\"",
43
- "test": "npm run build-app && playwright test --config=playwright.config.cjs",
47
+ "test": "npm run build-app && playwright test --config=playwright.config.cjs && npm run test:rules",
44
48
  "test-server": "node server/dist/server.js",
49
+ "test:rules": "sg test --skip-snapshot-tests",
45
50
  "install-playwright-browsers": "npm run playwright install",
46
51
  "dev": "npm run build && npm run build-app && npm run build-server && npm run test-server"
47
52
  },
@@ -51,17 +56,19 @@
51
56
  "types": "./dist/dts/index.d.ts",
52
57
  "default": "./dist/esm/index.js"
53
58
  },
59
+ "./rules/*.yml": "./rules/*.yml",
54
60
  "./package.json": "./package.json"
55
61
  },
56
62
  "sideEffects": [
57
63
  "./dist/esm/index.js"
58
64
  ],
59
65
  "peerDependencies": {
60
- "@microsoft/fast-element": "^2.2.0"
66
+ "@microsoft/fast-element": "^2.3.0"
61
67
  },
62
68
  "devDependencies": {
69
+ "@ast-grep/cli": "^0.37.0",
63
70
  "@microsoft/api-extractor": "^7.47.0",
64
- "@microsoft/fast-element": "^2.2.0",
71
+ "@microsoft/fast-element": "^2.3.0",
65
72
  "@playwright/test": "^1.49.0",
66
73
  "@types/express": "^4.17.21",
67
74
  "@types/node": "^17.0.17",
@@ -76,7 +83,6 @@
76
83
  "major",
77
84
  "minor",
78
85
  "patch"
79
- ],
80
- "tag": "alpha"
86
+ ]
81
87
  }
82
88
  }
@@ -0,0 +1,38 @@
1
+ # https://ast-grep.github.io/guide/rule-config.html#rule
2
+ # from: ${ref("defaultSlot")}
3
+ # to: f-ref="{defaultSlot}"
4
+ id: binding - convert attribute directives
5
+ language: typescript
6
+ utils:
7
+ call-expression:
8
+ has:
9
+ nthChild: 1
10
+ kind: call_expression
11
+ all:
12
+ - matches: identifier
13
+ - matches: arguments
14
+ identifier:
15
+ has:
16
+ nthChild: 1
17
+ kind: identifier
18
+ pattern: $DIRECTIVE
19
+ arguments:
20
+ has:
21
+ kind: arguments
22
+ matches: string
23
+ string:
24
+ has:
25
+ kind: string
26
+ matches: string-fragment
27
+ string-fragment:
28
+ has:
29
+ kind: string_fragment
30
+ pattern: $STRING
31
+ constraints:
32
+ DIRECTIVE:
33
+ regex: ref|slotted|children
34
+ rule:
35
+ kind: template_substitution
36
+ matches: call-expression
37
+ fix:
38
+ 'f-$DIRECTIVE="{$STRING}"'
@@ -0,0 +1,41 @@
1
+ # https://ast-grep.github.io/guide/rule-config.html#rule
2
+ # from: ${(x, c) => x.foo(c.event)}
3
+ # to: {foo(event)}
4
+ id: binding - convert call expression with event argument
5
+ language: typescript
6
+ utils:
7
+ arrow-function:
8
+ has:
9
+ kind: arrow_function
10
+ matches: call-expression
11
+ call-expression:
12
+ has:
13
+ kind: call_expression
14
+ all:
15
+ - matches: handler-arguments
16
+ - matches: handler-expression
17
+ handler-expression:
18
+ has:
19
+ kind: member_expression
20
+ matches: handler-expression-property
21
+ handler-expression-property:
22
+ has:
23
+ kind: property_identifier
24
+ pattern: $A
25
+ handler-arguments:
26
+ has:
27
+ kind: arguments
28
+ matches: handler-arguments-member-expression
29
+ handler-arguments-member-expression:
30
+ has:
31
+ kind: member_expression
32
+ matches: handler-arguments-property-identifier
33
+ handler-arguments-property-identifier:
34
+ has:
35
+ kind: property_identifier
36
+ pattern: $B
37
+ rule:
38
+ kind: template_substitution
39
+ matches: arrow-function
40
+ fix:
41
+ '{$A($B)}'
@@ -0,0 +1,33 @@
1
+ # https://ast-grep.github.io/guide/rule-config.html#rule
2
+ # from: ${x => x.foo}
3
+ # to: {{foo}}
4
+ id: binding - convert member expression
5
+ language: typescript
6
+ utils:
7
+ arrow-function:
8
+ has:
9
+ kind: arrow_function
10
+ all:
11
+ - matches: identifier
12
+ - matches: member-expression
13
+ member-expression:
14
+ has:
15
+ kind: member_expression
16
+ nthChild: 2
17
+ all:
18
+ - matches: identifier
19
+ - matches: property-identifier
20
+ identifier:
21
+ has:
22
+ kind: identifier
23
+ nthChild: 1
24
+ property-identifier:
25
+ has:
26
+ kind: property_identifier
27
+ nthChild: 2
28
+ pattern: $A
29
+ rule:
30
+ kind: template_substitution
31
+ matches: arrow-function
32
+ fix:
33
+ '{{$A}}'