@ngrok/mantle 0.89.0 → 0.90.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.
Files changed (66) hide show
  1. package/dist/agent.json +1529 -1
  2. package/dist/alert-DO00UiQe.js +1 -0
  3. package/dist/{alert-CZYYlx9q.js → alert-ZaUBtgno.js} +1 -1
  4. package/dist/alert-center.js +1 -1
  5. package/dist/alert-dialog.js +1 -1
  6. package/dist/alert.js +1 -1
  7. package/dist/app-layout.d.ts +68 -13
  8. package/dist/app-layout.js +1 -1
  9. package/dist/card.d.ts +7 -0
  10. package/dist/combobox.d.ts +1 -1
  11. package/dist/command.js +1 -1
  12. package/dist/{dialog-BDzapPLR.js → dialog-CaGJD02w.js} +1 -1
  13. package/dist/dialog.js +1 -1
  14. package/dist/{dropdown-menu-CpRsyt_F.d.ts → dropdown-menu-Cef0Cz2B.d.ts} +1 -1
  15. package/dist/dropdown-menu-DMA8dGxZ.d.ts +1 -0
  16. package/dist/dropdown-menu.d.ts +2 -2
  17. package/dist/empty.d.ts +7 -0
  18. package/dist/flag.d.ts +1 -1
  19. package/dist/flag.js +1 -1
  20. package/dist/hooks.d.ts +251 -1
  21. package/dist/hooks.js +1 -1
  22. package/dist/{icons-BMZnm4hM.js → icons-CAtjMNti.js} +1 -1
  23. package/dist/icons.js +1 -1
  24. package/dist/input.js +1 -1
  25. package/dist/llms.txt +117 -2
  26. package/dist/mantle.css +9 -0
  27. package/dist/migrations/0002-data-table-action-header.yml +526 -0
  28. package/dist/migrations/0003-dialog-footer-dom-order.yml +271 -0
  29. package/dist/migrations/0004-priority-to-intent.yml +1728 -0
  30. package/dist/migrations/0005-field-item-owns-control-id.yml +234 -0
  31. package/dist/migrations/0006-data-table-tanstack-v9.yml +423 -0
  32. package/dist/migrations/0008-tabs-separator.yml +1212 -0
  33. package/dist/migrations/0009-chart-root-mode.yml +871 -0
  34. package/dist/multi-select.d.ts +1 -1
  35. package/dist/multi-select.js +1 -1
  36. package/dist/pagination.d.ts +1 -1
  37. package/dist/{primitive-B-6XILB2.js → primitive-AGoxSJBI.js} +1 -1
  38. package/dist/sandbar.js +1 -1
  39. package/dist/{select-CxXb3aiC.d.ts → select-DlohFa54.d.ts} +1 -1
  40. package/dist/select.d.ts +1 -1
  41. package/dist/{separator-HzGvuD0B.d.ts → separator-BWGjCIl7.d.ts} +7 -0
  42. package/dist/separator.d.ts +1 -1
  43. package/dist/{sheet-DND_KjmS.js → sheet-H8zvhSuA.js} +1 -1
  44. package/dist/sheet.js +1 -1
  45. package/dist/sidebar.d.ts +17 -10
  46. package/dist/sidebar.js +1 -1
  47. package/dist/split-button.d.ts +1 -1
  48. package/dist/strata.d.ts +548 -0
  49. package/dist/strata.js +1 -0
  50. package/dist/tabs.d.ts +12 -2
  51. package/dist/tabs.js +1 -1
  52. package/dist/theme-6Q65C1Rx.js +1 -0
  53. package/dist/theme-switcher.d.ts +2 -2
  54. package/dist/theme-switcher.js +1 -1
  55. package/dist/theme.js +1 -1
  56. package/dist/toast.js +1 -1
  57. package/dist/truncated-text.d.ts +9 -1
  58. package/dist/truncated-text.js +1 -1
  59. package/dist/use-prefers-reduced-motion-DimzRx-M.js +1 -0
  60. package/dist/use-swipe-to-dismiss-Cj-AayFd.js +1 -0
  61. package/dist/well.d.ts +7 -0
  62. package/package.json +4 -3
  63. package/dist/alert-vfeV_hso.js +0 -1
  64. package/dist/dropdown-menu-CWUzGFgf.d.ts +0 -1
  65. package/dist/theme-BlCZHClJ.js +0 -1
  66. package/dist/use-prefers-reduced-motion-Cj9tJ181.js +0 -1
@@ -0,0 +1,1728 @@
1
+ # Every rule binds the local name of each part's import from its
2
+ # `@ngrok/mantle/<subpath>`, so an aliased import matches and another
3
+ # library's `Button` does not.
4
+ id: priority-default-to-accent
5
+ language: tsx
6
+ message: Button priority="default" becomes intent="accent"
7
+ utils:
8
+ # A node that opens a lexical scope. The shadow search below stops at a
9
+ # nested one, so a sibling function's local name does not count.
10
+ scope:
11
+ any:
12
+ - kind: statement_block
13
+ - kind: function_declaration
14
+ - kind: generator_function_declaration
15
+ - kind: function_expression
16
+ - kind: generator_function
17
+ - kind: arrow_function
18
+ - kind: method_definition
19
+ - kind: class_body
20
+ - kind: for_statement
21
+ - kind: for_in_statement
22
+ - kind: catch_clause
23
+ # An identifier in a binding position: a parameter, a destructured name, a
24
+ # local variable, a function name, or a class name.
25
+ binding-name:
26
+ any:
27
+ - kind: shorthand_property_identifier_pattern
28
+ - kind: identifier
29
+ any:
30
+ - inside: { kind: variable_declarator, field: name }
31
+ - inside: { kind: function_declaration, field: name }
32
+ - inside: { kind: generator_function_declaration, field: name }
33
+ - inside: { kind: function_expression, field: name }
34
+ - inside: { kind: required_parameter, field: pattern }
35
+ - inside: { kind: optional_parameter, field: pattern }
36
+ - inside: { kind: assignment_pattern, field: left }
37
+ - inside: { kind: pair_pattern, field: value }
38
+ - inside: { kind: array_pattern }
39
+ - inside: { kind: rest_pattern }
40
+ - inside: { kind: arrow_function, field: parameter }
41
+ - inside: { kind: catch_clause, field: parameter }
42
+ - kind: type_identifier
43
+ inside: { kind: class_declaration, field: name }
44
+ # A function declaration opens a scope, so the search above stops at it and
45
+ # never reads its name. This matches the declaration itself instead.
46
+ function-declaration:
47
+ any:
48
+ - kind: function_declaration
49
+ - kind: generator_function_declaration
50
+ alertdialog-import:
51
+ kind: import_statement
52
+ all:
53
+ - has:
54
+ field: source
55
+ regex: ^["']@ngrok/mantle/alert-dialog["']$
56
+ - has:
57
+ stopBy: end
58
+ kind: import_specifier
59
+ has:
60
+ field: name
61
+ regex: ^AlertDialog$
62
+ any:
63
+ - kind: import_specifier
64
+ has:
65
+ field: alias
66
+ pattern: $ALERT_DIALOG
67
+ - kind: import_specifier
68
+ not:
69
+ has:
70
+ field: alias
71
+ kind: identifier
72
+ has:
73
+ field: name
74
+ pattern: $ALERT_DIALOG
75
+ button-import:
76
+ kind: import_statement
77
+ all:
78
+ - has:
79
+ field: source
80
+ regex: ^["']@ngrok/mantle/button["']$
81
+ - has:
82
+ stopBy: end
83
+ kind: import_specifier
84
+ has:
85
+ field: name
86
+ regex: ^Button$
87
+ any:
88
+ - kind: import_specifier
89
+ has:
90
+ field: alias
91
+ pattern: $BUTTON
92
+ - kind: import_specifier
93
+ not:
94
+ has:
95
+ field: alias
96
+ kind: identifier
97
+ has:
98
+ field: name
99
+ pattern: $BUTTON
100
+ datatable-import:
101
+ kind: import_statement
102
+ all:
103
+ - has:
104
+ field: source
105
+ regex: ^["']@ngrok/mantle/data-table["']$
106
+ - has:
107
+ stopBy: end
108
+ kind: import_specifier
109
+ has:
110
+ field: name
111
+ regex: ^DataTable$
112
+ any:
113
+ - kind: import_specifier
114
+ has:
115
+ field: alias
116
+ pattern: $DT
117
+ - kind: import_specifier
118
+ not:
119
+ has:
120
+ field: alias
121
+ kind: identifier
122
+ has:
123
+ field: name
124
+ pattern: $DT
125
+ button-element:
126
+ any:
127
+ - kind: jsx_opening_element
128
+ - kind: jsx_self_closing_element
129
+ # Why all: the name binds the metavariable, and the import must read it.
130
+ all:
131
+ - has:
132
+ field: name
133
+ kind: identifier
134
+ pattern: $BUTTON
135
+ - inside:
136
+ stopBy: end
137
+ kind: program
138
+ has:
139
+ matches: button-import
140
+ # Why: a parameter or a local under the import's name shadows it, and the
141
+ # rules cannot tell which binding the element reads.
142
+ - not:
143
+ inside:
144
+ stopBy: end
145
+ matches: scope
146
+ has:
147
+ stopBy:
148
+ matches: scope
149
+ any:
150
+ - matches: binding-name
151
+ pattern: $BUTTON
152
+ - matches: function-declaration
153
+ has:
154
+ field: name
155
+ pattern: $BUTTON
156
+ alert-dialog-action-element:
157
+ any:
158
+ - kind: jsx_opening_element
159
+ - kind: jsx_self_closing_element
160
+ # Why all: the name binds the metavariable, and the import must read it.
161
+ all:
162
+ - has:
163
+ field: name
164
+ kind: member_expression
165
+ all:
166
+ - has:
167
+ field: object
168
+ pattern: $ALERT_DIALOG
169
+ - has:
170
+ field: property
171
+ regex: ^Action$
172
+ - inside:
173
+ stopBy: end
174
+ kind: program
175
+ has:
176
+ matches: alertdialog-import
177
+ # Why: a parameter or a local under the import's name shadows it, and the
178
+ # rules cannot tell which binding the element reads.
179
+ - not:
180
+ inside:
181
+ stopBy: end
182
+ matches: scope
183
+ has:
184
+ stopBy:
185
+ matches: scope
186
+ any:
187
+ - matches: binding-name
188
+ pattern: $ALERT_DIALOG
189
+ - matches: function-declaration
190
+ has:
191
+ field: name
192
+ pattern: $ALERT_DIALOG
193
+ alert-dialog-cancel-element:
194
+ any:
195
+ - kind: jsx_opening_element
196
+ - kind: jsx_self_closing_element
197
+ # Why all: the name binds the metavariable, and the import must read it.
198
+ all:
199
+ - has:
200
+ field: name
201
+ kind: member_expression
202
+ all:
203
+ - has:
204
+ field: object
205
+ pattern: $ALERT_DIALOG
206
+ - has:
207
+ field: property
208
+ regex: ^Cancel$
209
+ - inside:
210
+ stopBy: end
211
+ kind: program
212
+ has:
213
+ matches: alertdialog-import
214
+ # Why: a parameter or a local under the import's name shadows it, and the
215
+ # rules cannot tell which binding the element reads.
216
+ - not:
217
+ inside:
218
+ stopBy: end
219
+ matches: scope
220
+ has:
221
+ stopBy:
222
+ matches: scope
223
+ any:
224
+ - matches: binding-name
225
+ pattern: $ALERT_DIALOG
226
+ - matches: function-declaration
227
+ has:
228
+ field: name
229
+ pattern: $ALERT_DIALOG
230
+ header-sort-button-element:
231
+ any:
232
+ - kind: jsx_opening_element
233
+ - kind: jsx_self_closing_element
234
+ # Why all: the name binds the metavariable, and the import must read it.
235
+ all:
236
+ - has:
237
+ field: name
238
+ kind: member_expression
239
+ all:
240
+ - has:
241
+ field: object
242
+ pattern: $DT
243
+ - has:
244
+ field: property
245
+ regex: ^HeaderSortButton$
246
+ - inside:
247
+ stopBy: end
248
+ kind: program
249
+ has:
250
+ matches: datatable-import
251
+ # Why: a parameter or a local under the import's name shadows it, and the
252
+ # rules cannot tell which binding the element reads.
253
+ - not:
254
+ inside:
255
+ stopBy: end
256
+ matches: scope
257
+ has:
258
+ stopBy:
259
+ matches: scope
260
+ any:
261
+ - matches: binding-name
262
+ pattern: $DT
263
+ - matches: function-declaration
264
+ has:
265
+ field: name
266
+ pattern: $DT
267
+ rule:
268
+ kind: jsx_attribute
269
+ has:
270
+ kind: property_identifier
271
+ regex: ^priority$
272
+ any:
273
+ - kind: jsx_attribute
274
+ has:
275
+ kind: string
276
+ regex: ^["']default["']$
277
+ - kind: jsx_attribute
278
+ has:
279
+ kind: jsx_expression
280
+ has:
281
+ kind: string
282
+ regex: ^["']default["']$
283
+ inside:
284
+ any:
285
+ - matches: button-element
286
+ - matches: alert-dialog-action-element
287
+ - matches: alert-dialog-cancel-element
288
+ - matches: header-sort-button-element
289
+ fix: intent="accent"
290
+ ---
291
+ id: priority-to-intent
292
+ language: tsx
293
+ message: rename priority to intent
294
+ utils:
295
+ # A node that opens a lexical scope. The shadow search below stops at a
296
+ # nested one, so a sibling function's local name does not count.
297
+ scope:
298
+ any:
299
+ - kind: statement_block
300
+ - kind: function_declaration
301
+ - kind: generator_function_declaration
302
+ - kind: function_expression
303
+ - kind: generator_function
304
+ - kind: arrow_function
305
+ - kind: method_definition
306
+ - kind: class_body
307
+ - kind: for_statement
308
+ - kind: for_in_statement
309
+ - kind: catch_clause
310
+ # An identifier in a binding position: a parameter, a destructured name, a
311
+ # local variable, a function name, or a class name.
312
+ binding-name:
313
+ any:
314
+ - kind: shorthand_property_identifier_pattern
315
+ - kind: identifier
316
+ any:
317
+ - inside: { kind: variable_declarator, field: name }
318
+ - inside: { kind: function_declaration, field: name }
319
+ - inside: { kind: generator_function_declaration, field: name }
320
+ - inside: { kind: function_expression, field: name }
321
+ - inside: { kind: required_parameter, field: pattern }
322
+ - inside: { kind: optional_parameter, field: pattern }
323
+ - inside: { kind: assignment_pattern, field: left }
324
+ - inside: { kind: pair_pattern, field: value }
325
+ - inside: { kind: array_pattern }
326
+ - inside: { kind: rest_pattern }
327
+ - inside: { kind: arrow_function, field: parameter }
328
+ - inside: { kind: catch_clause, field: parameter }
329
+ - kind: type_identifier
330
+ inside: { kind: class_declaration, field: name }
331
+ # A function declaration opens a scope, so the search above stops at it and
332
+ # never reads its name. This matches the declaration itself instead.
333
+ function-declaration:
334
+ any:
335
+ - kind: function_declaration
336
+ - kind: generator_function_declaration
337
+ alert-import:
338
+ kind: import_statement
339
+ all:
340
+ - has:
341
+ field: source
342
+ regex: ^["']@ngrok/mantle/alert["']$
343
+ - has:
344
+ stopBy: end
345
+ kind: import_specifier
346
+ has:
347
+ field: name
348
+ regex: ^Alert$
349
+ any:
350
+ - kind: import_specifier
351
+ has:
352
+ field: alias
353
+ pattern: $ALERT
354
+ - kind: import_specifier
355
+ not:
356
+ has:
357
+ field: alias
358
+ kind: identifier
359
+ has:
360
+ field: name
361
+ pattern: $ALERT
362
+ alertdialog-import:
363
+ kind: import_statement
364
+ all:
365
+ - has:
366
+ field: source
367
+ regex: ^["']@ngrok/mantle/alert-dialog["']$
368
+ - has:
369
+ stopBy: end
370
+ kind: import_specifier
371
+ has:
372
+ field: name
373
+ regex: ^AlertDialog$
374
+ any:
375
+ - kind: import_specifier
376
+ has:
377
+ field: alias
378
+ pattern: $ALERT_DIALOG
379
+ - kind: import_specifier
380
+ not:
381
+ has:
382
+ field: alias
383
+ kind: identifier
384
+ has:
385
+ field: name
386
+ pattern: $ALERT_DIALOG
387
+ button-import:
388
+ kind: import_statement
389
+ all:
390
+ - has:
391
+ field: source
392
+ regex: ^["']@ngrok/mantle/button["']$
393
+ - has:
394
+ stopBy: end
395
+ kind: import_specifier
396
+ has:
397
+ field: name
398
+ regex: ^Button$
399
+ any:
400
+ - kind: import_specifier
401
+ has:
402
+ field: alias
403
+ pattern: $BUTTON
404
+ - kind: import_specifier
405
+ not:
406
+ has:
407
+ field: alias
408
+ kind: identifier
409
+ has:
410
+ field: name
411
+ pattern: $BUTTON
412
+ datatable-import:
413
+ kind: import_statement
414
+ all:
415
+ - has:
416
+ field: source
417
+ regex: ^["']@ngrok/mantle/data-table["']$
418
+ - has:
419
+ stopBy: end
420
+ kind: import_specifier
421
+ has:
422
+ field: name
423
+ regex: ^DataTable$
424
+ any:
425
+ - kind: import_specifier
426
+ has:
427
+ field: alias
428
+ pattern: $DT
429
+ - kind: import_specifier
430
+ not:
431
+ has:
432
+ field: alias
433
+ kind: identifier
434
+ has:
435
+ field: name
436
+ pattern: $DT
437
+ iconbutton-import:
438
+ kind: import_statement
439
+ all:
440
+ - has:
441
+ field: source
442
+ regex: ^["']@ngrok/mantle/button["']$
443
+ - has:
444
+ stopBy: end
445
+ kind: import_specifier
446
+ has:
447
+ field: name
448
+ regex: ^IconButton$
449
+ any:
450
+ - kind: import_specifier
451
+ has:
452
+ field: alias
453
+ pattern: $ICON_BUTTON
454
+ - kind: import_specifier
455
+ not:
456
+ has:
457
+ field: alias
458
+ kind: identifier
459
+ has:
460
+ field: name
461
+ pattern: $ICON_BUTTON
462
+ toast-import:
463
+ kind: import_statement
464
+ all:
465
+ - has:
466
+ field: source
467
+ regex: ^["']@ngrok/mantle/toast["']$
468
+ - has:
469
+ stopBy: end
470
+ kind: import_specifier
471
+ has:
472
+ field: name
473
+ regex: ^Toast$
474
+ any:
475
+ - kind: import_specifier
476
+ has:
477
+ field: alias
478
+ pattern: $TOAST
479
+ - kind: import_specifier
480
+ not:
481
+ has:
482
+ field: alias
483
+ kind: identifier
484
+ has:
485
+ field: name
486
+ pattern: $TOAST
487
+ button-element:
488
+ any:
489
+ - kind: jsx_opening_element
490
+ - kind: jsx_self_closing_element
491
+ # Why all: the name binds the metavariable, and the import must read it.
492
+ all:
493
+ - has:
494
+ field: name
495
+ kind: identifier
496
+ pattern: $BUTTON
497
+ - inside:
498
+ stopBy: end
499
+ kind: program
500
+ has:
501
+ matches: button-import
502
+ # Why: a parameter or a local under the import's name shadows it, and the
503
+ # rules cannot tell which binding the element reads.
504
+ - not:
505
+ inside:
506
+ stopBy: end
507
+ matches: scope
508
+ has:
509
+ stopBy:
510
+ matches: scope
511
+ any:
512
+ - matches: binding-name
513
+ pattern: $BUTTON
514
+ - matches: function-declaration
515
+ has:
516
+ field: name
517
+ pattern: $BUTTON
518
+ icon-button-element:
519
+ any:
520
+ - kind: jsx_opening_element
521
+ - kind: jsx_self_closing_element
522
+ # Why all: the name binds the metavariable, and the import must read it.
523
+ all:
524
+ - has:
525
+ field: name
526
+ kind: identifier
527
+ pattern: $ICON_BUTTON
528
+ - inside:
529
+ stopBy: end
530
+ kind: program
531
+ has:
532
+ matches: iconbutton-import
533
+ # Why: a parameter or a local under the import's name shadows it, and the
534
+ # rules cannot tell which binding the element reads.
535
+ - not:
536
+ inside:
537
+ stopBy: end
538
+ matches: scope
539
+ has:
540
+ stopBy:
541
+ matches: scope
542
+ any:
543
+ - matches: binding-name
544
+ pattern: $ICON_BUTTON
545
+ - matches: function-declaration
546
+ has:
547
+ field: name
548
+ pattern: $ICON_BUTTON
549
+ alert-root-element:
550
+ any:
551
+ - kind: jsx_opening_element
552
+ - kind: jsx_self_closing_element
553
+ # Why all: the name binds the metavariable, and the import must read it.
554
+ all:
555
+ - has:
556
+ field: name
557
+ kind: member_expression
558
+ all:
559
+ - has:
560
+ field: object
561
+ pattern: $ALERT
562
+ - has:
563
+ field: property
564
+ regex: ^Root$
565
+ - inside:
566
+ stopBy: end
567
+ kind: program
568
+ has:
569
+ matches: alert-import
570
+ # Why: a parameter or a local under the import's name shadows it, and the
571
+ # rules cannot tell which binding the element reads.
572
+ - not:
573
+ inside:
574
+ stopBy: end
575
+ matches: scope
576
+ has:
577
+ stopBy:
578
+ matches: scope
579
+ any:
580
+ - matches: binding-name
581
+ pattern: $ALERT
582
+ - matches: function-declaration
583
+ has:
584
+ field: name
585
+ pattern: $ALERT
586
+ alert-dialog-root-element:
587
+ any:
588
+ - kind: jsx_opening_element
589
+ - kind: jsx_self_closing_element
590
+ # Why all: the name binds the metavariable, and the import must read it.
591
+ all:
592
+ - has:
593
+ field: name
594
+ kind: member_expression
595
+ all:
596
+ - has:
597
+ field: object
598
+ pattern: $ALERT_DIALOG
599
+ - has:
600
+ field: property
601
+ regex: ^Root$
602
+ - inside:
603
+ stopBy: end
604
+ kind: program
605
+ has:
606
+ matches: alertdialog-import
607
+ # Why: a parameter or a local under the import's name shadows it, and the
608
+ # rules cannot tell which binding the element reads.
609
+ - not:
610
+ inside:
611
+ stopBy: end
612
+ matches: scope
613
+ has:
614
+ stopBy:
615
+ matches: scope
616
+ any:
617
+ - matches: binding-name
618
+ pattern: $ALERT_DIALOG
619
+ - matches: function-declaration
620
+ has:
621
+ field: name
622
+ pattern: $ALERT_DIALOG
623
+ alert-dialog-action-element:
624
+ any:
625
+ - kind: jsx_opening_element
626
+ - kind: jsx_self_closing_element
627
+ # Why all: the name binds the metavariable, and the import must read it.
628
+ all:
629
+ - has:
630
+ field: name
631
+ kind: member_expression
632
+ all:
633
+ - has:
634
+ field: object
635
+ pattern: $ALERT_DIALOG
636
+ - has:
637
+ field: property
638
+ regex: ^Action$
639
+ - inside:
640
+ stopBy: end
641
+ kind: program
642
+ has:
643
+ matches: alertdialog-import
644
+ # Why: a parameter or a local under the import's name shadows it, and the
645
+ # rules cannot tell which binding the element reads.
646
+ - not:
647
+ inside:
648
+ stopBy: end
649
+ matches: scope
650
+ has:
651
+ stopBy:
652
+ matches: scope
653
+ any:
654
+ - matches: binding-name
655
+ pattern: $ALERT_DIALOG
656
+ - matches: function-declaration
657
+ has:
658
+ field: name
659
+ pattern: $ALERT_DIALOG
660
+ alert-dialog-cancel-element:
661
+ any:
662
+ - kind: jsx_opening_element
663
+ - kind: jsx_self_closing_element
664
+ # Why all: the name binds the metavariable, and the import must read it.
665
+ all:
666
+ - has:
667
+ field: name
668
+ kind: member_expression
669
+ all:
670
+ - has:
671
+ field: object
672
+ pattern: $ALERT_DIALOG
673
+ - has:
674
+ field: property
675
+ regex: ^Cancel$
676
+ - inside:
677
+ stopBy: end
678
+ kind: program
679
+ has:
680
+ matches: alertdialog-import
681
+ # Why: a parameter or a local under the import's name shadows it, and the
682
+ # rules cannot tell which binding the element reads.
683
+ - not:
684
+ inside:
685
+ stopBy: end
686
+ matches: scope
687
+ has:
688
+ stopBy:
689
+ matches: scope
690
+ any:
691
+ - matches: binding-name
692
+ pattern: $ALERT_DIALOG
693
+ - matches: function-declaration
694
+ has:
695
+ field: name
696
+ pattern: $ALERT_DIALOG
697
+ toast-root-element:
698
+ any:
699
+ - kind: jsx_opening_element
700
+ - kind: jsx_self_closing_element
701
+ # Why all: the name binds the metavariable, and the import must read it.
702
+ all:
703
+ - has:
704
+ field: name
705
+ kind: member_expression
706
+ all:
707
+ - has:
708
+ field: object
709
+ pattern: $TOAST
710
+ - has:
711
+ field: property
712
+ regex: ^Root$
713
+ - inside:
714
+ stopBy: end
715
+ kind: program
716
+ has:
717
+ matches: toast-import
718
+ # Why: a parameter or a local under the import's name shadows it, and the
719
+ # rules cannot tell which binding the element reads.
720
+ - not:
721
+ inside:
722
+ stopBy: end
723
+ matches: scope
724
+ has:
725
+ stopBy:
726
+ matches: scope
727
+ any:
728
+ - matches: binding-name
729
+ pattern: $TOAST
730
+ - matches: function-declaration
731
+ has:
732
+ field: name
733
+ pattern: $TOAST
734
+ header-sort-button-element:
735
+ any:
736
+ - kind: jsx_opening_element
737
+ - kind: jsx_self_closing_element
738
+ # Why all: the name binds the metavariable, and the import must read it.
739
+ all:
740
+ - has:
741
+ field: name
742
+ kind: member_expression
743
+ all:
744
+ - has:
745
+ field: object
746
+ pattern: $DT
747
+ - has:
748
+ field: property
749
+ regex: ^HeaderSortButton$
750
+ - inside:
751
+ stopBy: end
752
+ kind: program
753
+ has:
754
+ matches: datatable-import
755
+ # Why: a parameter or a local under the import's name shadows it, and the
756
+ # rules cannot tell which binding the element reads.
757
+ - not:
758
+ inside:
759
+ stopBy: end
760
+ matches: scope
761
+ has:
762
+ stopBy:
763
+ matches: scope
764
+ any:
765
+ - matches: binding-name
766
+ pattern: $DT
767
+ - matches: function-declaration
768
+ has:
769
+ field: name
770
+ pattern: $DT
771
+ priority-default:
772
+ kind: jsx_attribute
773
+ has:
774
+ kind: property_identifier
775
+ regex: ^priority$
776
+ any:
777
+ - kind: jsx_attribute
778
+ has:
779
+ kind: string
780
+ regex: ^["']default["']$
781
+ - kind: jsx_attribute
782
+ has:
783
+ kind: jsx_expression
784
+ has:
785
+ kind: string
786
+ regex: ^["']default["']$
787
+ rule:
788
+ kind: jsx_attribute
789
+ pattern: $ATTR
790
+ has:
791
+ kind: property_identifier
792
+ regex: ^priority$
793
+ not:
794
+ matches: priority-default
795
+ inside:
796
+ any:
797
+ - matches: button-element
798
+ - matches: icon-button-element
799
+ - matches: alert-root-element
800
+ - matches: alert-dialog-root-element
801
+ - matches: alert-dialog-action-element
802
+ - matches: alert-dialog-cancel-element
803
+ - matches: toast-root-element
804
+ - matches: header-sort-button-element
805
+ transform:
806
+ RENAMED:
807
+ replace:
808
+ source: $ATTR
809
+ replace: ^priority
810
+ by: intent
811
+ fix: $RENAMED
812
+ ---
813
+ id: button-bare
814
+ language: tsx
815
+ message: a bare Button keeps its old implicit outlined accent rendering
816
+ utils:
817
+ # A node that opens a lexical scope. The shadow search below stops at a
818
+ # nested one, so a sibling function's local name does not count.
819
+ scope:
820
+ any:
821
+ - kind: statement_block
822
+ - kind: function_declaration
823
+ - kind: generator_function_declaration
824
+ - kind: function_expression
825
+ - kind: generator_function
826
+ - kind: arrow_function
827
+ - kind: method_definition
828
+ - kind: class_body
829
+ - kind: for_statement
830
+ - kind: for_in_statement
831
+ - kind: catch_clause
832
+ # An identifier in a binding position: a parameter, a destructured name, a
833
+ # local variable, a function name, or a class name.
834
+ binding-name:
835
+ any:
836
+ - kind: shorthand_property_identifier_pattern
837
+ - kind: identifier
838
+ any:
839
+ - inside: { kind: variable_declarator, field: name }
840
+ - inside: { kind: function_declaration, field: name }
841
+ - inside: { kind: generator_function_declaration, field: name }
842
+ - inside: { kind: function_expression, field: name }
843
+ - inside: { kind: required_parameter, field: pattern }
844
+ - inside: { kind: optional_parameter, field: pattern }
845
+ - inside: { kind: assignment_pattern, field: left }
846
+ - inside: { kind: pair_pattern, field: value }
847
+ - inside: { kind: array_pattern }
848
+ - inside: { kind: rest_pattern }
849
+ - inside: { kind: arrow_function, field: parameter }
850
+ - inside: { kind: catch_clause, field: parameter }
851
+ - kind: type_identifier
852
+ inside: { kind: class_declaration, field: name }
853
+ # A function declaration opens a scope, so the search above stops at it and
854
+ # never reads its name. This matches the declaration itself instead.
855
+ function-declaration:
856
+ any:
857
+ - kind: function_declaration
858
+ - kind: generator_function_declaration
859
+ button-import:
860
+ kind: import_statement
861
+ all:
862
+ - has:
863
+ field: source
864
+ regex: ^["']@ngrok/mantle/button["']$
865
+ - has:
866
+ stopBy: end
867
+ kind: import_specifier
868
+ has:
869
+ field: name
870
+ regex: ^Button$
871
+ any:
872
+ - kind: import_specifier
873
+ has:
874
+ field: alias
875
+ pattern: $BUTTON
876
+ - kind: import_specifier
877
+ not:
878
+ has:
879
+ field: alias
880
+ kind: identifier
881
+ has:
882
+ field: name
883
+ pattern: $BUTTON
884
+ button-element:
885
+ any:
886
+ - kind: jsx_opening_element
887
+ - kind: jsx_self_closing_element
888
+ # Why all: the name binds the metavariable, and the import must read it.
889
+ all:
890
+ - has:
891
+ field: name
892
+ kind: identifier
893
+ pattern: $BUTTON
894
+ - inside:
895
+ stopBy: end
896
+ kind: program
897
+ has:
898
+ matches: button-import
899
+ # Why: a parameter or a local under the import's name shadows it, and the
900
+ # rules cannot tell which binding the element reads.
901
+ - not:
902
+ inside:
903
+ stopBy: end
904
+ matches: scope
905
+ has:
906
+ stopBy:
907
+ matches: scope
908
+ any:
909
+ - matches: binding-name
910
+ pattern: $BUTTON
911
+ - matches: function-declaration
912
+ has:
913
+ field: name
914
+ pattern: $BUTTON
915
+ has-tone:
916
+ kind: jsx_attribute
917
+ has:
918
+ kind: property_identifier
919
+ regex: ^(priority|intent)$
920
+ has-appearance:
921
+ kind: jsx_attribute
922
+ has:
923
+ kind: property_identifier
924
+ regex: ^appearance$
925
+ rule:
926
+ kind: identifier
927
+ pattern: $BUTTON
928
+ inside:
929
+ matches: button-element
930
+ all:
931
+ - not:
932
+ has:
933
+ matches: has-appearance
934
+ - not:
935
+ has:
936
+ matches: has-tone
937
+ fix: $BUTTON appearance="outlined" intent="accent"
938
+ ---
939
+ id: button-tone-only
940
+ language: tsx
941
+ message: a Button with a tone and no appearance was outlined
942
+ utils:
943
+ # A node that opens a lexical scope. The shadow search below stops at a
944
+ # nested one, so a sibling function's local name does not count.
945
+ scope:
946
+ any:
947
+ - kind: statement_block
948
+ - kind: function_declaration
949
+ - kind: generator_function_declaration
950
+ - kind: function_expression
951
+ - kind: generator_function
952
+ - kind: arrow_function
953
+ - kind: method_definition
954
+ - kind: class_body
955
+ - kind: for_statement
956
+ - kind: for_in_statement
957
+ - kind: catch_clause
958
+ # An identifier in a binding position: a parameter, a destructured name, a
959
+ # local variable, a function name, or a class name.
960
+ binding-name:
961
+ any:
962
+ - kind: shorthand_property_identifier_pattern
963
+ - kind: identifier
964
+ any:
965
+ - inside: { kind: variable_declarator, field: name }
966
+ - inside: { kind: function_declaration, field: name }
967
+ - inside: { kind: generator_function_declaration, field: name }
968
+ - inside: { kind: function_expression, field: name }
969
+ - inside: { kind: required_parameter, field: pattern }
970
+ - inside: { kind: optional_parameter, field: pattern }
971
+ - inside: { kind: assignment_pattern, field: left }
972
+ - inside: { kind: pair_pattern, field: value }
973
+ - inside: { kind: array_pattern }
974
+ - inside: { kind: rest_pattern }
975
+ - inside: { kind: arrow_function, field: parameter }
976
+ - inside: { kind: catch_clause, field: parameter }
977
+ - kind: type_identifier
978
+ inside: { kind: class_declaration, field: name }
979
+ # A function declaration opens a scope, so the search above stops at it and
980
+ # never reads its name. This matches the declaration itself instead.
981
+ function-declaration:
982
+ any:
983
+ - kind: function_declaration
984
+ - kind: generator_function_declaration
985
+ button-import:
986
+ kind: import_statement
987
+ all:
988
+ - has:
989
+ field: source
990
+ regex: ^["']@ngrok/mantle/button["']$
991
+ - has:
992
+ stopBy: end
993
+ kind: import_specifier
994
+ has:
995
+ field: name
996
+ regex: ^Button$
997
+ any:
998
+ - kind: import_specifier
999
+ has:
1000
+ field: alias
1001
+ pattern: $BUTTON
1002
+ - kind: import_specifier
1003
+ not:
1004
+ has:
1005
+ field: alias
1006
+ kind: identifier
1007
+ has:
1008
+ field: name
1009
+ pattern: $BUTTON
1010
+ button-element:
1011
+ any:
1012
+ - kind: jsx_opening_element
1013
+ - kind: jsx_self_closing_element
1014
+ # Why all: the name binds the metavariable, and the import must read it.
1015
+ all:
1016
+ - has:
1017
+ field: name
1018
+ kind: identifier
1019
+ pattern: $BUTTON
1020
+ - inside:
1021
+ stopBy: end
1022
+ kind: program
1023
+ has:
1024
+ matches: button-import
1025
+ # Why: a parameter or a local under the import's name shadows it, and the
1026
+ # rules cannot tell which binding the element reads.
1027
+ - not:
1028
+ inside:
1029
+ stopBy: end
1030
+ matches: scope
1031
+ has:
1032
+ stopBy:
1033
+ matches: scope
1034
+ any:
1035
+ - matches: binding-name
1036
+ pattern: $BUTTON
1037
+ - matches: function-declaration
1038
+ has:
1039
+ field: name
1040
+ pattern: $BUTTON
1041
+ has-tone:
1042
+ kind: jsx_attribute
1043
+ has:
1044
+ kind: property_identifier
1045
+ regex: ^(priority|intent)$
1046
+ has-appearance:
1047
+ kind: jsx_attribute
1048
+ has:
1049
+ kind: property_identifier
1050
+ regex: ^appearance$
1051
+ rule:
1052
+ kind: identifier
1053
+ pattern: $BUTTON
1054
+ inside:
1055
+ matches: button-element
1056
+ all:
1057
+ - not:
1058
+ has:
1059
+ matches: has-appearance
1060
+ - has:
1061
+ matches: has-tone
1062
+ fix: $BUTTON appearance="outlined"
1063
+ ---
1064
+ id: button-filled-no-tone
1065
+ language: tsx
1066
+ message: a filled Button without a tone adopts the default primary action
1067
+ utils:
1068
+ # A node that opens a lexical scope. The shadow search below stops at a
1069
+ # nested one, so a sibling function's local name does not count.
1070
+ scope:
1071
+ any:
1072
+ - kind: statement_block
1073
+ - kind: function_declaration
1074
+ - kind: generator_function_declaration
1075
+ - kind: function_expression
1076
+ - kind: generator_function
1077
+ - kind: arrow_function
1078
+ - kind: method_definition
1079
+ - kind: class_body
1080
+ - kind: for_statement
1081
+ - kind: for_in_statement
1082
+ - kind: catch_clause
1083
+ # An identifier in a binding position: a parameter, a destructured name, a
1084
+ # local variable, a function name, or a class name.
1085
+ binding-name:
1086
+ any:
1087
+ - kind: shorthand_property_identifier_pattern
1088
+ - kind: identifier
1089
+ any:
1090
+ - inside: { kind: variable_declarator, field: name }
1091
+ - inside: { kind: function_declaration, field: name }
1092
+ - inside: { kind: generator_function_declaration, field: name }
1093
+ - inside: { kind: function_expression, field: name }
1094
+ - inside: { kind: required_parameter, field: pattern }
1095
+ - inside: { kind: optional_parameter, field: pattern }
1096
+ - inside: { kind: assignment_pattern, field: left }
1097
+ - inside: { kind: pair_pattern, field: value }
1098
+ - inside: { kind: array_pattern }
1099
+ - inside: { kind: rest_pattern }
1100
+ - inside: { kind: arrow_function, field: parameter }
1101
+ - inside: { kind: catch_clause, field: parameter }
1102
+ - kind: type_identifier
1103
+ inside: { kind: class_declaration, field: name }
1104
+ # A function declaration opens a scope, so the search above stops at it and
1105
+ # never reads its name. This matches the declaration itself instead.
1106
+ function-declaration:
1107
+ any:
1108
+ - kind: function_declaration
1109
+ - kind: generator_function_declaration
1110
+ button-import:
1111
+ kind: import_statement
1112
+ all:
1113
+ - has:
1114
+ field: source
1115
+ regex: ^["']@ngrok/mantle/button["']$
1116
+ - has:
1117
+ stopBy: end
1118
+ kind: import_specifier
1119
+ has:
1120
+ field: name
1121
+ regex: ^Button$
1122
+ any:
1123
+ - kind: import_specifier
1124
+ has:
1125
+ field: alias
1126
+ pattern: $BUTTON
1127
+ - kind: import_specifier
1128
+ not:
1129
+ has:
1130
+ field: alias
1131
+ kind: identifier
1132
+ has:
1133
+ field: name
1134
+ pattern: $BUTTON
1135
+ button-element:
1136
+ any:
1137
+ - kind: jsx_opening_element
1138
+ - kind: jsx_self_closing_element
1139
+ # Why all: the name binds the metavariable, and the import must read it.
1140
+ all:
1141
+ - has:
1142
+ field: name
1143
+ kind: identifier
1144
+ pattern: $BUTTON
1145
+ - inside:
1146
+ stopBy: end
1147
+ kind: program
1148
+ has:
1149
+ matches: button-import
1150
+ # Why: a parameter or a local under the import's name shadows it, and the
1151
+ # rules cannot tell which binding the element reads.
1152
+ - not:
1153
+ inside:
1154
+ stopBy: end
1155
+ matches: scope
1156
+ has:
1157
+ stopBy:
1158
+ matches: scope
1159
+ any:
1160
+ - matches: binding-name
1161
+ pattern: $BUTTON
1162
+ - matches: function-declaration
1163
+ has:
1164
+ field: name
1165
+ pattern: $BUTTON
1166
+ has-tone:
1167
+ kind: jsx_attribute
1168
+ has:
1169
+ kind: property_identifier
1170
+ regex: ^(priority|intent)$
1171
+ appearance-filled:
1172
+ kind: jsx_attribute
1173
+ has:
1174
+ kind: property_identifier
1175
+ regex: ^appearance$
1176
+ any:
1177
+ - kind: jsx_attribute
1178
+ has:
1179
+ kind: string
1180
+ regex: ^["']filled["']$
1181
+ - kind: jsx_attribute
1182
+ has:
1183
+ kind: jsx_expression
1184
+ has:
1185
+ kind: string
1186
+ regex: ^["']filled["']$
1187
+ rule:
1188
+ kind: identifier
1189
+ pattern: $BUTTON
1190
+ inside:
1191
+ matches: button-element
1192
+ all:
1193
+ - has:
1194
+ matches: appearance-filled
1195
+ - not:
1196
+ has:
1197
+ matches: has-tone
1198
+ fix: $BUTTON intent="neutral"
1199
+ ---
1200
+ id: button-appearance-no-tone
1201
+ language: tsx
1202
+ message: a Button with an appearance and no tone was accent
1203
+ utils:
1204
+ # A node that opens a lexical scope. The shadow search below stops at a
1205
+ # nested one, so a sibling function's local name does not count.
1206
+ scope:
1207
+ any:
1208
+ - kind: statement_block
1209
+ - kind: function_declaration
1210
+ - kind: generator_function_declaration
1211
+ - kind: function_expression
1212
+ - kind: generator_function
1213
+ - kind: arrow_function
1214
+ - kind: method_definition
1215
+ - kind: class_body
1216
+ - kind: for_statement
1217
+ - kind: for_in_statement
1218
+ - kind: catch_clause
1219
+ # An identifier in a binding position: a parameter, a destructured name, a
1220
+ # local variable, a function name, or a class name.
1221
+ binding-name:
1222
+ any:
1223
+ - kind: shorthand_property_identifier_pattern
1224
+ - kind: identifier
1225
+ any:
1226
+ - inside: { kind: variable_declarator, field: name }
1227
+ - inside: { kind: function_declaration, field: name }
1228
+ - inside: { kind: generator_function_declaration, field: name }
1229
+ - inside: { kind: function_expression, field: name }
1230
+ - inside: { kind: required_parameter, field: pattern }
1231
+ - inside: { kind: optional_parameter, field: pattern }
1232
+ - inside: { kind: assignment_pattern, field: left }
1233
+ - inside: { kind: pair_pattern, field: value }
1234
+ - inside: { kind: array_pattern }
1235
+ - inside: { kind: rest_pattern }
1236
+ - inside: { kind: arrow_function, field: parameter }
1237
+ - inside: { kind: catch_clause, field: parameter }
1238
+ - kind: type_identifier
1239
+ inside: { kind: class_declaration, field: name }
1240
+ # A function declaration opens a scope, so the search above stops at it and
1241
+ # never reads its name. This matches the declaration itself instead.
1242
+ function-declaration:
1243
+ any:
1244
+ - kind: function_declaration
1245
+ - kind: generator_function_declaration
1246
+ button-import:
1247
+ kind: import_statement
1248
+ all:
1249
+ - has:
1250
+ field: source
1251
+ regex: ^["']@ngrok/mantle/button["']$
1252
+ - has:
1253
+ stopBy: end
1254
+ kind: import_specifier
1255
+ has:
1256
+ field: name
1257
+ regex: ^Button$
1258
+ any:
1259
+ - kind: import_specifier
1260
+ has:
1261
+ field: alias
1262
+ pattern: $BUTTON
1263
+ - kind: import_specifier
1264
+ not:
1265
+ has:
1266
+ field: alias
1267
+ kind: identifier
1268
+ has:
1269
+ field: name
1270
+ pattern: $BUTTON
1271
+ button-element:
1272
+ any:
1273
+ - kind: jsx_opening_element
1274
+ - kind: jsx_self_closing_element
1275
+ # Why all: the name binds the metavariable, and the import must read it.
1276
+ all:
1277
+ - has:
1278
+ field: name
1279
+ kind: identifier
1280
+ pattern: $BUTTON
1281
+ - inside:
1282
+ stopBy: end
1283
+ kind: program
1284
+ has:
1285
+ matches: button-import
1286
+ # Why: a parameter or a local under the import's name shadows it, and the
1287
+ # rules cannot tell which binding the element reads.
1288
+ - not:
1289
+ inside:
1290
+ stopBy: end
1291
+ matches: scope
1292
+ has:
1293
+ stopBy:
1294
+ matches: scope
1295
+ any:
1296
+ - matches: binding-name
1297
+ pattern: $BUTTON
1298
+ - matches: function-declaration
1299
+ has:
1300
+ field: name
1301
+ pattern: $BUTTON
1302
+ has-tone:
1303
+ kind: jsx_attribute
1304
+ has:
1305
+ kind: property_identifier
1306
+ regex: ^(priority|intent)$
1307
+ appearance-filled:
1308
+ kind: jsx_attribute
1309
+ has:
1310
+ kind: property_identifier
1311
+ regex: ^appearance$
1312
+ any:
1313
+ - kind: jsx_attribute
1314
+ has:
1315
+ kind: string
1316
+ regex: ^["']filled["']$
1317
+ - kind: jsx_attribute
1318
+ has:
1319
+ kind: jsx_expression
1320
+ has:
1321
+ kind: string
1322
+ regex: ^["']filled["']$
1323
+ # A static appearance other than filled. A dynamic one stays manual, because
1324
+ # the old implicit intent depended on the value.
1325
+ appearance-static-not-filled:
1326
+ kind: jsx_attribute
1327
+ has:
1328
+ kind: property_identifier
1329
+ regex: ^appearance$
1330
+ any:
1331
+ - kind: jsx_attribute
1332
+ has:
1333
+ kind: string
1334
+ - kind: jsx_attribute
1335
+ has:
1336
+ kind: jsx_expression
1337
+ has:
1338
+ kind: string
1339
+ not:
1340
+ matches: appearance-filled
1341
+ rule:
1342
+ kind: identifier
1343
+ pattern: $BUTTON
1344
+ inside:
1345
+ matches: button-element
1346
+ all:
1347
+ - has:
1348
+ matches: appearance-static-not-filled
1349
+ - not:
1350
+ has:
1351
+ matches: has-tone
1352
+ fix: $BUTTON intent="accent"
1353
+ ---
1354
+ id: icon-button-bare
1355
+ language: tsx
1356
+ message: a bare IconButton was outlined and neutral
1357
+ utils:
1358
+ # A node that opens a lexical scope. The shadow search below stops at a
1359
+ # nested one, so a sibling function's local name does not count.
1360
+ scope:
1361
+ any:
1362
+ - kind: statement_block
1363
+ - kind: function_declaration
1364
+ - kind: generator_function_declaration
1365
+ - kind: function_expression
1366
+ - kind: generator_function
1367
+ - kind: arrow_function
1368
+ - kind: method_definition
1369
+ - kind: class_body
1370
+ - kind: for_statement
1371
+ - kind: for_in_statement
1372
+ - kind: catch_clause
1373
+ # An identifier in a binding position: a parameter, a destructured name, a
1374
+ # local variable, a function name, or a class name.
1375
+ binding-name:
1376
+ any:
1377
+ - kind: shorthand_property_identifier_pattern
1378
+ - kind: identifier
1379
+ any:
1380
+ - inside: { kind: variable_declarator, field: name }
1381
+ - inside: { kind: function_declaration, field: name }
1382
+ - inside: { kind: generator_function_declaration, field: name }
1383
+ - inside: { kind: function_expression, field: name }
1384
+ - inside: { kind: required_parameter, field: pattern }
1385
+ - inside: { kind: optional_parameter, field: pattern }
1386
+ - inside: { kind: assignment_pattern, field: left }
1387
+ - inside: { kind: pair_pattern, field: value }
1388
+ - inside: { kind: array_pattern }
1389
+ - inside: { kind: rest_pattern }
1390
+ - inside: { kind: arrow_function, field: parameter }
1391
+ - inside: { kind: catch_clause, field: parameter }
1392
+ - kind: type_identifier
1393
+ inside: { kind: class_declaration, field: name }
1394
+ # A function declaration opens a scope, so the search above stops at it and
1395
+ # never reads its name. This matches the declaration itself instead.
1396
+ function-declaration:
1397
+ any:
1398
+ - kind: function_declaration
1399
+ - kind: generator_function_declaration
1400
+ iconbutton-import:
1401
+ kind: import_statement
1402
+ all:
1403
+ - has:
1404
+ field: source
1405
+ regex: ^["']@ngrok/mantle/button["']$
1406
+ - has:
1407
+ stopBy: end
1408
+ kind: import_specifier
1409
+ has:
1410
+ field: name
1411
+ regex: ^IconButton$
1412
+ any:
1413
+ - kind: import_specifier
1414
+ has:
1415
+ field: alias
1416
+ pattern: $ICON_BUTTON
1417
+ - kind: import_specifier
1418
+ not:
1419
+ has:
1420
+ field: alias
1421
+ kind: identifier
1422
+ has:
1423
+ field: name
1424
+ pattern: $ICON_BUTTON
1425
+ icon-button-element:
1426
+ any:
1427
+ - kind: jsx_opening_element
1428
+ - kind: jsx_self_closing_element
1429
+ # Why all: the name binds the metavariable, and the import must read it.
1430
+ all:
1431
+ - has:
1432
+ field: name
1433
+ kind: identifier
1434
+ pattern: $ICON_BUTTON
1435
+ - inside:
1436
+ stopBy: end
1437
+ kind: program
1438
+ has:
1439
+ matches: iconbutton-import
1440
+ # Why: a parameter or a local under the import's name shadows it, and the
1441
+ # rules cannot tell which binding the element reads.
1442
+ - not:
1443
+ inside:
1444
+ stopBy: end
1445
+ matches: scope
1446
+ has:
1447
+ stopBy:
1448
+ matches: scope
1449
+ any:
1450
+ - matches: binding-name
1451
+ pattern: $ICON_BUTTON
1452
+ - matches: function-declaration
1453
+ has:
1454
+ field: name
1455
+ pattern: $ICON_BUTTON
1456
+ has-tone:
1457
+ kind: jsx_attribute
1458
+ has:
1459
+ kind: property_identifier
1460
+ regex: ^(priority|intent)$
1461
+ has-appearance:
1462
+ kind: jsx_attribute
1463
+ has:
1464
+ kind: property_identifier
1465
+ regex: ^appearance$
1466
+ rule:
1467
+ kind: identifier
1468
+ pattern: $ICON_BUTTON
1469
+ inside:
1470
+ matches: icon-button-element
1471
+ all:
1472
+ - not:
1473
+ has:
1474
+ matches: has-appearance
1475
+ - not:
1476
+ has:
1477
+ matches: has-tone
1478
+ fix: $ICON_BUTTON appearance="outlined" intent="neutral"
1479
+ ---
1480
+ id: icon-button-tone-only
1481
+ language: tsx
1482
+ message: an IconButton with a tone and no appearance was outlined
1483
+ utils:
1484
+ # A node that opens a lexical scope. The shadow search below stops at a
1485
+ # nested one, so a sibling function's local name does not count.
1486
+ scope:
1487
+ any:
1488
+ - kind: statement_block
1489
+ - kind: function_declaration
1490
+ - kind: generator_function_declaration
1491
+ - kind: function_expression
1492
+ - kind: generator_function
1493
+ - kind: arrow_function
1494
+ - kind: method_definition
1495
+ - kind: class_body
1496
+ - kind: for_statement
1497
+ - kind: for_in_statement
1498
+ - kind: catch_clause
1499
+ # An identifier in a binding position: a parameter, a destructured name, a
1500
+ # local variable, a function name, or a class name.
1501
+ binding-name:
1502
+ any:
1503
+ - kind: shorthand_property_identifier_pattern
1504
+ - kind: identifier
1505
+ any:
1506
+ - inside: { kind: variable_declarator, field: name }
1507
+ - inside: { kind: function_declaration, field: name }
1508
+ - inside: { kind: generator_function_declaration, field: name }
1509
+ - inside: { kind: function_expression, field: name }
1510
+ - inside: { kind: required_parameter, field: pattern }
1511
+ - inside: { kind: optional_parameter, field: pattern }
1512
+ - inside: { kind: assignment_pattern, field: left }
1513
+ - inside: { kind: pair_pattern, field: value }
1514
+ - inside: { kind: array_pattern }
1515
+ - inside: { kind: rest_pattern }
1516
+ - inside: { kind: arrow_function, field: parameter }
1517
+ - inside: { kind: catch_clause, field: parameter }
1518
+ - kind: type_identifier
1519
+ inside: { kind: class_declaration, field: name }
1520
+ # A function declaration opens a scope, so the search above stops at it and
1521
+ # never reads its name. This matches the declaration itself instead.
1522
+ function-declaration:
1523
+ any:
1524
+ - kind: function_declaration
1525
+ - kind: generator_function_declaration
1526
+ iconbutton-import:
1527
+ kind: import_statement
1528
+ all:
1529
+ - has:
1530
+ field: source
1531
+ regex: ^["']@ngrok/mantle/button["']$
1532
+ - has:
1533
+ stopBy: end
1534
+ kind: import_specifier
1535
+ has:
1536
+ field: name
1537
+ regex: ^IconButton$
1538
+ any:
1539
+ - kind: import_specifier
1540
+ has:
1541
+ field: alias
1542
+ pattern: $ICON_BUTTON
1543
+ - kind: import_specifier
1544
+ not:
1545
+ has:
1546
+ field: alias
1547
+ kind: identifier
1548
+ has:
1549
+ field: name
1550
+ pattern: $ICON_BUTTON
1551
+ icon-button-element:
1552
+ any:
1553
+ - kind: jsx_opening_element
1554
+ - kind: jsx_self_closing_element
1555
+ # Why all: the name binds the metavariable, and the import must read it.
1556
+ all:
1557
+ - has:
1558
+ field: name
1559
+ kind: identifier
1560
+ pattern: $ICON_BUTTON
1561
+ - inside:
1562
+ stopBy: end
1563
+ kind: program
1564
+ has:
1565
+ matches: iconbutton-import
1566
+ # Why: a parameter or a local under the import's name shadows it, and the
1567
+ # rules cannot tell which binding the element reads.
1568
+ - not:
1569
+ inside:
1570
+ stopBy: end
1571
+ matches: scope
1572
+ has:
1573
+ stopBy:
1574
+ matches: scope
1575
+ any:
1576
+ - matches: binding-name
1577
+ pattern: $ICON_BUTTON
1578
+ - matches: function-declaration
1579
+ has:
1580
+ field: name
1581
+ pattern: $ICON_BUTTON
1582
+ has-tone:
1583
+ kind: jsx_attribute
1584
+ has:
1585
+ kind: property_identifier
1586
+ regex: ^(priority|intent)$
1587
+ has-appearance:
1588
+ kind: jsx_attribute
1589
+ has:
1590
+ kind: property_identifier
1591
+ regex: ^appearance$
1592
+ rule:
1593
+ kind: identifier
1594
+ pattern: $ICON_BUTTON
1595
+ inside:
1596
+ matches: icon-button-element
1597
+ all:
1598
+ - not:
1599
+ has:
1600
+ matches: has-appearance
1601
+ - has:
1602
+ matches: has-tone
1603
+ fix: $ICON_BUTTON appearance="outlined"
1604
+ ---
1605
+ id: icon-button-appearance-no-tone
1606
+ language: tsx
1607
+ message: an IconButton with an appearance and no tone was neutral
1608
+ utils:
1609
+ # A node that opens a lexical scope. The shadow search below stops at a
1610
+ # nested one, so a sibling function's local name does not count.
1611
+ scope:
1612
+ any:
1613
+ - kind: statement_block
1614
+ - kind: function_declaration
1615
+ - kind: generator_function_declaration
1616
+ - kind: function_expression
1617
+ - kind: generator_function
1618
+ - kind: arrow_function
1619
+ - kind: method_definition
1620
+ - kind: class_body
1621
+ - kind: for_statement
1622
+ - kind: for_in_statement
1623
+ - kind: catch_clause
1624
+ # An identifier in a binding position: a parameter, a destructured name, a
1625
+ # local variable, a function name, or a class name.
1626
+ binding-name:
1627
+ any:
1628
+ - kind: shorthand_property_identifier_pattern
1629
+ - kind: identifier
1630
+ any:
1631
+ - inside: { kind: variable_declarator, field: name }
1632
+ - inside: { kind: function_declaration, field: name }
1633
+ - inside: { kind: generator_function_declaration, field: name }
1634
+ - inside: { kind: function_expression, field: name }
1635
+ - inside: { kind: required_parameter, field: pattern }
1636
+ - inside: { kind: optional_parameter, field: pattern }
1637
+ - inside: { kind: assignment_pattern, field: left }
1638
+ - inside: { kind: pair_pattern, field: value }
1639
+ - inside: { kind: array_pattern }
1640
+ - inside: { kind: rest_pattern }
1641
+ - inside: { kind: arrow_function, field: parameter }
1642
+ - inside: { kind: catch_clause, field: parameter }
1643
+ - kind: type_identifier
1644
+ inside: { kind: class_declaration, field: name }
1645
+ # A function declaration opens a scope, so the search above stops at it and
1646
+ # never reads its name. This matches the declaration itself instead.
1647
+ function-declaration:
1648
+ any:
1649
+ - kind: function_declaration
1650
+ - kind: generator_function_declaration
1651
+ iconbutton-import:
1652
+ kind: import_statement
1653
+ all:
1654
+ - has:
1655
+ field: source
1656
+ regex: ^["']@ngrok/mantle/button["']$
1657
+ - has:
1658
+ stopBy: end
1659
+ kind: import_specifier
1660
+ has:
1661
+ field: name
1662
+ regex: ^IconButton$
1663
+ any:
1664
+ - kind: import_specifier
1665
+ has:
1666
+ field: alias
1667
+ pattern: $ICON_BUTTON
1668
+ - kind: import_specifier
1669
+ not:
1670
+ has:
1671
+ field: alias
1672
+ kind: identifier
1673
+ has:
1674
+ field: name
1675
+ pattern: $ICON_BUTTON
1676
+ icon-button-element:
1677
+ any:
1678
+ - kind: jsx_opening_element
1679
+ - kind: jsx_self_closing_element
1680
+ # Why all: the name binds the metavariable, and the import must read it.
1681
+ all:
1682
+ - has:
1683
+ field: name
1684
+ kind: identifier
1685
+ pattern: $ICON_BUTTON
1686
+ - inside:
1687
+ stopBy: end
1688
+ kind: program
1689
+ has:
1690
+ matches: iconbutton-import
1691
+ # Why: a parameter or a local under the import's name shadows it, and the
1692
+ # rules cannot tell which binding the element reads.
1693
+ - not:
1694
+ inside:
1695
+ stopBy: end
1696
+ matches: scope
1697
+ has:
1698
+ stopBy:
1699
+ matches: scope
1700
+ any:
1701
+ - matches: binding-name
1702
+ pattern: $ICON_BUTTON
1703
+ - matches: function-declaration
1704
+ has:
1705
+ field: name
1706
+ pattern: $ICON_BUTTON
1707
+ has-tone:
1708
+ kind: jsx_attribute
1709
+ has:
1710
+ kind: property_identifier
1711
+ regex: ^(priority|intent)$
1712
+ has-appearance:
1713
+ kind: jsx_attribute
1714
+ has:
1715
+ kind: property_identifier
1716
+ regex: ^appearance$
1717
+ rule:
1718
+ kind: identifier
1719
+ pattern: $ICON_BUTTON
1720
+ inside:
1721
+ matches: icon-button-element
1722
+ all:
1723
+ - has:
1724
+ matches: has-appearance
1725
+ - not:
1726
+ has:
1727
+ matches: has-tone
1728
+ fix: $ICON_BUTTON intent="neutral"