@nldd/design-system 0.26.1 → 0.26.2

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 (480) hide show
  1. package/custom-elements.json +4559 -1176
  2. package/dist/cdn/autoloader.js +141 -141
  3. package/dist/cdn/chunks/{accordion-DA4IlxS5.js → accordion-CCuKxlsg.js} +6 -6
  4. package/dist/cdn/chunks/{accordion-item-Ca1o93cq.js → accordion-item-Cn1UDWtD.js} +7 -7
  5. package/dist/cdn/chunks/{activity-indicator-Cj4H0Mbz.js → activity-indicator-BM_atCTY.js} +13 -13
  6. package/dist/cdn/chunks/{admonition-CdZSoO8O.js → admonition-CqDce27_.js} +11 -11
  7. package/dist/cdn/chunks/{avatar-Dhqn-Dmv.js → avatar-Dl2tOfc2.js} +18 -18
  8. package/dist/cdn/chunks/{avatar-group-B017eF-u.js → avatar-group-Br3qBaow.js} +42 -40
  9. package/dist/cdn/chunks/{badge-Bep5B0_g.js → badge-DjjAl4mn.js} +15 -15
  10. package/dist/cdn/chunks/{banner-DGpIXuE2.js → banner-s5xMqoEU.js} +16 -16
  11. package/dist/cdn/chunks/{bar-split-view-CKwJxd3e.js → bar-split-view-B6Mv_cw-.js} +8 -8
  12. package/dist/cdn/chunks/{blockquote-ChMgaOuI.js → blockquote-CRFPXI9u.js} +8 -8
  13. package/dist/cdn/chunks/{box-BRmziG-6.js → box-CSZyj31o.js} +5 -5
  14. package/dist/cdn/chunks/{breadcrumbs-BeVO8bkQ.js → breadcrumbs-DzjbOB7o.js} +13 -13
  15. package/dist/cdn/chunks/{button-cHBkq_s7.js → button-B7OGt_dX.js} +53 -54
  16. package/dist/cdn/chunks/{button-bar-CLxOdalJ.js → button-bar-CvDkir22.js} +8 -8
  17. package/dist/cdn/chunks/{button-group-BIvKtEIX.js → button-group-Bi3dr9Go.js} +6 -6
  18. package/dist/cdn/chunks/{card-B5gp9Zly.js → card-DceO3pMp.js} +10 -10
  19. package/dist/cdn/chunks/{cell-D4Nrd5Z9.js → cell-Bgp9n0yQ.js} +13 -13
  20. package/dist/cdn/chunks/{checkbox-CeLTJhAc.js → checkbox-C1F0Q3g8.js} +26 -43
  21. package/dist/cdn/chunks/{checkbox-field-C8cU8fuf.js → checkbox-field-DGKc530M.js} +35 -43
  22. package/dist/cdn/chunks/checkbox-group-x9Ua2a06.js +91 -0
  23. package/dist/cdn/chunks/choice-group-AZsqoheP.js +64 -0
  24. package/dist/cdn/chunks/{class-map-xzscTu4B.js → class-map-CAVKoa31.js} +1 -1
  25. package/dist/cdn/chunks/{code-editor-BNhlXTSl.js → code-editor-C0U5qVW2.js} +11 -11
  26. package/dist/cdn/chunks/{code-viewer-D_JwouYO.js → code-viewer-C_DzKPSv.js} +17 -17
  27. package/dist/cdn/chunks/{codemirror-input-DJ0wgYrc.js → codemirror-input-BmIE22aU.js} +5 -5
  28. package/dist/cdn/chunks/{collection-BXvz_OtU.js → collection-BZK9NzrQ.js} +19 -19
  29. package/dist/cdn/chunks/{combo-box-8kbmoStb.js → combo-box-DJrQ-2Wr.js} +69 -87
  30. package/dist/cdn/chunks/{container-Dq-2uHd5.js → container-BT96Wlz6.js} +48 -48
  31. package/dist/cdn/chunks/{custom-element-DeaCQ2NP.js → custom-element-D5bstafw.js} +2 -2
  32. package/dist/cdn/chunks/{date-field-CQg1_73u.js → date-field-B8GcDwkD.js} +33 -40
  33. package/dist/cdn/chunks/{date-picker-CTMxGOiA.js → date-picker-Byi-fA0A.js} +17 -17
  34. package/dist/cdn/chunks/{decorate-CCYde2ES.js → decorate-Cjb3GqlZ.js} +1 -1
  35. package/dist/cdn/chunks/deep-active-element-DgiHjYGG.js +7 -0
  36. package/dist/cdn/chunks/{described-by-mixin-BYFim7aO.js → described-by-mixin-ZWpyWEyB.js} +2 -2
  37. package/dist/cdn/chunks/{description-cell-GcVeCz2_.js → description-cell-DRXRiZGw.js} +12 -12
  38. package/dist/cdn/chunks/{dev-checks-CSlbfDuF.js → dev-checks-BYWMWeug.js} +931 -931
  39. package/dist/cdn/chunks/{directive-helpers-DgaADFyY.js → directive-helpers-mh9SNf0j.js} +1 -1
  40. package/dist/cdn/chunks/{dist-5vPsM2aV.js → dist-1yCEk2Pe.js} +1 -1
  41. package/dist/cdn/chunks/{dist-1OQdP4ho.js → dist-BBtyEGZQ.js} +3 -3
  42. package/dist/cdn/chunks/{dist-Da_liXcd.js → dist-BIhRNYZs.js} +3 -3
  43. package/dist/cdn/chunks/{dist-B23jHvJ5.js → dist-BfJ8w6Dz.js} +1 -1
  44. package/dist/cdn/chunks/{dist-CcpLhc4y.js → dist-BlHWe6Ns.js} +1 -1
  45. package/dist/cdn/chunks/{dist-VCymi0hs.js → dist-C4o16iKF.js} +1 -1
  46. package/dist/cdn/chunks/{dist-CyDpBAaD.js → dist-CKGgPGjj.js} +2 -2
  47. package/dist/cdn/chunks/{dist-CNy2sPTt.js → dist-CT0CdAxb.js} +2 -2
  48. package/dist/cdn/chunks/{dist-D4SViUJx.js → dist-DCzCfm9V.js} +1 -1
  49. package/dist/cdn/chunks/{dist-DLtwMUDc.js → dist-iYv1GHSb.js} +2 -2
  50. package/dist/cdn/chunks/{dist-DBxjWahH.js → dist-jyyZH0d2.js} +1 -1
  51. package/dist/cdn/chunks/{divider-8XD3xTbl.js → divider-CeAw8gBP.js} +2 -2
  52. package/dist/cdn/chunks/{document-tab-bar-RBAmckHS.js → document-tab-bar-rIsC6EZp.js} +32 -46
  53. package/dist/cdn/chunks/{dropdown-DVlxPcjr.js → dropdown-MEzKo0TQ.js} +14 -14
  54. package/dist/cdn/chunks/{file-field-BrHnFplX.js → file-field--wivtgZv.js} +42 -40
  55. package/dist/cdn/chunks/{form-DGHeGEIr.js → form-ByjlUZuR.js} +1 -1
  56. package/dist/cdn/chunks/{form-actions-CHwWKfMM.js → form-actions-YK7n_jse.js} +4 -4
  57. package/dist/cdn/chunks/form-associated-mixin-BCzChLUO.js +123 -0
  58. package/dist/cdn/chunks/{form-field-CdTSI-8h.js → form-field-y-h-k8x5.js} +11 -11
  59. package/dist/cdn/chunks/{form-section-CjECOIiZ.js → form-section-jWj88aQa.js} +1 -1
  60. package/dist/cdn/chunks/{full-bleed-section-CQgq4iGQ.js → full-bleed-section-h6CrFe8F.js} +5 -5
  61. package/dist/cdn/chunks/{hero-DhdcYt2N.js → hero-Dy1tW9gU.js} +19 -19
  62. package/dist/cdn/chunks/{icon-button-DT_Bi4Ac.js → icon-button-B0Lb2ccT.js} +37 -38
  63. package/dist/cdn/chunks/{icon-cell-C-qrZAlN.js → icon-cell-byBTzcEn.js} +10 -10
  64. package/dist/cdn/chunks/{icon-qpmEfU9B.js → icon-m8JXbN5F.js} +8 -8
  65. package/dist/cdn/chunks/{identity-DFmvuPkl.js → identity-BpUMGka9.js} +12 -12
  66. package/dist/cdn/chunks/{if-defined-BINBE69I.js → if-defined-Duzrh8bb.js} +1 -1
  67. package/dist/cdn/chunks/{image-B4M3h1xJ.js → image-DfpFBPj1.js} +21 -21
  68. package/dist/cdn/chunks/{inline-dialog-L-NvjANF.js → inline-dialog-D6CMJnYk.js} +16 -16
  69. package/dist/cdn/chunks/interest-intent-Bk3i_upv.js +63 -0
  70. package/dist/cdn/chunks/{interest-controller-Ban-3NrX.js → interest-invoker-BY95Duqo.js} +28 -38
  71. package/dist/cdn/chunks/{just-in-time-education-CWplH4r9.js → just-in-time-education-_1kTZuGb.js} +13 -13
  72. package/dist/cdn/chunks/{kanban-B6Wa-2aM.js → kanban-DFGaEwfP.js} +25 -29
  73. package/dist/cdn/chunks/{kanban-column-D2-Xq79_.js → kanban-column-Cs47JSUO.js} +10 -10
  74. package/dist/cdn/chunks/{keyboard-shortcut-Ci95olxF.js → keyboard-shortcut-4DPqQovv.js} +13 -13
  75. package/dist/cdn/chunks/{languages-C9AGuuSS.js → languages-D-97TsxL.js} +12 -12
  76. package/dist/cdn/chunks/{link-BJB2a_fG.js → link-6T0VtDWt.js} +18 -18
  77. package/dist/cdn/chunks/{link-group-aNoedLZo.js → link-group-ymcl82Ua.js} +7 -7
  78. package/dist/cdn/chunks/{list-CZWX62tH.js → list-BXpR0UzC.js} +110 -95
  79. package/dist/cdn/chunks/{list-item-DHzsbK_S.js → list-item-CyZ6uPGG.js} +50 -29
  80. package/dist/cdn/chunks/{list-item-segment-CHLlU9Gg.js → list-item-segment-BUtAy96X.js} +23 -20
  81. package/dist/cdn/chunks/{menu-bar-CJazkmY7.js → menu-bar-Cn1Nb2ir.js} +59 -60
  82. package/dist/cdn/chunks/{menu-bar-item-CSqXWNKE.js → menu-bar-item-CZR2qAzA.js} +35 -35
  83. package/dist/cdn/chunks/{menu-divider-Cn1hTpcM.js → menu-divider-dF1NvFJO.js} +3 -3
  84. package/dist/cdn/chunks/{menu-group-C71K1Vmv.js → menu-group-DW3so0Dn.js} +4 -4
  85. package/dist/cdn/chunks/{menu-item-TqBlQfI2.js → menu-item-7kb18Ypf.js} +4 -4
  86. package/dist/cdn/chunks/{menu-NGpB1SKq.js → menu-kSZLzjet.js} +101 -93
  87. package/dist/cdn/chunks/{menu.template-DthELYky.js → menu.template-cgua9dKM.js} +4 -4
  88. package/dist/cdn/chunks/{modal-dialog-0V2HsrJC.js → modal-dialog-DfKbcw9T.js} +28 -78
  89. package/dist/cdn/chunks/modal-overlay-Bx0bYzF3.js +95 -0
  90. package/dist/cdn/chunks/{multi-line-text-field-BV4uUDoK.js → multi-line-text-field-AV-vID1z.js} +28 -45
  91. package/dist/cdn/chunks/{navigation-split-view-tPhkxEVD.js → navigation-split-view-UwlSFPDE.js} +10 -10
  92. package/dist/cdn/chunks/{notification-CZccv6qx.js → notification-e5uGGh0b.js} +12 -12
  93. package/dist/cdn/chunks/{number-field-4R2blHda.js → number-field-COUmvl_s.js} +26 -32
  94. package/dist/cdn/chunks/{one-half-one-half-section-h2fLPQfP.js → one-half-one-half-section-C-AgSdm9.js} +6 -6
  95. package/dist/cdn/chunks/{one-third-two-thirds-section-mqUAH5lK.js → one-third-two-thirds-section-D1kq4IEc.js} +6 -6
  96. package/dist/cdn/chunks/{one-time-code-field-Bf_qymKd.js → one-time-code-field-BDQctC8H.js} +25 -38
  97. package/dist/cdn/chunks/overflow-menu-C67lAkP8.js +83 -0
  98. package/dist/cdn/chunks/overlay-invoker-CQpe-JGA.js +95 -0
  99. package/dist/cdn/chunks/{page-Kipfvmi6.js → page-DXEaFsfo.js} +11 -11
  100. package/dist/cdn/chunks/{page-footer-DxE966Oe.js → page-footer-DFaIlgHs.js} +13 -13
  101. package/dist/cdn/chunks/{page-section-mixin-DpF9JDpd.js → page-section-mixin-3XhS4f5q.js} +21 -21
  102. package/dist/cdn/chunks/{pagination-DUFFhaU8.js → pagination-BE3ERBNx.js} +13 -13
  103. package/dist/cdn/chunks/{password-field-DdYAVmF3.js → password-field-DjRp78HI.js} +28 -45
  104. package/dist/cdn/chunks/{popover-CRHxyhGx.js → popover-C3j0KtFh.js} +55 -64
  105. package/dist/cdn/chunks/{progress-bar-BuYsjmSo.js → progress-bar-iWFq6KS1.js} +26 -26
  106. package/dist/cdn/chunks/{progress-circle-Cvu1bfNG.js → progress-circle-BPFzTlhn.js} +24 -24
  107. package/dist/cdn/chunks/{radio-button-B_4AxWDx.js → radio-button-BMVBbe3-.js} +17 -26
  108. package/dist/cdn/chunks/{radio-button-field-D7jIg6Oi.js → radio-button-field-BqSd0JMd.js} +29 -37
  109. package/dist/cdn/chunks/radio-button-group-DZTPflZ3.js +112 -0
  110. package/dist/cdn/chunks/{render-marked-CIuiSS_8.js → render-marked-1xftlCd8.js} +1 -1
  111. package/dist/cdn/chunks/{reorder-handle-cell-DNPaZjSC.js → reorder-handle-cell-loSG6GRY.js} +7 -7
  112. package/dist/cdn/chunks/{reorder-handle-mixin-CgvWq4fF.js → reorder-handle-mixin-cLWXCdFC.js} +2 -2
  113. package/dist/cdn/chunks/{repeat-DfVuWl6o.js → repeat-CWsNVfra.js} +2 -2
  114. package/dist/cdn/chunks/{return-focus-D0fF2hjd.js → return-focus-CpwHVxYU.js} +10 -14
  115. package/dist/cdn/chunks/{rich-text-CVHlMQY6.js → rich-text-DSvI9u6v.js} +3 -3
  116. package/dist/cdn/chunks/{row-header-mixin-B25JK2B3.js → row-header-mixin-vwABKkTO.js} +2 -2
  117. package/dist/cdn/chunks/{scroll-fade-Dv57rTww.js → scroll-fade-ZNdnDF4p.js} +4 -4
  118. package/dist/cdn/chunks/{search-field-hmD_DXbG.js → search-field-CBTir8Wu.js} +33 -58
  119. package/dist/cdn/chunks/{segmented-control-e8e-jYSw.js → segmented-control-hvWn3L0J.js} +92 -103
  120. package/dist/cdn/chunks/{shadow-resets-CRdvf-Ei.js → shadow-resets-JiVlctXb.js} +2 -2
  121. package/dist/cdn/chunks/{sheet-D09y3J45.js → sheet-CnbdONF9.js} +39 -90
  122. package/dist/cdn/chunks/{shell-CV3gooGg.js → shell-BAH9okPd.js} +5 -5
  123. package/dist/cdn/chunks/{side-by-side-split-view-Ckz1C9zk.js → side-by-side-split-view-D07iBCFK.js} +8 -8
  124. package/dist/cdn/chunks/{sidebar-section-CdyD-x4t.js → sidebar-section-DAE2lrdn.js} +14 -14
  125. package/dist/cdn/chunks/{simple-section-CEf38rBZ.js → simple-section-DQZpG3nQ.js} +7 -7
  126. package/dist/cdn/chunks/{skip-link-DMRhATWw.js → skip-link-D0yYukhb.js} +7 -7
  127. package/dist/cdn/chunks/{slider-Db3FPiP6.js → slider-C-a97cAu.js} +30 -37
  128. package/dist/cdn/chunks/{spacer-BPFIYueo.js → spacer-C19W6HrX.js} +8 -8
  129. package/dist/cdn/chunks/{spacer-cell-kITa3CDV.js → spacer-cell-lRxkFSnp.js} +6 -6
  130. package/dist/cdn/chunks/{split-button-CJs9-Nha.js → split-button-38xSIAVk.js} +21 -21
  131. package/dist/cdn/chunks/{split-view-divider-lHlM1Ss8.js → split-view-divider-CViSo7s7.js} +5 -5
  132. package/dist/cdn/chunks/{split-view-pane-DlsbZtyo.js → split-view-pane-Bb1RFCNJ.js} +7 -7
  133. package/dist/cdn/chunks/{stacked-split-view-uRSVhrMd.js → stacked-split-view-Bnw5hQ5A.js} +8 -8
  134. package/dist/cdn/chunks/{static-html-BahSPV_4.js → static-html-7PckS8pf.js} +1 -1
  135. package/dist/cdn/chunks/{status-bar-DCJLVpsW.js → status-bar-D57SEB_4.js} +8 -8
  136. package/dist/cdn/chunks/{step-bar-CRR2jiyo.js → step-bar-Q_wc0vqp.js} +18 -18
  137. package/dist/cdn/chunks/{step-cell-CbtKxJNJ.js → step-cell-DU6sNjnm.js} +15 -15
  138. package/dist/cdn/chunks/{stepper-Con1_CnB.js → stepper-BM1dp44g.js} +16 -26
  139. package/dist/cdn/chunks/{style-map-uOwLerwV.js → style-map-BRs_xiW6.js} +1 -1
  140. package/dist/cdn/chunks/{swatch-picker-Bqn0eaC9.js → swatch-picker-BcRbPWVv.js} +63 -69
  141. package/dist/cdn/chunks/{switch-CMQcLEBJ.js → switch-7BZAufN0.js} +25 -42
  142. package/dist/cdn/chunks/{switch-field-D9kWq4Kw.js → switch-field-gjPTIapp.js} +19 -32
  143. package/dist/cdn/chunks/{tab-bar-DXzyZI3V.js → tab-bar-BKzbb7TE.js} +34 -29
  144. package/dist/cdn/chunks/{table-CWACLpHx.js → table-CmkkY3M1.js} +15 -15
  145. package/dist/cdn/chunks/{tag-Bo4yJbtF.js → tag-B4VfItSH.js} +11 -11
  146. package/dist/cdn/chunks/{term-CQ379ZbN.js → term-C0aNyYXz.js} +42 -39
  147. package/dist/cdn/chunks/{text-D-dFoj6N.js → text-CLuHOFQt.js} +29 -29
  148. package/dist/cdn/chunks/{text-cell-Be1hStxp.js → text-cell-Dvujh580.js} +23 -23
  149. package/dist/cdn/chunks/{text-editor-BjzQEBWm.js → text-editor-0_ZoELkA.js} +12 -12
  150. package/dist/cdn/chunks/{text-field-DA8nirp6.js → text-field-CrRBrXx0.js} +28 -45
  151. package/dist/cdn/chunks/{time-field-Dd_TxJuf.js → time-field-DUt1zvLw.js} +66 -148
  152. package/dist/cdn/chunks/{time-picker-B0-rv1qp.js → time-picker-CDzillxF.js} +119 -40
  153. package/dist/cdn/chunks/{title-DOoPdG_i.js → title-DQXyEqFW.js} +12 -12
  154. package/dist/cdn/chunks/{title-cell-BzCNOMGr.js → title-cell-CoUK6h-F.js} +23 -23
  155. package/dist/cdn/chunks/{toggle-button-9PbDHviQ.js → toggle-button-BhU5vLF8.js} +41 -54
  156. package/dist/cdn/chunks/{toggle-button-group-C-H-xp0M.js → toggle-button-group-B-0r4xZZ.js} +40 -54
  157. package/dist/cdn/chunks/{token-CMKFC3gz.js → token-CELUzY2p.js} +31 -34
  158. package/dist/cdn/chunks/{token-field-D4-XHfnG.js → token-field-C8ynyISX.js} +67 -57
  159. package/dist/cdn/chunks/{toolbar-z9OhEE5l.js → toolbar--QBCm9qO.js} +34 -78
  160. package/dist/cdn/chunks/{toolbar-item-ZYoyKOyy.js → toolbar-item-BoRhKFDR.js} +3 -3
  161. package/dist/cdn/chunks/{toolbar-title-FKtQ8ZC4.js → toolbar-title-CciXdTJR.js} +4 -4
  162. package/dist/cdn/chunks/{toolbar.styles-DDjpdCHV.js → toolbar.styles-B6kTrAfC.js} +3 -3
  163. package/dist/cdn/chunks/{tooltip-BvRNYRo3.js → tooltip-CkLC4ooQ.js} +43 -41
  164. package/dist/cdn/chunks/{top-navigation-bar-BHPQntER.js → top-navigation-bar-CGu2pn4Z.js} +29 -29
  165. package/dist/cdn/chunks/{top-title-bar-BVjegLlh.js → top-title-bar-2b-XHftB.js} +15 -15
  166. package/dist/cdn/chunks/{translations-cJjO6nQV.js → translations-D0cgmONm.js} +1 -1
  167. package/dist/cdn/chunks/{two-thirds-one-third-section-BdBHQuXc.js → two-thirds-one-third-section-CEfd273Z.js} +6 -6
  168. package/dist/cdn/chunks/{validation-list-5E3-3_95.js → validation-list-DIFEVSIk.js} +12 -12
  169. package/dist/cdn/chunks/{visibility-mixin-DvRe3O8t.js → visibility-mixin-OjALtpXa.js} +14 -14
  170. package/dist/cdn/chunks/{visually-hidden-F85D_HcR.js → visually-hidden-DcpY5lun.js} +2 -2
  171. package/dist/cdn/chunks/{window-CabW35M1.js → window-BGZCu06O.js} +44 -80
  172. package/dist/cdn/chunks/{with-translations-BHDG37HJ.js → with-translations-DkNkjQym.js} +3 -3
  173. package/dist/components/actions/button/button.d.ts +4 -4
  174. package/dist/components/actions/button/button.d.ts.map +1 -1
  175. package/dist/components/actions/button/button.js +4 -5
  176. package/dist/components/actions/button/button.js.map +1 -1
  177. package/dist/components/actions/button/button.template.js +1 -1
  178. package/dist/components/actions/button/button.template.js.map +1 -1
  179. package/dist/components/actions/icon-button/icon-button.d.ts +4 -4
  180. package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
  181. package/dist/components/actions/icon-button/icon-button.js +4 -5
  182. package/dist/components/actions/icon-button/icon-button.js.map +1 -1
  183. package/dist/components/actions/icon-button/icon-button.template.js +1 -1
  184. package/dist/components/actions/icon-button/icon-button.template.js.map +1 -1
  185. package/dist/components/actions/menu/menu.d.ts +22 -6
  186. package/dist/components/actions/menu/menu.d.ts.map +1 -1
  187. package/dist/components/actions/menu/menu.js +50 -70
  188. package/dist/components/actions/menu/menu.js.map +1 -1
  189. package/dist/components/actions/split-button/split-button.js +1 -1
  190. package/dist/components/actions/split-button/split-button.js.map +1 -1
  191. package/dist/components/actions/toolbar/toolbar.d.ts +3 -3
  192. package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
  193. package/dist/components/actions/toolbar/toolbar.js +4 -4
  194. package/dist/components/actions/toolbar/toolbar.js.map +1 -1
  195. package/dist/components/actions/toolbar/toolbar.template.d.ts.map +1 -1
  196. package/dist/components/actions/toolbar/toolbar.template.js +5 -9
  197. package/dist/components/actions/toolbar/toolbar.template.js.map +1 -1
  198. package/dist/components/content/avatar-group/avatar-group.d.ts +7 -1
  199. package/dist/components/content/avatar-group/avatar-group.d.ts.map +1 -1
  200. package/dist/components/content/avatar-group/avatar-group.js +9 -9
  201. package/dist/components/content/avatar-group/avatar-group.js.map +1 -1
  202. package/dist/components/content/avatar-group/avatar-group.template.d.ts.map +1 -1
  203. package/dist/components/content/avatar-group/avatar-group.template.js +0 -1
  204. package/dist/components/content/avatar-group/avatar-group.template.js.map +1 -1
  205. package/dist/components/content/term/term.d.ts +5 -5
  206. package/dist/components/content/term/term.d.ts.map +1 -1
  207. package/dist/components/content/term/term.js +22 -23
  208. package/dist/components/content/term/term.js.map +1 -1
  209. package/dist/components/content/term/term.template.js +1 -1
  210. package/dist/components/content/term/term.template.js.map +1 -1
  211. package/dist/components/content/token/token.d.ts +3 -5
  212. package/dist/components/content/token/token.d.ts.map +1 -1
  213. package/dist/components/content/token/token.js +23 -33
  214. package/dist/components/content/token/token.js.map +1 -1
  215. package/dist/components/content/tooltip/tooltip.d.ts +3 -5
  216. package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
  217. package/dist/components/content/tooltip/tooltip.js +34 -119
  218. package/dist/components/content/tooltip/tooltip.js.map +1 -1
  219. package/dist/components/forms/form-field/form-field.d.ts.map +1 -1
  220. package/dist/components/forms/form-field/form-field.js +4 -1
  221. package/dist/components/forms/form-field/form-field.js.map +1 -1
  222. package/dist/components/inputs/checkbox/checkbox.d.ts +1 -4
  223. package/dist/components/inputs/checkbox/checkbox.d.ts.map +1 -1
  224. package/dist/components/inputs/checkbox/checkbox.js +3 -23
  225. package/dist/components/inputs/checkbox/checkbox.js.map +1 -1
  226. package/dist/components/inputs/checkbox-field/checkbox-field.d.ts +1 -5
  227. package/dist/components/inputs/checkbox-field/checkbox-field.d.ts.map +1 -1
  228. package/dist/components/inputs/checkbox-field/checkbox-field.js +8 -17
  229. package/dist/components/inputs/checkbox-field/checkbox-field.js.map +1 -1
  230. package/dist/components/inputs/checkbox-group/checkbox-group.d.ts +1 -9
  231. package/dist/components/inputs/checkbox-group/checkbox-group.d.ts.map +1 -1
  232. package/dist/components/inputs/checkbox-group/checkbox-group.js +18 -59
  233. package/dist/components/inputs/checkbox-group/checkbox-group.js.map +1 -1
  234. package/dist/components/inputs/combo-box/combo-box.d.ts +6 -7
  235. package/dist/components/inputs/combo-box/combo-box.d.ts.map +1 -1
  236. package/dist/components/inputs/combo-box/combo-box.js +25 -58
  237. package/dist/components/inputs/combo-box/combo-box.js.map +1 -1
  238. package/dist/components/inputs/date-field/date-field.d.ts +1 -2
  239. package/dist/components/inputs/date-field/date-field.d.ts.map +1 -1
  240. package/dist/components/inputs/date-field/date-field.js +4 -14
  241. package/dist/components/inputs/date-field/date-field.js.map +1 -1
  242. package/dist/components/inputs/file-field/file-field.d.ts +6 -3
  243. package/dist/components/inputs/file-field/file-field.d.ts.map +1 -1
  244. package/dist/components/inputs/file-field/file-field.js +15 -18
  245. package/dist/components/inputs/file-field/file-field.js.map +1 -1
  246. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.d.ts +1 -4
  247. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.d.ts.map +1 -1
  248. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js +3 -23
  249. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js.map +1 -1
  250. package/dist/components/inputs/number-field/number-field.d.ts +4 -3
  251. package/dist/components/inputs/number-field/number-field.d.ts.map +1 -1
  252. package/dist/components/inputs/number-field/number-field.js +12 -16
  253. package/dist/components/inputs/number-field/number-field.js.map +1 -1
  254. package/dist/components/inputs/one-time-code-field/one-time-code-field.d.ts +1 -4
  255. package/dist/components/inputs/one-time-code-field/one-time-code-field.d.ts.map +1 -1
  256. package/dist/components/inputs/one-time-code-field/one-time-code-field.js +2 -17
  257. package/dist/components/inputs/one-time-code-field/one-time-code-field.js.map +1 -1
  258. package/dist/components/inputs/password-field/password-field.d.ts +1 -4
  259. package/dist/components/inputs/password-field/password-field.d.ts.map +1 -1
  260. package/dist/components/inputs/password-field/password-field.js +3 -23
  261. package/dist/components/inputs/password-field/password-field.js.map +1 -1
  262. package/dist/components/inputs/radio-button/radio-button.d.ts +1 -4
  263. package/dist/components/inputs/radio-button/radio-button.d.ts.map +1 -1
  264. package/dist/components/inputs/radio-button/radio-button.js +1 -10
  265. package/dist/components/inputs/radio-button/radio-button.js.map +1 -1
  266. package/dist/components/inputs/radio-button-field/radio-button-field.d.ts +3 -6
  267. package/dist/components/inputs/radio-button-field/radio-button-field.d.ts.map +1 -1
  268. package/dist/components/inputs/radio-button-field/radio-button-field.js +6 -14
  269. package/dist/components/inputs/radio-button-field/radio-button-field.js.map +1 -1
  270. package/dist/components/inputs/radio-button-group/radio-button-group.d.ts +1 -10
  271. package/dist/components/inputs/radio-button-group/radio-button-group.d.ts.map +1 -1
  272. package/dist/components/inputs/radio-button-group/radio-button-group.js +17 -74
  273. package/dist/components/inputs/radio-button-group/radio-button-group.js.map +1 -1
  274. package/dist/components/inputs/search-field/search-field.d.ts +1 -4
  275. package/dist/components/inputs/search-field/search-field.d.ts.map +1 -1
  276. package/dist/components/inputs/search-field/search-field.js +5 -35
  277. package/dist/components/inputs/search-field/search-field.js.map +1 -1
  278. package/dist/components/inputs/segmented-control/segmented-control.d.ts +1 -3
  279. package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
  280. package/dist/components/inputs/segmented-control/segmented-control.js +6 -41
  281. package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
  282. package/dist/components/inputs/slider/slider.d.ts +1 -4
  283. package/dist/components/inputs/slider/slider.d.ts.map +1 -1
  284. package/dist/components/inputs/slider/slider.js +1 -14
  285. package/dist/components/inputs/slider/slider.js.map +1 -1
  286. package/dist/components/inputs/stepper/stepper.d.ts +1 -3
  287. package/dist/components/inputs/stepper/stepper.d.ts.map +1 -1
  288. package/dist/components/inputs/stepper/stepper.js +2 -13
  289. package/dist/components/inputs/stepper/stepper.js.map +1 -1
  290. package/dist/components/inputs/swatch-picker/swatch-picker.d.ts +1 -3
  291. package/dist/components/inputs/swatch-picker/swatch-picker.d.ts.map +1 -1
  292. package/dist/components/inputs/swatch-picker/swatch-picker.js +5 -28
  293. package/dist/components/inputs/swatch-picker/swatch-picker.js.map +1 -1
  294. package/dist/components/inputs/switch/switch.d.ts +1 -4
  295. package/dist/components/inputs/switch/switch.d.ts.map +1 -1
  296. package/dist/components/inputs/switch/switch.js +3 -22
  297. package/dist/components/inputs/switch/switch.js.map +1 -1
  298. package/dist/components/inputs/switch-field/switch-field.d.ts +1 -4
  299. package/dist/components/inputs/switch-field/switch-field.d.ts.map +1 -1
  300. package/dist/components/inputs/switch-field/switch-field.js +2 -16
  301. package/dist/components/inputs/switch-field/switch-field.js.map +1 -1
  302. package/dist/components/inputs/text-field/text-field.d.ts +1 -4
  303. package/dist/components/inputs/text-field/text-field.d.ts.map +1 -1
  304. package/dist/components/inputs/text-field/text-field.js +3 -23
  305. package/dist/components/inputs/text-field/text-field.js.map +1 -1
  306. package/dist/components/inputs/time-field/time-field.d.ts +8 -2
  307. package/dist/components/inputs/time-field/time-field.d.ts.map +1 -1
  308. package/dist/components/inputs/time-field/time-field.js +23 -14
  309. package/dist/components/inputs/time-field/time-field.js.map +1 -1
  310. package/dist/components/inputs/time-picker/time-picker.d.ts +11 -7
  311. package/dist/components/inputs/time-picker/time-picker.d.ts.map +1 -1
  312. package/dist/components/inputs/time-picker/time-picker.js +19 -14
  313. package/dist/components/inputs/time-picker/time-picker.js.map +1 -1
  314. package/dist/components/inputs/toggle-button/toggle-button.d.ts +3 -6
  315. package/dist/components/inputs/toggle-button/toggle-button.d.ts.map +1 -1
  316. package/dist/components/inputs/toggle-button/toggle-button.js +6 -20
  317. package/dist/components/inputs/toggle-button/toggle-button.js.map +1 -1
  318. package/dist/components/inputs/toggle-button-group/toggle-button-group.d.ts +2 -11
  319. package/dist/components/inputs/toggle-button-group/toggle-button-group.d.ts.map +1 -1
  320. package/dist/components/inputs/toggle-button-group/toggle-button-group.js +23 -78
  321. package/dist/components/inputs/toggle-button-group/toggle-button-group.js.map +1 -1
  322. package/dist/components/inputs/token-field/token-field.d.ts +12 -10
  323. package/dist/components/inputs/token-field/token-field.d.ts.map +1 -1
  324. package/dist/components/inputs/token-field/token-field.js +33 -35
  325. package/dist/components/inputs/token-field/token-field.js.map +1 -1
  326. package/dist/components/layout/kanban/kanban.d.ts +0 -1
  327. package/dist/components/layout/kanban/kanban.d.ts.map +1 -1
  328. package/dist/components/layout/kanban/kanban.js +2 -7
  329. package/dist/components/layout/kanban/kanban.js.map +1 -1
  330. package/dist/components/layout/popover/popover.d.ts +17 -3
  331. package/dist/components/layout/popover/popover.d.ts.map +1 -1
  332. package/dist/components/layout/popover/popover.js +34 -126
  333. package/dist/components/layout/popover/popover.js.map +1 -1
  334. package/dist/components/layout/sheet/sheet.d.ts +2 -33
  335. package/dist/components/layout/sheet/sheet.d.ts.map +1 -1
  336. package/dist/components/layout/sheet/sheet.js +8 -169
  337. package/dist/components/layout/sheet/sheet.js.map +1 -1
  338. package/dist/components/layout/sheet/sheet.template.js +5 -5
  339. package/dist/components/layout/sheet/sheet.template.js.map +1 -1
  340. package/dist/components/layout/window/window.d.ts +2 -30
  341. package/dist/components/layout/window/window.d.ts.map +1 -1
  342. package/dist/components/layout/window/window.js +12 -139
  343. package/dist/components/layout/window/window.js.map +1 -1
  344. package/dist/components/layout/window/window.template.d.ts.map +1 -1
  345. package/dist/components/layout/window/window.template.js +5 -4
  346. package/dist/components/layout/window/window.template.js.map +1 -1
  347. package/dist/components/lists-and-tables/list/list.d.ts +8 -32
  348. package/dist/components/lists-and-tables/list/list.d.ts.map +1 -1
  349. package/dist/components/lists-and-tables/list/list.js +37 -136
  350. package/dist/components/lists-and-tables/list/list.js.map +1 -1
  351. package/dist/components/lists-and-tables/list/list.roving.d.ts +79 -0
  352. package/dist/components/lists-and-tables/list/list.roving.d.ts.map +1 -0
  353. package/dist/components/lists-and-tables/list/list.roving.js +122 -0
  354. package/dist/components/lists-and-tables/list/list.roving.js.map +1 -0
  355. package/dist/components/lists-and-tables/list-item/list-item.d.ts +32 -17
  356. package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
  357. package/dist/components/lists-and-tables/list-item/list-item.js +49 -36
  358. package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
  359. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts +3 -2
  360. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts.map +1 -1
  361. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js +5 -5
  362. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js.map +1 -1
  363. package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts +4 -5
  364. package/dist/components/navigation/document-tab-bar/document-tab-bar.d.ts.map +1 -1
  365. package/dist/components/navigation/document-tab-bar/document-tab-bar.js +12 -63
  366. package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
  367. package/dist/components/navigation/document-tab-bar/document-tab-bar.template.d.ts.map +1 -1
  368. package/dist/components/navigation/document-tab-bar/document-tab-bar.template.js +5 -7
  369. package/dist/components/navigation/document-tab-bar/document-tab-bar.template.js.map +1 -1
  370. package/dist/components/navigation/link/link.d.ts +2 -2
  371. package/dist/components/navigation/link/link.d.ts.map +1 -1
  372. package/dist/components/navigation/link/link.js +2 -2
  373. package/dist/components/navigation/link/link.js.map +1 -1
  374. package/dist/components/navigation/menu-bar/menu-bar.d.ts +11 -17
  375. package/dist/components/navigation/menu-bar/menu-bar.d.ts.map +1 -1
  376. package/dist/components/navigation/menu-bar/menu-bar.js +44 -71
  377. package/dist/components/navigation/menu-bar/menu-bar.js.map +1 -1
  378. package/dist/components/navigation/menu-bar/menu-bar.template.js +2 -2
  379. package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts +2 -3
  380. package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts.map +1 -1
  381. package/dist/components/navigation/menu-bar-item/menu-bar-item.js +14 -30
  382. package/dist/components/navigation/menu-bar-item/menu-bar-item.js.map +1 -1
  383. package/dist/components/navigation/tab-bar/tab-bar.d.ts +8 -2
  384. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  385. package/dist/components/navigation/tab-bar/tab-bar.js +18 -4
  386. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  387. package/dist/components/navigation/tab-bar/tab-bar.template.d.ts.map +1 -1
  388. package/dist/components/navigation/tab-bar/tab-bar.template.js +4 -2
  389. package/dist/components/navigation/tab-bar/tab-bar.template.js.map +1 -1
  390. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts +2 -22
  391. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts.map +1 -1
  392. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js +4 -124
  393. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js.map +1 -1
  394. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.template.d.ts.map +1 -1
  395. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.template.js +5 -3
  396. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.template.js.map +1 -1
  397. package/dist/nldd.min.js +855 -851
  398. package/dist/types/react.d.ts +96 -6
  399. package/dist/types/vue.d.ts +182 -9
  400. package/dist/utilities/choice-group.d.ts +91 -0
  401. package/dist/utilities/choice-group.d.ts.map +1 -0
  402. package/dist/utilities/choice-group.js +135 -0
  403. package/dist/utilities/choice-group.js.map +1 -0
  404. package/dist/utilities/deep-active-element.d.ts +6 -0
  405. package/dist/utilities/deep-active-element.d.ts.map +1 -0
  406. package/dist/utilities/deep-active-element.js +11 -0
  407. package/dist/utilities/deep-active-element.js.map +1 -0
  408. package/dist/utilities/dev-rules.generated.js +931 -931
  409. package/dist/utilities/dev-rules.generated.js.map +1 -1
  410. package/dist/utilities/form-associated-mixin.d.ts +21 -5
  411. package/dist/utilities/form-associated-mixin.d.ts.map +1 -1
  412. package/dist/utilities/form-associated-mixin.js +86 -5
  413. package/dist/utilities/form-associated-mixin.js.map +1 -1
  414. package/dist/utilities/interest-intent.d.ts +63 -0
  415. package/dist/utilities/interest-intent.d.ts.map +1 -0
  416. package/dist/utilities/interest-intent.js +139 -0
  417. package/dist/utilities/interest-intent.js.map +1 -0
  418. package/dist/utilities/{interest-controller.d.ts → interest-invoker.d.ts} +5 -14
  419. package/dist/utilities/interest-invoker.d.ts.map +1 -0
  420. package/dist/utilities/{interest-controller.js → interest-invoker.js} +39 -97
  421. package/dist/utilities/interest-invoker.js.map +1 -0
  422. package/dist/utilities/modal-overlay.d.ts +73 -0
  423. package/dist/utilities/modal-overlay.d.ts.map +1 -0
  424. package/dist/utilities/modal-overlay.js +219 -0
  425. package/dist/utilities/modal-overlay.js.map +1 -0
  426. package/dist/utilities/overflow-menu.d.ts +97 -0
  427. package/dist/utilities/overflow-menu.d.ts.map +1 -0
  428. package/dist/utilities/overflow-menu.js +209 -0
  429. package/dist/utilities/overflow-menu.js.map +1 -0
  430. package/dist/utilities/overlay-invoker.d.ts +185 -0
  431. package/dist/utilities/overlay-invoker.d.ts.map +1 -0
  432. package/dist/utilities/overlay-invoker.js +326 -0
  433. package/dist/utilities/overlay-invoker.js.map +1 -0
  434. package/dist/utilities/page-section-mixin.d.ts +11 -0
  435. package/dist/utilities/page-section-mixin.d.ts.map +1 -1
  436. package/dist/utilities/page-section-mixin.js +11 -0
  437. package/dist/utilities/page-section-mixin.js.map +1 -1
  438. package/dist/utilities/return-focus.d.ts +0 -2
  439. package/dist/utilities/return-focus.d.ts.map +1 -1
  440. package/dist/utilities/return-focus.js +1 -7
  441. package/dist/utilities/return-focus.js.map +1 -1
  442. package/dist/utilities/with-translations.d.ts +3 -0
  443. package/dist/utilities/with-translations.d.ts.map +1 -1
  444. package/dist/utilities/with-translations.js +3 -0
  445. package/dist/utilities/with-translations.js.map +1 -1
  446. package/lint/data.generated.json +1 -1
  447. package/lint/engine.js +4 -114
  448. package/lint/fix.js +53 -136
  449. package/lint/frontends.js +68 -6
  450. package/lint/linter.js +1 -0
  451. package/lint/main.js +21 -123
  452. package/lint/project.js +31 -0
  453. package/lint/rule-compiler.js +289 -0
  454. package/lint/session.js +127 -0
  455. package/lint/tree.js +46 -0
  456. package/package.json +3 -1
  457. package/dist/cdn/chunks/checkbox-group-CC72cq-P.js +0 -103
  458. package/dist/cdn/chunks/form-associated-mixin-BtStDDYA.js +0 -73
  459. package/dist/cdn/chunks/open-when-rendered-CW_2_WUZ.js +0 -20
  460. package/dist/cdn/chunks/popover-target-B25dxnmt.js +0 -10
  461. package/dist/cdn/chunks/popup-anchor-controller-VZw0bXf2.js +0 -30
  462. package/dist/cdn/chunks/radio-button-group-D_OezDhB.js +0 -124
  463. package/dist/components/actions/toolbar/toolbar.overflow-menu.d.ts +0 -52
  464. package/dist/components/actions/toolbar/toolbar.overflow-menu.d.ts.map +0 -1
  465. package/dist/components/actions/toolbar/toolbar.overflow-menu.js +0 -105
  466. package/dist/components/actions/toolbar/toolbar.overflow-menu.js.map +0 -1
  467. package/dist/utilities/interest-controller.d.ts.map +0 -1
  468. package/dist/utilities/interest-controller.js.map +0 -1
  469. package/dist/utilities/open-when-rendered.d.ts +0 -21
  470. package/dist/utilities/open-when-rendered.d.ts.map +0 -1
  471. package/dist/utilities/open-when-rendered.js +0 -30
  472. package/dist/utilities/open-when-rendered.js.map +0 -1
  473. package/dist/utilities/popover-target.d.ts +0 -25
  474. package/dist/utilities/popover-target.d.ts.map +0 -1
  475. package/dist/utilities/popover-target.js +0 -48
  476. package/dist/utilities/popover-target.js.map +0 -1
  477. package/dist/utilities/popup-anchor-controller.d.ts +0 -63
  478. package/dist/utilities/popup-anchor-controller.d.ts.map +0 -1
  479. package/dist/utilities/popup-anchor-controller.js +0 -72
  480. package/dist/utilities/popup-anchor-controller.js.map +0 -1
package/lint/main.js CHANGED
@@ -1,14 +1,13 @@
1
- /** The `nldd` command, started from cli.js. */
1
+ /** The `nldd` command, started from cli.js: arguments in, formatted findings out. What it checks is lint/session.js. */
2
2
 
3
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
4
- import { dirname, extname, join, relative, resolve, sep } from 'node:path';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { dirname, join, relative, resolve } from 'node:path';
5
5
  import { parseArgs } from 'node:util';
6
- import { applyFixes, linesNaming, renameReferences } from './fix.js';
7
- import { declarations, TOKEN_PREFIX } from './css.js';
8
6
  import { formatGithub, formatJson, formatStatistics, formatText } from './format.js';
9
7
  import { BUILT_IN_RULES, createCanonical, loadData, GROUPS, OPT_IN_GROUPS, resolveSeverities } from './rule-data.js';
10
8
  import { rulesAboutTag } from './rule-index.js';
11
- import { applyBaseline, DEFAULT_EXTENSIONS, looseInBaseline, tightenBaseline, findFiles, IGNORED_DIRECTORIES, readBaseline, readConfig, REFERENCE_EXTENSIONS, STYLESHEET_EXTENSIONS, writeBaseline } from './project.js';
9
+ import { applyBaseline, looseInBaseline, tightenBaseline, readBaseline, readConfig, writeBaseline } from './project.js';
10
+ import { knownKeys, lintProject } from './session.js';
12
11
 
13
12
  const USAGE = `Usage:
14
13
  nldd lint [paths...] check files; without paths, the whole project
@@ -86,68 +85,6 @@ function noteOtherVersion(root) {
86
85
  }
87
86
  }
88
87
 
89
- /** Writing back what was read as UTF-8 would destroy any other encoding. */
90
- function isUtf8(filename) {
91
- const bytes = readFileSync(filename);
92
- return bytes.equals(Buffer.from(bytes.toString('utf8')));
93
- }
94
-
95
- /** The tag is gone from the markup; what still names it would break or stop matching. */
96
- function fixReferences(renamedTags, paths, root, exclude) {
97
- const isBuilt = (file) => relative(root, file).split(sep).some((part) => IGNORED_DIRECTORIES.has(part));
98
- const inMarkup = findFiles(paths, root, exclude);
99
- const elsewhere = findFiles(paths, root, exclude, REFERENCE_EXTENSIONS).filter((file) => REFERENCE_EXTENSIONS.includes(extname(file)) && !inMarkup.includes(file));
100
- let fixed = 0;
101
- let files = 0;
102
- const remaining = [];
103
- const kindOf = (file) => (/\.(css|scss|less)$/.test(file) ? 'styles' : /\.[cm]?[jt]s$/.test(file) || !inMarkup.includes(file) ? 'script' : 'markup');
104
- for (const list of [inMarkup, elsewhere]) {
105
- for (const filename of list.filter((file) => !/\.min\.[cm]?js$/.test(file))) {
106
- const source = readFileSync(filename, 'utf8');
107
- const change = isBuilt(filename) ? { source, fixed: 0 } : renameReferences(source, renamedTags, kindOf(filename));
108
- if (change.fixed > 0 && isUtf8(filename)) {
109
- writeFileSync(filename, change.source);
110
- fixed += change.fixed;
111
- files += 1;
112
- }
113
- for (const line of linesNaming(change.source, renamedTags)) remaining.push(`${relative(root, filename)}:${line}`);
114
- }
115
- }
116
- return { fixed, files, remaining };
117
- }
118
-
119
- /**
120
- * A script a bundler wrote: the linter reads a build through its HTML, and a bundle
121
- * carries the styles of the components as if they were the app's. Minified code
122
- * has few lines for its size; one long line, such as an inline SVG, does not make
123
- * a file of the app a bundle.
124
- */
125
- function isBundle(filename, source) {
126
- if (!/\.[cm]?js$/.test(filename)) return false;
127
- return /\.min\.[cm]?js$/.test(filename) || source.length / source.split('\n').length > MINIFIED_LINE_LENGTH;
128
- }
129
-
130
- /** The average line length above which a script counts as minified. */
131
- const MINIFIED_LINE_LENGTH = 500;
132
-
133
- const MAX_FIX_PASSES = 10;
134
-
135
- /** One fix can open the way for the next: a renamed tag has rules of its own. */
136
- async function fixUntilStable(linter, original, filename) {
137
- let source = original;
138
- let fixed = 0;
139
- const renamedTags = new Map();
140
- for (let pass = 0; pass < MAX_FIX_PASSES; pass++) {
141
- const { findings } = await linter.lintSource(source, filename);
142
- const change = applyFixes(source, findings);
143
- if (change.fixed === 0) return { source, fixed, renamedTags, findings };
144
- source = change.source;
145
- fixed += change.fixed;
146
- for (const [from, to] of change.renamedTags) renamedTags.set(from, to);
147
- }
148
- return { source, fixed, renamedTags, findings: (await linter.lintSource(source, filename)).findings };
149
- }
150
-
151
88
  async function runLint(data, paths, options) {
152
89
  if (!/^\d+$/.test(options['max-warnings'] ?? '0')) throw new Error('--max-warnings takes a whole number, 0 or more.');
153
90
  const formatName = options.format ?? 'text';
@@ -166,7 +103,7 @@ async function runLint(data, paths, options) {
166
103
  if (options.fix && (options.stdin || options['update-baseline'])) {
167
104
  throw new Error('--fix writes files, so it takes no --stdin or --update-baseline.');
168
105
  }
169
- const known = new Set([...data.rules.flatMap((r) => [r.id, ...(r.aliases ?? [])]), ...Object.keys(BUILT_IN_RULES), ...GROUPS]);
106
+ const known = knownKeys(data);
170
107
  const list = (value) => value?.split(',').map((key) => key.trim());
171
108
  const select = list(options.select);
172
109
  const ignore = list(options.ignore);
@@ -176,63 +113,24 @@ async function runLint(data, paths, options) {
176
113
  const config = readConfig(root, known);
177
114
  noteOtherVersion(root);
178
115
  const canonical = createCanonical(data);
179
-
180
116
  const severities = resolveSeverities(data, config.rules, { select, ignore, optIn: options.pure ? OPT_IN_GROUPS : [] });
181
- // An app that is to be pure has to be read in full: a file without a single component
182
- // is the least pure of all, and a stylesheet is one too.
183
- const pure = data.rules.some((rule) => OPT_IN_GROUPS.includes(rule.group) && severities[rule.id] !== 'off');
184
- const extensions = [...DEFAULT_EXTENSIONS, ...STYLESHEET_EXTENSIONS];
185
117
 
186
- const inputs = options.stdin
187
- ? [{ filename: resolve(root, options.filename ?? 'stdin.html'), source: readFileSync(0, 'utf8') }]
188
- : findFiles(paths, root, config.exclude, extensions).map((filename) => ({
189
- filename,
190
- source: readFileSync(filename, 'utf8'),
191
- })).filter(({ filename, source }) => !isBundle(filename, source));
192
-
193
- // Most files in an app use no component at all, and those need no parser either.
194
118
  // Tightening has to see every file the baseline names, also one without a component left.
195
119
  const inBaseline = options['tighten-baseline'] ? new Set(Object.keys(readBaseline(root, canonical))) : new Set();
196
- // A stylesheet counts for the tokens it names and the variables it sets, and only then.
197
- const isStylesheet = (filename) => STYLESHEET_EXTENSIONS.includes(extname(filename));
198
- const namesTokens = (source) => /var\(\s*--(primitives|semantics|components|context)-|--_[a-z]/.test(source);
199
- const relevant = pure
200
- ? inputs
201
- : inputs.filter(({ filename, source }) =>
202
- isStylesheet(filename)
203
- ? namesTokens(source) || inBaseline.has(relative(root, filename))
204
- : /nldd-|Nldd/.test(source) || namesTokens(source) || config.wrappers || inBaseline.has(relative(root, filename)),
205
- );
206
- const counted = pure ? inputs.length : inputs.filter(({ filename }) => !isStylesheet(filename)).length + relevant.filter(({ filename }) => isStylesheet(filename)).length;
207
- // What the project declares itself, in any file read, is its own token and not a typo.
208
- const projectTokens = [...new Set(inputs.flatMap(({ source }) => (/--(primitives|semantics|components|context)-/.test(source) ? declarations(source).map(({ name }) => name) : [])).filter((name) => TOKEN_PREFIX.test(name)))];
209
- const results = [];
210
- let fixed = 0;
211
- let fixedFiles = 0;
212
- const renamedTags = new Map();
213
- if (relevant.length > 0) {
214
- const { createLinter } = await import('./linter.js');
215
- const linter = createLinter(data, { wrappers: config.wrappers, severities, projectTokens });
216
- for (const { filename, source } of relevant) {
217
- const canWrite = options.fix && isUtf8(filename);
218
- if (options.fix && !canWrite) console.error(`Skipped ${relative(root, filename)}: it is not UTF-8.`);
219
- if (!canWrite) {
220
- results.push({ filename, source, ...(await linter.lintSource(source, filename)) });
221
- continue;
222
- }
223
- const change = await fixUntilStable(linter, source, filename);
224
- if (change.fixed > 0) {
225
- writeFileSync(filename, change.source);
226
- fixed += change.fixed;
227
- fixedFiles += 1;
228
- for (const [from, to] of change.renamedTags) renamedTags.set(from, to);
229
- }
230
- results.push({ filename, source: change.source, findings: change.findings });
231
- }
232
- }
233
- if (options.fix) console.error(`Fixed ${fixed} in ${fixedFiles} of ${counted} files.`);
234
- if (renamedTags.size > 0) {
235
- const references = fixReferences(renamedTags, paths, root, config.exclude);
120
+ const session = await lintProject(data, {
121
+ root,
122
+ paths,
123
+ config,
124
+ severities,
125
+ input: options.stdin ? { filename: options.filename ?? 'stdin.html', source: readFileSync(0, 'utf8') } : undefined,
126
+ fix: options.fix,
127
+ keep: (filename) => inBaseline.has(relative(root, filename)),
128
+ });
129
+ const { results } = session;
130
+ for (const filename of session.notUtf8) console.error(`Skipped ${relative(root, filename)}: it is not UTF-8.`);
131
+ if (options.fix) console.error(`Fixed ${session.fixed} in ${session.fixedFiles} of ${session.files} files.`);
132
+ if (session.references) {
133
+ const { references } = session;
236
134
  if (references.fixed > 0) console.error(`Renamed ${references.fixed} imports, classes and selectors of old tags in ${references.files} files.`);
237
135
  for (const place of references.remaining) console.error(`Still names an old tag: ${place}`);
238
136
  if (paths.some((path) => resolve(root, path) !== root)) {
@@ -265,7 +163,7 @@ async function runLint(data, paths, options) {
265
163
 
266
164
  const context = {
267
165
  root,
268
- files: counted,
166
+ files: session.files,
269
167
  ms: Math.round(performance.now() - started),
270
168
  skipped,
271
169
  loose: looseInBaseline(results, baseline, root, ran),
package/lint/project.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import { execFileSync } from 'node:child_process';
4
4
  import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
5
5
  import { extname, join, relative, resolve } from 'node:path';
6
+ import { declarations, TOKEN_PREFIX } from './css.js';
6
7
 
7
8
  export const IGNORED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', 'coverage', '.git', '.next', '.nuxt']);
8
9
  /** Markdown is linted on request: documentation is full of deliberately wrong examples. */
@@ -59,6 +60,36 @@ export function findFiles(paths, root, exclude = [], extensions = DEFAULT_EXTENS
59
60
  return [...new Set(files)].filter((file) => existsSync(file) && !matchesExclude(relative(root, file), exclude));
60
61
  }
61
62
 
63
+ /** The average line length above which a script counts as minified. */
64
+ const MINIFIED_LINE_LENGTH = 500;
65
+
66
+ /** A built or minified script: not the app's own source, and no use to lint. */
67
+ export function isBundle(filename, source) {
68
+ if (!/\.[cm]?js$/.test(filename)) return false;
69
+ return /\.min\.[cm]?js$/.test(filename) || source.length / source.split('\n').length > MINIFIED_LINE_LENGTH;
70
+ }
71
+
72
+ const isStylesheet = (filename) => STYLESHEET_EXTENSIONS.includes(extname(filename));
73
+ const namesTokens = (source) => /var\(\s*--(primitives|semantics|components|context)-|--_[a-z]/.test(source);
74
+
75
+ /**
76
+ * Whether a file is worth a parser when the group pure is off: most files in
77
+ * an app use no component at all. A stylesheet counts for the tokens it names
78
+ * and the variables it sets, and only then. `keep` says a file has to be read
79
+ * anyway, as one the baseline names.
80
+ */
81
+ export function isRelevant({ filename, source }, { wrappers, keep = () => false } = {}) {
82
+ if (keep(filename)) return true;
83
+ if (isStylesheet(filename)) return namesTokens(source);
84
+ return /nldd-|Nldd/.test(source) || namesTokens(source) || Boolean(wrappers);
85
+ }
86
+
87
+ /** What the project declares itself, in any file read, is its own token and not a typo. */
88
+ export function projectTokens(inputs) {
89
+ const names = inputs.flatMap(({ source }) => (/--(primitives|semantics|components|context)-/.test(source) ? declarations(source).map(({ name }) => name) : []));
90
+ return [...new Set(names.filter((name) => TOKEN_PREFIX.test(name)))];
91
+ }
92
+
62
93
  const CONFIG_FILE = '.nldd-lint.json';
63
94
 
64
95
  export function readConfig(root, knownRules) {
@@ -0,0 +1,289 @@
1
+ /**
2
+ * What a rule means where it runs: in source, through the engine, and on a
3
+ * running page, as plain CSS for `el.matches()`.
4
+ *
5
+ * A rule is a selector, and most of it is CSS that means the same in both. The
6
+ * pseudo-classes the design system adds are not: each one here says what it
7
+ * means in source and what the browser gets instead. A class of tags becomes
8
+ * `:is()` of its tags, `:named-by-field` is dropped because on a running page
9
+ * the field has set the attribute, and what only source can judge has no
10
+ * browser form at all. A selector that cannot be compiled is refused, so a rule
11
+ * never silently stops running in the browser.
12
+ */
13
+
14
+ import { parse, stringify } from 'css-what';
15
+ import { OPT_IN_GROUPS } from './rule-data.js';
16
+ import { isDesignSystemCss } from './css.js';
17
+ import { BOUND } from './tree.js';
18
+
19
+ /**
20
+ * A member of a tag class that counts only in part. A hidden input has no box
21
+ * and no place in the accessibility tree, so it is no form input, though its
22
+ * tag is (#421).
23
+ */
24
+ const CLASS_EXCEPTIONS = {
25
+ 'form-input': { input: { attribute: 'type', value: 'hidden' } },
26
+ };
27
+
28
+ function excepted(className, node) {
29
+ const exception = CLASS_EXCEPTIONS[className]?.[node.name];
30
+ return Boolean(exception) && node.attrs.get(exception.attribute) === exception.value;
31
+ }
32
+
33
+ /** Pseudo-classes of CSS itself, which mean the same everywhere. */
34
+ const CSS_PSEUDOS = new Set(['is', 'not', 'has', 'where', 'matches']);
35
+
36
+ /**
37
+ * Whether a field hands its label to `target`, as _findInput in nldd-form-field does:
38
+ * the first input in document order, helper text left out. The answer is `maybe` when
39
+ * something before it may or may not be an input that renders.
40
+ */
41
+ function findsInput(node, target, isInput, uncertain = false) {
42
+ let maybe = uncertain;
43
+ for (const child of node.children) {
44
+ if (child.name === 'nldd-form-field-help-text') continue;
45
+ const unsure = maybe || child.conditional || child.repeated;
46
+ if (child === target) return maybe ? 'maybe' : 'yes';
47
+ if (isInput(child)) {
48
+ if (!unsure) return 'no';
49
+ maybe = true;
50
+ }
51
+ if (child.opaque) maybe = true;
52
+ const inside = findsInput(child, target, isInput, unsure);
53
+ if (inside !== 'absent') return inside;
54
+ }
55
+ return 'absent';
56
+ }
57
+
58
+ function fieldLabelCheck(isInput, allowMaybe) {
59
+ return (node) => {
60
+ for (let parent = node.parent; parent; parent = parent.parent) {
61
+ if (parent.name === 'nldd-form-field') {
62
+ const label = parent.attrs.get('label');
63
+ const unknownLabel = label === BOUND || parent.spread;
64
+ if (!unknownLabel && !label) return false;
65
+ const found = findsInput(parent, node, isInput);
66
+ if (found === 'yes' && !unknownLabel) return true;
67
+ return allowMaybe && found !== 'no';
68
+ }
69
+ if (parent.opaque) return allowMaybe;
70
+ }
71
+ return false;
72
+ };
73
+ }
74
+
75
+ /**
76
+ * Whether the nearest component around a plain element styles it, as nldd-dropdown
77
+ * does its <select> and nldd-rich-text everything in it. Each component says so
78
+ * with `@accepts` in its JSDoc.
79
+ *
80
+ * What a file renders is judged in that file: that a parent elsewhere might put it
81
+ * inside an nldd-rich-text does not make plain HTML written here the design system's. A
82
+ * tree the file builds under a name (a helper component, a variable) is judged where
83
+ * the file uses that name. Used nowhere here, or under a component of the app, it is
84
+ * unknown.
85
+ */
86
+ function acceptedCheck(tags, allowUnknown) {
87
+ // `chain` holds the plain elements between the node and the component: the
88
+ // component styles its own children (::slotted) or descendants of what it styles,
89
+ // so each of them has to be accepted too. `seen` keeps a component that places
90
+ // itself from going round in circles.
91
+ const accepted = (node, from, chain, seen) => {
92
+ for (let parent = from; parent; parent = parent.parent) {
93
+ if (parent.name === '#root') {
94
+ if (!parent.detached) return false;
95
+ if (!parent.placements) return allowUnknown;
96
+ if (seen.has(parent)) return false;
97
+ const next = new Set(seen).add(parent);
98
+ // Accepted in any of the places the file uses it is enough.
99
+ return parent.placements.some((place) => accepted(node, place.parent, chain, next));
100
+ }
101
+ if (parent.opaque) return allowUnknown;
102
+ if (!parent.name.startsWith('nldd-')) {
103
+ chain.push(parent.name);
104
+ continue;
105
+ }
106
+ const accepts = tags[parent.name]?.accepts ?? [];
107
+ return accepts.includes('*') || [node.name, ...chain].every((name) => accepts.includes(name));
108
+ }
109
+ return false;
110
+ };
111
+ return (node) => accepted(node, node.parent, [], new Set());
112
+ }
113
+
114
+ /**
115
+ * The pseudo-classes a rule may use besides those of CSS and the tag classes.
116
+ *
117
+ * - `source` is what it means in the engine, made from the linter data.
118
+ * - `favorable` is what it means in W+, where whatever is unknown may hold.
119
+ * - `browser` is `native` (CSS knows it), `drop` (leave the alternative out of
120
+ * its list) or absent (source only).
121
+ * - `optIn` keeps it to the groups a project turns on itself: it judges a file
122
+ * by itself, which a rule that runs unasked may not do.
123
+ */
124
+ const VOCABULARY = {
125
+ // Only exists on a running page, so in source it is never true.
126
+ state: { source: () => () => false, browser: 'native' },
127
+ // On a running page the field has set the attribute, so no exception is needed.
128
+ 'named-by-field': {
129
+ source: ({ isInput }) => fieldLabelCheck(isInput, false),
130
+ favorable: ({ isInput }) => fieldLabelCheck(isInput, true),
131
+ browser: 'drop',
132
+ },
133
+ accepted: {
134
+ source: ({ tags }) => acceptedCheck(tags, false),
135
+ favorable: ({ tags }) => acceptedCheck(tags, true),
136
+ optIn: true,
137
+ },
138
+ // The attribute is in the markup, with a value or bound to one. `[class]` asks for a
139
+ // value we can read, so a bound class would only ever be cantTell.
140
+ written: { source: () => (node, name) => node.attrs.has(name), optIn: true },
141
+ // No element and no text: an empty mount point such as <div id="app"></div>.
142
+ blank: { source: () => (node) => node.children.length === 0 && !node.text, optIn: true },
143
+ // Inside an element of this name in this file. A drawing's own classes and styles are its business.
144
+ within: {
145
+ source: () => (node, name) => {
146
+ for (let parent = node.parent; parent; parent = parent.parent) if (parent.name === name) return true;
147
+ return false;
148
+ },
149
+ optIn: true,
150
+ },
151
+ // CSS the design system ships: a block it recognizes, or a stylesheet with nothing else in it.
152
+ 'design-system': {
153
+ source: ({ designSystemCss }) => (node) => node.designSystem ?? (node.css !== undefined && isDesignSystemCss(node.css, designSystemCss)),
154
+ optIn: true,
155
+ },
156
+ };
157
+
158
+ /** The name a pseudo-class goes by in W+, or the name itself when unknown changes nothing. */
159
+ export function favorableName(name) {
160
+ return VOCABULARY[name]?.favorable ? `may-be-${name}` : name;
161
+ }
162
+
163
+ /** What each pseudo-class means in source, for css-select. */
164
+ export function sourcePseudos({ classes = {}, tags = {}, designSystemCss = {} } = {}) {
165
+ const shared = Object.fromEntries(
166
+ Object.entries(classes).map(([name, members]) => {
167
+ const set = new Set(members);
168
+ return [name, (node) => set.has(node.name) && !excepted(name, node)];
169
+ }),
170
+ );
171
+ const context = { tags, designSystemCss, isInput: shared['form-input'] ?? (() => false) };
172
+ const own = Object.entries(VOCABULARY).flatMap(([name, entry]) => [
173
+ [name, entry.source(context)],
174
+ ...(entry.favorable ? [[favorableName(name), entry.favorable(context)]] : []),
175
+ ]);
176
+ return { ...shared, ...Object.fromEntries(own) };
177
+ }
178
+
179
+ /**
180
+ * Whether a rule runs on a running page. A hint is advice for whoever writes the
181
+ * source, and components write `style`, `id` and more on a live page that it would
182
+ * take for the app's own. An opt-in group judges the app's own markup and is off
183
+ * unless a project turns it on. A `ref` follows an id and is no selector.
184
+ */
185
+ export function runsInBrowser(rule) {
186
+ return !rule.ref && rule.severity !== 'hint' && !OPT_IN_GROUPS.includes(rule.group);
187
+ }
188
+
189
+ function pseudoNames(selector) {
190
+ const names = [];
191
+ const visit = (tokens) => {
192
+ for (const token of tokens) {
193
+ if (token.type !== 'pseudo') continue;
194
+ names.push(token.name);
195
+ if (Array.isArray(token.data)) token.data.forEach(visit);
196
+ }
197
+ };
198
+ parse(selector).forEach(visit);
199
+ return names;
200
+ }
201
+
202
+ function compileList(list, classes, selector) {
203
+ const kept = list.filter((tokens) => {
204
+ const [only] = tokens;
205
+ return !(tokens.length === 1 && only.type === 'pseudo' && VOCABULARY[only.name]?.browser === 'drop');
206
+ });
207
+ if (kept.length === 0) throw new Error(`${selector}: nothing is left of it in the browser.`);
208
+ return kept.map((tokens) => tokens.map((token) => compileToken(token, classes, selector)));
209
+ }
210
+
211
+ function compileToken(token, classes, selector) {
212
+ if (token.type !== 'pseudo') return token;
213
+ if (classes[token.name]) {
214
+ return { type: 'pseudo', name: 'is', data: classes[token.name].map((name) => {
215
+ const tag = { type: 'tag', name, namespace: null };
216
+ const exception = CLASS_EXCEPTIONS[token.name]?.[name];
217
+ if (!exception) return [tag];
218
+ const attribute = { type: 'attribute', name: exception.attribute, action: 'equals', value: exception.value, namespace: null, ignoreCase: null };
219
+ return [tag, { type: 'pseudo', name: 'not', data: [[attribute]] }];
220
+ }) };
221
+ }
222
+ const browser = CSS_PSEUDOS.has(token.name) ? 'native' : VOCABULARY[token.name]?.browser;
223
+ if (browser === 'drop') throw new Error(`${selector}: :${token.name} can only stand on its own in a list.`);
224
+ if (browser !== 'native') throw new Error(`${selector}: the browser has no :${token.name}.`);
225
+ return Array.isArray(token.data) ? { ...token, data: compileList(token.data, classes, selector) } : token;
226
+ }
227
+
228
+ /** The selector as plain CSS. Throws when the browser cannot run it. */
229
+ export function forBrowser(selector, classes = {}) {
230
+ return stringify(compileList(parse(selector), classes, selector));
231
+ }
232
+
233
+ const toProperty = (name) => name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
234
+
235
+ /**
236
+ * `[accessible-label]` in an assert also holds for the property `accessibleLabel`,
237
+ * which a selector cannot see. Not inside a `:not()`: there the attribute is what may
238
+ * not be there, and a property that is set does not excuse it.
239
+ */
240
+ export function assertProperties(assert) {
241
+ const names = [];
242
+ const visit = (tokens, negated) => {
243
+ for (const token of tokens) {
244
+ if (token.type === 'attribute' && token.action === 'exists' && !negated) names.push(toProperty(token.name));
245
+ if (token.type === 'pseudo' && Array.isArray(token.data)) {
246
+ for (const inner of token.data) visit(inner, token.name === 'not' ? !negated : negated);
247
+ }
248
+ }
249
+ };
250
+ parse(assert).forEach((tokens) => visit(tokens, false));
251
+ return [...new Set(names)];
252
+ }
253
+
254
+ /** A rule as the browser runs it, or null for one that only runs on source. */
255
+ export function compileForBrowser(rule, classes = {}) {
256
+ if (!runsInBrowser(rule)) return null;
257
+ const { id, message, context, assert, report, count } = rule;
258
+ const css = (selector) => forBrowser(selector, classes);
259
+ return {
260
+ id,
261
+ message,
262
+ context: css(context),
263
+ ...(assert ? { assert: css(assert), properties: assertProperties(css(assert)) } : {}),
264
+ ...(report ? { report: css(report) } : {}),
265
+ ...(count ? { count: { ...count, of: css(count.of) } } : {}),
266
+ };
267
+ }
268
+
269
+ /** What is wrong with the selectors of a rule, for where it runs. */
270
+ export function ruleProblems(rule, classes = {}) {
271
+ const problems = [];
272
+ const selectors = [rule.context, rule.assert, rule.report, rule.count?.of, rule.ref?.target].filter(Boolean);
273
+ for (const name of new Set(selectors.flatMap(pseudoNames))) {
274
+ if (CSS_PSEUDOS.has(name) || classes[name]) continue;
275
+ const entry = VOCABULARY[name];
276
+ if (!entry) problems.push(`:${name} does not exist.`);
277
+ else if (entry.optIn && !OPT_IN_GROUPS.includes(rule.group)) {
278
+ problems.push(`:${name} is for the opt-in groups (${OPT_IN_GROUPS.join(', ')}) only.`);
279
+ }
280
+ }
281
+ if (problems.length === 0) {
282
+ try {
283
+ compileForBrowser(rule, classes);
284
+ } catch (error) {
285
+ problems.push(error.message);
286
+ }
287
+ }
288
+ return problems;
289
+ }
@@ -0,0 +1,127 @@
1
+ /**
2
+ * What `nldd lint` checks in a project, without the command line around it:
3
+ * which files it reads, which of them need a parser, the tokens the project
4
+ * declares itself, and the fixes. The CLI parses its arguments, calls this and
5
+ * formats what comes back; scripts/lint-corpus.js calls it the same way, so the
6
+ * corpus measures the linter consumers run.
7
+ */
8
+
9
+ import { readFileSync, writeFileSync } from 'node:fs';
10
+ import { extname, relative, resolve, sep } from 'node:path';
11
+ import { applyFixes, linesNaming, renameReferences } from './fix.js';
12
+ import { BUILT_IN_RULES, GROUPS, OPT_IN_GROUPS } from './rule-data.js';
13
+ import { DEFAULT_EXTENSIONS, findFiles, IGNORED_DIRECTORIES, isBundle, isRelevant, projectTokens, REFERENCE_EXTENSIONS, STYLESHEET_EXTENSIONS } from './project.js';
14
+
15
+ /** Every name `--select`, `--ignore` and .nldd-lint.json may use: rule ids, aliases and groups. */
16
+ export function knownKeys(data) {
17
+ return new Set([...data.rules.flatMap((rule) => [rule.id, ...(rule.aliases ?? [])]), ...Object.keys(BUILT_IN_RULES), ...GROUPS]);
18
+ }
19
+
20
+ /** Whether an opt-in group runs: then every file is read, stylesheets and files without a component too. */
21
+ export function readsEverything(data, severities) {
22
+ return data.rules.some((rule) => OPT_IN_GROUPS.includes(rule.group) && severities[rule.id] !== 'off');
23
+ }
24
+
25
+ /** Writing back what was read as UTF-8 would destroy any other encoding. */
26
+ export function isUtf8(filename) {
27
+ const bytes = readFileSync(filename);
28
+ return bytes.equals(Buffer.from(bytes.toString('utf8')));
29
+ }
30
+
31
+ const MAX_FIX_PASSES = 10;
32
+
33
+ /** One fix can open the way for the next: a renamed tag has rules of its own. */
34
+ async function fixUntilStable(linter, original, filename) {
35
+ let source = original;
36
+ let fixed = 0;
37
+ const renamedTags = new Map();
38
+ for (let pass = 0; pass < MAX_FIX_PASSES; pass++) {
39
+ const { findings } = await linter.lintSource(source, filename);
40
+ const change = applyFixes(source, findings);
41
+ if (change.fixed === 0) return { source, fixed, renamedTags, findings };
42
+ source = change.source;
43
+ fixed += change.fixed;
44
+ for (const [from, to] of change.renamedTags) renamedTags.set(from, to);
45
+ }
46
+ return { source, fixed, renamedTags, findings: (await linter.lintSource(source, filename)).findings };
47
+ }
48
+
49
+ /** The tag is gone from the markup; what still names it would break or stop matching. */
50
+ function fixReferences(renamedTags, paths, root, exclude) {
51
+ const isBuilt = (file) => relative(root, file).split(sep).some((part) => IGNORED_DIRECTORIES.has(part));
52
+ const inMarkup = findFiles(paths, root, exclude);
53
+ const elsewhere = findFiles(paths, root, exclude, REFERENCE_EXTENSIONS).filter((file) => REFERENCE_EXTENSIONS.includes(extname(file)) && !inMarkup.includes(file));
54
+ let fixed = 0;
55
+ let files = 0;
56
+ const remaining = [];
57
+ const kindOf = (file) => (/\.(css|scss|less)$/.test(file) ? 'styles' : /\.[cm]?[jt]s$/.test(file) || !inMarkup.includes(file) ? 'script' : 'markup');
58
+ for (const list of [inMarkup, elsewhere]) {
59
+ for (const filename of list.filter((file) => !/\.min\.[cm]?js$/.test(file))) {
60
+ const source = readFileSync(filename, 'utf8');
61
+ const change = isBuilt(filename) ? { source, fixed: 0 } : renameReferences(source, renamedTags, kindOf(filename));
62
+ if (change.fixed > 0 && isUtf8(filename)) {
63
+ writeFileSync(filename, change.source);
64
+ fixed += change.fixed;
65
+ files += 1;
66
+ }
67
+ for (const line of linesNaming(change.source, renamedTags)) remaining.push(`${relative(root, filename)}:${line}`);
68
+ }
69
+ }
70
+ return { fixed, files, remaining };
71
+ }
72
+
73
+ /**
74
+ * @param {object} data - the rule data, from loadData()
75
+ * @param {object} options
76
+ * @param {string} options.root - the project, for config-relative paths and the baseline
77
+ * @param {string[]} [options.paths] - what to check; none is the whole project
78
+ * @param {{ wrappers?: object, exclude?: string[] }} [options.config] - from .nldd-lint.json
79
+ * @param {object} options.severities - from resolveSeverities()
80
+ * @param {{ filename: string, source: string }} [options.input] - one snippet instead of files
81
+ * @param {boolean} [options.fix] - write the fixes that are certain
82
+ * @param {(filename: string) => boolean} [options.keep] - read this file even without a component
83
+ * @returns {Promise<{ results: object[], files: number, fixed: number, fixedFiles: number,
84
+ * notUtf8: string[], references?: { fixed: number, files: number, remaining: string[] } }>}
85
+ */
86
+ export async function lintProject(data, { root, paths = [], config = {}, severities, input, fix = false, keep = () => false }) {
87
+ const everything = readsEverything(data, severities);
88
+ const inputs = input
89
+ ? [{ filename: resolve(root, input.filename), source: input.source }]
90
+ : findFiles(paths, root, config.exclude, [...DEFAULT_EXTENSIONS, ...STYLESHEET_EXTENSIONS])
91
+ .map((filename) => ({ filename, source: readFileSync(filename, 'utf8') }))
92
+ .filter(({ filename, source }) => !isBundle(filename, source));
93
+
94
+ // Most files in an app use no component at all, and those need no parser either.
95
+ // A stylesheet is still read for the tokens it declares.
96
+ const isStylesheet = (filename) => STYLESHEET_EXTENSIONS.includes(extname(filename));
97
+ const relevant = everything ? inputs : inputs.filter((one) => isRelevant(one, { wrappers: config.wrappers, keep }));
98
+ const files = everything ? inputs.length : inputs.filter(({ filename }) => !isStylesheet(filename)).length + relevant.filter(({ filename }) => isStylesheet(filename)).length;
99
+
100
+ const results = [];
101
+ const notUtf8 = [];
102
+ const renamedTags = new Map();
103
+ let fixed = 0;
104
+ let fixedFiles = 0;
105
+ if (relevant.length > 0) {
106
+ const { createLinter } = await import('./linter.js');
107
+ const linter = createLinter(data, { wrappers: config.wrappers, severities, projectTokens: projectTokens(inputs) });
108
+ for (const { filename, source } of relevant) {
109
+ const canWrite = fix && isUtf8(filename);
110
+ if (fix && !canWrite) notUtf8.push(filename);
111
+ if (!canWrite) {
112
+ results.push({ filename, source, ...(await linter.lintSource(source, filename)) });
113
+ continue;
114
+ }
115
+ const change = await fixUntilStable(linter, source, filename);
116
+ if (change.fixed > 0) {
117
+ writeFileSync(filename, change.source);
118
+ fixed += change.fixed;
119
+ fixedFiles += 1;
120
+ for (const [from, to] of change.renamedTags) renamedTags.set(from, to);
121
+ }
122
+ results.push({ filename, source: change.source, findings: change.findings });
123
+ }
124
+ }
125
+ const references = renamedTags.size > 0 ? fixReferences(renamedTags, paths, root, config.exclude) : undefined;
126
+ return { results, files, fixed, fixedFiles, notUtf8, references };
127
+ }