@nldd/design-system 0.13.2 → 0.14.0

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 (491) hide show
  1. package/README.md +4 -2
  2. package/custom-elements.json +1425 -136
  3. package/dist/components/actions/button/button.d.ts +0 -2
  4. package/dist/components/actions/button/button.d.ts.map +1 -1
  5. package/dist/components/actions/button/button.js +17 -33
  6. package/dist/components/actions/button/button.js.map +1 -1
  7. package/dist/components/actions/button/button.template.js +2 -2
  8. package/dist/components/actions/button-bar/button-bar.d.ts +0 -2
  9. package/dist/components/actions/button-bar/button-bar.d.ts.map +1 -1
  10. package/dist/components/actions/button-bar/button-bar.js +2 -12
  11. package/dist/components/actions/button-bar/button-bar.js.map +1 -1
  12. package/dist/components/actions/button-group/button-group.d.ts.map +1 -1
  13. package/dist/components/actions/button-group/button-group.js +9 -10
  14. package/dist/components/actions/button-group/button-group.js.map +1 -1
  15. package/dist/components/actions/icon-button/icon-button.d.ts +0 -1
  16. package/dist/components/actions/icon-button/icon-button.d.ts.map +1 -1
  17. package/dist/components/actions/icon-button/icon-button.js +4 -11
  18. package/dist/components/actions/icon-button/icon-button.js.map +1 -1
  19. package/dist/components/actions/icon-button/icon-button.template.js +2 -2
  20. package/dist/components/actions/menu/menu-divider.d.ts +1 -0
  21. package/dist/components/actions/menu/menu-divider.d.ts.map +1 -1
  22. package/dist/components/actions/menu/menu-divider.js +1 -0
  23. package/dist/components/actions/menu/menu-divider.js.map +1 -1
  24. package/dist/components/actions/menu/menu-group.d.ts +1 -0
  25. package/dist/components/actions/menu/menu-group.d.ts.map +1 -1
  26. package/dist/components/actions/menu/menu-group.js +1 -0
  27. package/dist/components/actions/menu/menu-group.js.map +1 -1
  28. package/dist/components/actions/menu/menu-item.d.ts +1 -0
  29. package/dist/components/actions/menu/menu-item.d.ts.map +1 -1
  30. package/dist/components/actions/menu/menu-item.js +4 -7
  31. package/dist/components/actions/menu/menu-item.js.map +1 -1
  32. package/dist/components/actions/menu/menu.d.ts +1 -4
  33. package/dist/components/actions/menu/menu.d.ts.map +1 -1
  34. package/dist/components/actions/menu/menu.js +3 -17
  35. package/dist/components/actions/menu/menu.js.map +1 -1
  36. package/dist/components/actions/split-button/split-button.d.ts.map +1 -1
  37. package/dist/components/actions/split-button/split-button.js +2 -1
  38. package/dist/components/actions/split-button/split-button.js.map +1 -1
  39. package/dist/components/actions/toolbar/toolbar-item.d.ts +0 -2
  40. package/dist/components/actions/toolbar/toolbar-item.d.ts.map +1 -1
  41. package/dist/components/actions/toolbar/toolbar-item.js +2 -20
  42. package/dist/components/actions/toolbar/toolbar-item.js.map +1 -1
  43. package/dist/components/actions/toolbar/toolbar-title.d.ts.map +1 -1
  44. package/dist/components/actions/toolbar/toolbar-title.js +2 -1
  45. package/dist/components/actions/toolbar/toolbar-title.js.map +1 -1
  46. package/dist/components/actions/toolbar/toolbar.d.ts.map +1 -1
  47. package/dist/components/actions/toolbar/toolbar.js +2 -1
  48. package/dist/components/actions/toolbar/toolbar.js.map +1 -1
  49. package/dist/components/button.i18n-DiDGynnq.js +8 -0
  50. package/dist/components/components.js +352 -706
  51. package/dist/components/content/avatar/avatar.d.ts +0 -2
  52. package/dist/components/content/avatar/avatar.d.ts.map +1 -1
  53. package/dist/components/content/avatar/avatar.js +2 -27
  54. package/dist/components/content/avatar/avatar.js.map +1 -1
  55. package/dist/components/content/avatar-group/avatar-group.d.ts +0 -1
  56. package/dist/components/content/avatar-group/avatar-group.d.ts.map +1 -1
  57. package/dist/components/content/avatar-group/avatar-group.js +2 -24
  58. package/dist/components/content/avatar-group/avatar-group.js.map +1 -1
  59. package/dist/components/content/blockquote/blockquote.d.ts.map +1 -1
  60. package/dist/components/content/blockquote/blockquote.js +2 -1
  61. package/dist/components/content/blockquote/blockquote.js.map +1 -1
  62. package/dist/components/content/code-viewer/code-viewer.d.ts +1 -0
  63. package/dist/components/content/code-viewer/code-viewer.d.ts.map +1 -1
  64. package/dist/components/content/code-viewer/code-viewer.diff.d.ts +2 -0
  65. package/dist/components/content/code-viewer/code-viewer.diff.d.ts.map +1 -1
  66. package/dist/components/content/code-viewer/code-viewer.diff.js +1 -4
  67. package/dist/components/content/code-viewer/code-viewer.diff.js.map +1 -1
  68. package/dist/components/content/code-viewer/code-viewer.js +13 -11
  69. package/dist/components/content/code-viewer/code-viewer.js.map +1 -1
  70. package/dist/components/content/icon/icon.d.ts +3 -0
  71. package/dist/components/content/icon/icon.d.ts.map +1 -1
  72. package/dist/components/content/icon/icon.js +19 -15
  73. package/dist/components/content/icon/icon.js.map +1 -1
  74. package/dist/components/content/identity/identity.d.ts.map +1 -1
  75. package/dist/components/content/identity/identity.js +2 -1
  76. package/dist/components/content/identity/identity.js.map +1 -1
  77. package/dist/components/content/image/image.d.ts +5 -11
  78. package/dist/components/content/image/image.d.ts.map +1 -1
  79. package/dist/components/content/image/image.js +14 -31
  80. package/dist/components/content/image/image.js.map +1 -1
  81. package/dist/components/content/image/lqip-encoder-element.d.ts.map +1 -1
  82. package/dist/components/content/image/lqip-encoder-element.js +2 -1
  83. package/dist/components/content/image/lqip-encoder-element.js.map +1 -1
  84. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.d.ts.map +1 -1
  85. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js +2 -1
  86. package/dist/components/content/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  87. package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
  88. package/dist/components/content/rich-text/rich-text.js +2 -1
  89. package/dist/components/content/rich-text/rich-text.js.map +1 -1
  90. package/dist/components/content/tag/tag.d.ts.map +1 -1
  91. package/dist/components/content/tag/tag.js +5 -5
  92. package/dist/components/content/tag/tag.js.map +1 -1
  93. package/dist/components/content/text/text.d.ts.map +1 -1
  94. package/dist/components/content/text/text.js +2 -1
  95. package/dist/components/content/text/text.js.map +1 -1
  96. package/dist/components/content/title/title.d.ts +1 -5
  97. package/dist/components/content/title/title.d.ts.map +1 -1
  98. package/dist/components/content/title/title.js +15 -27
  99. package/dist/components/content/title/title.js.map +1 -1
  100. package/dist/components/content/token/token.d.ts.map +1 -1
  101. package/dist/components/content/token/token.js +2 -1
  102. package/dist/components/content/token/token.js.map +1 -1
  103. package/dist/components/content/tooltip/tooltip.d.ts.map +1 -1
  104. package/dist/components/content/tooltip/tooltip.js +2 -1
  105. package/dist/components/content/tooltip/tooltip.js.map +1 -1
  106. package/dist/components/content/visually-hidden/visually-hidden.js +1 -1
  107. package/dist/components/content/visually-hidden/visually-hidden.js.map +1 -1
  108. package/dist/components/{decorate-Cz9-peTN.js → decorate-x12uDAK4.js} +9 -1
  109. package/dist/components/dev-checks-BgrW077W.js +2503 -0
  110. package/dist/components/element-state-BnarBv0M.js +42 -0
  111. package/dist/components/forms/form/form.d.ts +1 -96
  112. package/dist/components/forms/form/form.d.ts.map +1 -1
  113. package/dist/components/forms/form/form.js +1 -0
  114. package/dist/components/forms/form/form.js.map +1 -1
  115. package/dist/components/forms/form-actions/form-actions.d.ts.map +1 -1
  116. package/dist/components/forms/form-actions/form-actions.js +2 -1
  117. package/dist/components/forms/form-actions/form-actions.js.map +1 -1
  118. package/dist/components/forms/form-field/form-field.d.ts +1 -2
  119. package/dist/components/forms/form-field/form-field.d.ts.map +1 -1
  120. package/dist/components/forms/form-field/form-field.js +10 -26
  121. package/dist/components/forms/form-field/form-field.js.map +1 -1
  122. package/dist/components/forms/form-section/form-section.d.ts +1 -67
  123. package/dist/components/forms/form-section/form-section.d.ts.map +1 -1
  124. package/dist/components/forms/form-section/form-section.js +2 -16
  125. package/dist/components/forms/form-section/form-section.js.map +1 -1
  126. package/dist/components/forms/validation-list/validation-list.d.ts.map +1 -1
  127. package/dist/components/forms/validation-list/validation-list.js +7 -6
  128. package/dist/components/forms/validation-list/validation-list.js.map +1 -1
  129. package/dist/components/{icon-DRpTWSIg.js → icon-IgCyk9ui.js} +17 -4
  130. package/dist/components/{icon-button-DUEmWlBD.js → icon-button-B5tH4b3c.js} +8 -17
  131. package/dist/components/icon-button.i18n-1_N-wN6x.js +10 -0
  132. package/dist/components/inputs/checkbox/checkbox.d.ts.map +1 -1
  133. package/dist/components/inputs/checkbox/checkbox.js +2 -1
  134. package/dist/components/inputs/checkbox/checkbox.js.map +1 -1
  135. package/dist/components/inputs/checkbox-field/checkbox-field.d.ts.map +1 -1
  136. package/dist/components/inputs/checkbox-field/checkbox-field.js +2 -1
  137. package/dist/components/inputs/checkbox-field/checkbox-field.js.map +1 -1
  138. package/dist/components/inputs/code-editor/code-editor.d.ts.map +1 -1
  139. package/dist/components/inputs/code-editor/code-editor.js +2 -1
  140. package/dist/components/inputs/code-editor/code-editor.js.map +1 -1
  141. package/dist/components/inputs/combo-box/combo-box.d.ts.map +1 -1
  142. package/dist/components/inputs/combo-box/combo-box.js +4 -5
  143. package/dist/components/inputs/combo-box/combo-box.js.map +1 -1
  144. package/dist/components/inputs/date-field/date-field.d.ts.map +1 -1
  145. package/dist/components/inputs/date-field/date-field.js +2 -1
  146. package/dist/components/inputs/date-field/date-field.js.map +1 -1
  147. package/dist/components/inputs/date-picker/date-picker.d.ts.map +1 -1
  148. package/dist/components/inputs/date-picker/date-picker.js +2 -1
  149. package/dist/components/inputs/date-picker/date-picker.js.map +1 -1
  150. package/dist/components/inputs/dropdown/dropdown.d.ts.map +1 -1
  151. package/dist/components/inputs/dropdown/dropdown.js +5 -4
  152. package/dist/components/inputs/dropdown/dropdown.js.map +1 -1
  153. package/dist/components/inputs/file-field/file-field.d.ts.map +1 -1
  154. package/dist/components/inputs/file-field/file-field.js +2 -1
  155. package/dist/components/inputs/file-field/file-field.js.map +1 -1
  156. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.d.ts.map +1 -1
  157. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js +2 -4
  158. package/dist/components/inputs/multi-line-text-field/multi-line-text-field.js.map +1 -1
  159. package/dist/components/inputs/number-field/number-field.d.ts.map +1 -1
  160. package/dist/components/inputs/number-field/number-field.js +2 -4
  161. package/dist/components/inputs/number-field/number-field.js.map +1 -1
  162. package/dist/components/inputs/password-field/password-field.d.ts.map +1 -1
  163. package/dist/components/inputs/password-field/password-field.js +2 -1
  164. package/dist/components/inputs/password-field/password-field.js.map +1 -1
  165. package/dist/components/inputs/radio-button/radio-button.d.ts.map +1 -1
  166. package/dist/components/inputs/radio-button/radio-button.js +2 -1
  167. package/dist/components/inputs/radio-button/radio-button.js.map +1 -1
  168. package/dist/components/inputs/radio-button-field/radio-button-field.d.ts.map +1 -1
  169. package/dist/components/inputs/radio-button-field/radio-button-field.js +2 -1
  170. package/dist/components/inputs/radio-button-field/radio-button-field.js.map +1 -1
  171. package/dist/components/inputs/radio-button-group/radio-button-group.d.ts +0 -1
  172. package/dist/components/inputs/radio-button-group/radio-button-group.d.ts.map +1 -1
  173. package/dist/components/inputs/radio-button-group/radio-button-group.js +2 -6
  174. package/dist/components/inputs/radio-button-group/radio-button-group.js.map +1 -1
  175. package/dist/components/inputs/search-field/search-field.d.ts.map +1 -1
  176. package/dist/components/inputs/search-field/search-field.js +2 -1
  177. package/dist/components/inputs/search-field/search-field.js.map +1 -1
  178. package/dist/components/inputs/segmented-control/segmented-control.d.ts +0 -1
  179. package/dist/components/inputs/segmented-control/segmented-control.d.ts.map +1 -1
  180. package/dist/components/inputs/segmented-control/segmented-control.js +2 -11
  181. package/dist/components/inputs/segmented-control/segmented-control.js.map +1 -1
  182. package/dist/components/inputs/slider/slider.d.ts.map +1 -1
  183. package/dist/components/inputs/slider/slider.js +2 -1
  184. package/dist/components/inputs/slider/slider.js.map +1 -1
  185. package/dist/components/inputs/stepper/stepper.d.ts.map +1 -1
  186. package/dist/components/inputs/stepper/stepper.js +2 -1
  187. package/dist/components/inputs/stepper/stepper.js.map +1 -1
  188. package/dist/components/inputs/switch/switch.d.ts.map +1 -1
  189. package/dist/components/inputs/switch/switch.js +2 -4
  190. package/dist/components/inputs/switch/switch.js.map +1 -1
  191. package/dist/components/inputs/switch-field/switch-field.d.ts.map +1 -1
  192. package/dist/components/inputs/switch-field/switch-field.js +2 -1
  193. package/dist/components/inputs/switch-field/switch-field.js.map +1 -1
  194. package/dist/components/inputs/text-editor/text-editor.d.ts.map +1 -1
  195. package/dist/components/inputs/text-editor/text-editor.js +7 -3
  196. package/dist/components/inputs/text-editor/text-editor.js.map +1 -1
  197. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts +2 -0
  198. package/dist/components/inputs/text-editor/text-editor.mentions.d.ts.map +1 -1
  199. package/dist/components/inputs/text-editor/text-editor.mentions.js +14 -2
  200. package/dist/components/inputs/text-editor/text-editor.mentions.js.map +1 -1
  201. package/dist/components/inputs/text-field/text-field.d.ts +1 -5
  202. package/dist/components/inputs/text-field/text-field.d.ts.map +1 -1
  203. package/dist/components/inputs/text-field/text-field.js +6 -23
  204. package/dist/components/inputs/text-field/text-field.js.map +1 -1
  205. package/dist/components/inputs/time-field/time-field.d.ts.map +1 -1
  206. package/dist/components/inputs/time-field/time-field.js +2 -1
  207. package/dist/components/inputs/time-field/time-field.js.map +1 -1
  208. package/dist/components/inputs/time-picker/time-picker.d.ts.map +1 -1
  209. package/dist/components/inputs/time-picker/time-picker.js +2 -1
  210. package/dist/components/inputs/time-picker/time-picker.js.map +1 -1
  211. package/dist/components/inputs/toggle-button/toggle-button.d.ts +0 -2
  212. package/dist/components/inputs/toggle-button/toggle-button.d.ts.map +1 -1
  213. package/dist/components/inputs/toggle-button/toggle-button.js +2 -23
  214. package/dist/components/inputs/toggle-button/toggle-button.js.map +1 -1
  215. package/dist/components/inputs/toggle-button-group/toggle-button-group.d.ts +0 -2
  216. package/dist/components/inputs/toggle-button-group/toggle-button-group.d.ts.map +1 -1
  217. package/dist/components/inputs/toggle-button-group/toggle-button-group.js +2 -12
  218. package/dist/components/inputs/toggle-button-group/toggle-button-group.js.map +1 -1
  219. package/dist/components/inputs/token-field/token-field.d.ts.map +1 -1
  220. package/dist/components/inputs/token-field/token-field.js +2 -1
  221. package/dist/components/inputs/token-field/token-field.js.map +1 -1
  222. package/dist/components/just-in-time-education.i18n-BJ5ovWVB.js +370 -0
  223. package/dist/components/layout/box/box.d.ts.map +1 -1
  224. package/dist/components/layout/box/box.js +2 -1
  225. package/dist/components/layout/box/box.js.map +1 -1
  226. package/dist/components/layout/card/card.d.ts +0 -1
  227. package/dist/components/layout/card/card.d.ts.map +1 -1
  228. package/dist/components/layout/card/card.js +2 -15
  229. package/dist/components/layout/card/card.js.map +1 -1
  230. package/dist/components/layout/card/card.template.js +2 -2
  231. package/dist/components/layout/collection/collection.d.ts +0 -2
  232. package/dist/components/layout/collection/collection.d.ts.map +1 -1
  233. package/dist/components/layout/collection/collection.js +8 -24
  234. package/dist/components/layout/collection/collection.js.map +1 -1
  235. package/dist/components/layout/container/container.d.ts +6 -3
  236. package/dist/components/layout/container/container.d.ts.map +1 -1
  237. package/dist/components/layout/container/container.js +17 -23
  238. package/dist/components/layout/container/container.js.map +1 -1
  239. package/dist/components/layout/divider/divider.js +1 -1
  240. package/dist/components/layout/divider/divider.js.map +1 -1
  241. package/dist/components/layout/page/page.d.ts +2 -3
  242. package/dist/components/layout/page/page.d.ts.map +1 -1
  243. package/dist/components/layout/page/page.js +9 -12
  244. package/dist/components/layout/page/page.js.map +1 -1
  245. package/dist/components/layout/page-footer/page-footer.d.ts.map +1 -1
  246. package/dist/components/layout/page-footer/page-footer.js +6 -7
  247. package/dist/components/layout/page-footer/page-footer.js.map +1 -1
  248. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.d.ts.map +1 -1
  249. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.js +2 -1
  250. package/dist/components/layout/page-sections/full-bleed-section/full-bleed-section.js.map +1 -1
  251. package/dist/components/layout/page-sections/hero/hero-corner.d.ts +0 -1
  252. package/dist/components/layout/page-sections/hero/hero-corner.d.ts.map +1 -1
  253. package/dist/components/layout/page-sections/hero/hero-corner.js +9 -28
  254. package/dist/components/layout/page-sections/hero/hero-corner.js.map +1 -1
  255. package/dist/components/layout/page-sections/hero/hero.d.ts +1 -4
  256. package/dist/components/layout/page-sections/hero/hero.d.ts.map +1 -1
  257. package/dist/components/layout/page-sections/hero/hero.js +7 -29
  258. package/dist/components/layout/page-sections/hero/hero.js.map +1 -1
  259. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.d.ts.map +1 -1
  260. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.js +2 -1
  261. package/dist/components/layout/page-sections/one-half-one-half-section/one-half-one-half-section.js.map +1 -1
  262. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.d.ts.map +1 -1
  263. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.js +2 -1
  264. package/dist/components/layout/page-sections/one-third-two-thirds-section/one-third-two-thirds-section.js.map +1 -1
  265. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.d.ts.map +1 -1
  266. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.js +2 -1
  267. package/dist/components/layout/page-sections/sidebar-section/sidebar-section.js.map +1 -1
  268. package/dist/components/layout/page-sections/simple-section/simple-section.d.ts.map +1 -1
  269. package/dist/components/layout/page-sections/simple-section/simple-section.js +2 -1
  270. package/dist/components/layout/page-sections/simple-section/simple-section.js.map +1 -1
  271. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.d.ts.map +1 -1
  272. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.js +2 -1
  273. package/dist/components/layout/page-sections/two-thirds-one-third-section/two-thirds-one-third-section.js.map +1 -1
  274. package/dist/components/layout/popover/popover.d.ts +0 -2
  275. package/dist/components/layout/popover/popover.d.ts.map +1 -1
  276. package/dist/components/layout/popover/popover.js +6 -25
  277. package/dist/components/layout/popover/popover.js.map +1 -1
  278. package/dist/components/layout/sheet/sheet.d.ts +0 -2
  279. package/dist/components/layout/sheet/sheet.d.ts.map +1 -1
  280. package/dist/components/layout/sheet/sheet.js +9 -20
  281. package/dist/components/layout/sheet/sheet.js.map +1 -1
  282. package/dist/components/layout/shell/shell.d.ts.map +1 -1
  283. package/dist/components/layout/shell/shell.js +2 -1
  284. package/dist/components/layout/shell/shell.js.map +1 -1
  285. package/dist/components/layout/spacer/spacer.d.ts.map +1 -1
  286. package/dist/components/layout/spacer/spacer.js +2 -1
  287. package/dist/components/layout/spacer/spacer.js.map +1 -1
  288. package/dist/components/layout/split-views/bar-split-view/bar-split-view.d.ts +6 -6
  289. package/dist/components/layout/split-views/bar-split-view/bar-split-view.d.ts.map +1 -1
  290. package/dist/components/layout/split-views/bar-split-view/bar-split-view.js +9 -12
  291. package/dist/components/layout/split-views/bar-split-view/bar-split-view.js.map +1 -1
  292. package/dist/components/layout/split-views/navigation-split-view/navigation-split-view.d.ts.map +1 -1
  293. package/dist/components/layout/split-views/navigation-split-view/navigation-split-view.js +2 -1
  294. package/dist/components/layout/split-views/navigation-split-view/navigation-split-view.js.map +1 -1
  295. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.d.ts.map +1 -1
  296. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.js +2 -1
  297. package/dist/components/layout/split-views/side-by-side-split-view/side-by-side-split-view.js.map +1 -1
  298. package/dist/components/layout/split-views/split-view-divider/split-view-divider.d.ts.map +1 -1
  299. package/dist/components/layout/split-views/split-view-divider/split-view-divider.js +2 -1
  300. package/dist/components/layout/split-views/split-view-divider/split-view-divider.js.map +1 -1
  301. package/dist/components/layout/split-views/split-view-pane/split-view-pane.d.ts.map +1 -1
  302. package/dist/components/layout/split-views/split-view-pane/split-view-pane.js +2 -1
  303. package/dist/components/layout/split-views/split-view-pane/split-view-pane.js.map +1 -1
  304. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.d.ts.map +1 -1
  305. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.js +2 -1
  306. package/dist/components/layout/split-views/stacked-split-view/stacked-split-view.js.map +1 -1
  307. package/dist/components/layout/task-board/task-board-column.d.ts.map +1 -1
  308. package/dist/components/layout/task-board/task-board-column.js +2 -4
  309. package/dist/components/layout/task-board/task-board-column.js.map +1 -1
  310. package/dist/components/layout/task-board/task-board.d.ts.map +1 -1
  311. package/dist/components/layout/task-board/task-board.js +4 -3
  312. package/dist/components/layout/task-board/task-board.js.map +1 -1
  313. package/dist/components/layout/window/window.d.ts +0 -1
  314. package/dist/components/layout/window/window.d.ts.map +1 -1
  315. package/dist/components/layout/window/window.js +4 -6
  316. package/dist/components/layout/window/window.js.map +1 -1
  317. package/dist/components/list-item.i18n-89uqlBMK.js +8 -0
  318. package/dist/components/list.i18n-nFB6dZpc.js +13 -0
  319. package/dist/components/lists-and-tables/cells/cell/cell.d.ts.map +1 -1
  320. package/dist/components/lists-and-tables/cells/cell/cell.js +2 -1
  321. package/dist/components/lists-and-tables/cells/cell/cell.js.map +1 -1
  322. package/dist/components/lists-and-tables/cells/description-cell/description-cell.d.ts.map +1 -1
  323. package/dist/components/lists-and-tables/cells/description-cell/description-cell.js +2 -1
  324. package/dist/components/lists-and-tables/cells/description-cell/description-cell.js.map +1 -1
  325. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.d.ts.map +1 -1
  326. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js +2 -1
  327. package/dist/components/lists-and-tables/cells/drag-handle-cell/drag-handle-cell.js.map +1 -1
  328. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts +1 -0
  329. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.d.ts.map +1 -1
  330. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js +3 -1
  331. package/dist/components/lists-and-tables/cells/icon-cell/icon-cell.js.map +1 -1
  332. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.d.ts.map +1 -1
  333. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.js +2 -1
  334. package/dist/components/lists-and-tables/cells/spacer-cell/spacer-cell.js.map +1 -1
  335. package/dist/components/lists-and-tables/cells/step-cell/step-cell.d.ts +0 -1
  336. package/dist/components/lists-and-tables/cells/step-cell/step-cell.d.ts.map +1 -1
  337. package/dist/components/lists-and-tables/cells/step-cell/step-cell.js +5 -15
  338. package/dist/components/lists-and-tables/cells/step-cell/step-cell.js.map +1 -1
  339. package/dist/components/lists-and-tables/cells/text-cell/text-cell.d.ts.map +1 -1
  340. package/dist/components/lists-and-tables/cells/text-cell/text-cell.js +2 -1
  341. package/dist/components/lists-and-tables/cells/text-cell/text-cell.js.map +1 -1
  342. package/dist/components/lists-and-tables/cells/title-cell/title-cell.d.ts.map +1 -1
  343. package/dist/components/lists-and-tables/cells/title-cell/title-cell.js +2 -1
  344. package/dist/components/lists-and-tables/cells/title-cell/title-cell.js.map +1 -1
  345. package/dist/components/lists-and-tables/list/list.d.ts +5 -23
  346. package/dist/components/lists-and-tables/list/list.d.ts.map +1 -1
  347. package/dist/components/lists-and-tables/list/list.js +53 -98
  348. package/dist/components/lists-and-tables/list/list.js.map +1 -1
  349. package/dist/components/lists-and-tables/list-item/list-item.d.ts +10 -15
  350. package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
  351. package/dist/components/lists-and-tables/list-item/list-item.js +40 -87
  352. package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
  353. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts +2 -2
  354. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts.map +1 -1
  355. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js +6 -11
  356. package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js.map +1 -1
  357. package/dist/components/lists-and-tables/table/table.d.ts +0 -13
  358. package/dist/components/lists-and-tables/table/table.d.ts.map +1 -1
  359. package/dist/components/lists-and-tables/table/table.js +6 -41
  360. package/dist/components/lists-and-tables/table/table.js.map +1 -1
  361. package/dist/components/navigation/breadcrumbs/breadcrumbs.d.ts.map +1 -1
  362. package/dist/components/navigation/breadcrumbs/breadcrumbs.js +2 -1
  363. package/dist/components/navigation/breadcrumbs/breadcrumbs.js.map +1 -1
  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 +2 -4
  366. package/dist/components/navigation/document-tab-bar/document-tab-bar.js.map +1 -1
  367. package/dist/components/navigation/link/link.d.ts.map +1 -1
  368. package/dist/components/navigation/link/link.js +2 -1
  369. package/dist/components/navigation/link/link.js.map +1 -1
  370. package/dist/components/navigation/link/link.template.js +2 -2
  371. package/dist/components/navigation/menu-bar/menu-bar.d.ts +4 -0
  372. package/dist/components/navigation/menu-bar/menu-bar.d.ts.map +1 -1
  373. package/dist/components/navigation/menu-bar/menu-bar.js +13 -10
  374. package/dist/components/navigation/menu-bar/menu-bar.js.map +1 -1
  375. package/dist/components/navigation/menu-bar-item/menu-bar-item.d.ts.map +1 -1
  376. package/dist/components/navigation/menu-bar-item/menu-bar-item.js +2 -1
  377. package/dist/components/navigation/menu-bar-item/menu-bar-item.js.map +1 -1
  378. package/dist/components/navigation/pagination/pagination.d.ts.map +1 -1
  379. package/dist/components/navigation/pagination/pagination.js +2 -1
  380. package/dist/components/navigation/pagination/pagination.js.map +1 -1
  381. package/dist/components/navigation/skip-link/skip-link.d.ts.map +1 -1
  382. package/dist/components/navigation/skip-link/skip-link.js +6 -8
  383. package/dist/components/navigation/skip-link/skip-link.js.map +1 -1
  384. package/dist/components/navigation/tab-bar/tab-bar.d.ts +1 -1
  385. package/dist/components/navigation/tab-bar/tab-bar.d.ts.map +1 -1
  386. package/dist/components/navigation/tab-bar/tab-bar.js +5 -15
  387. package/dist/components/navigation/tab-bar/tab-bar.js.map +1 -1
  388. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts +0 -1
  389. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.d.ts.map +1 -1
  390. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js +6 -6
  391. package/dist/components/navigation/top-navigation-bar/top-navigation-bar.js.map +1 -1
  392. package/dist/components/navigation/top-title-bar/top-title-bar.d.ts.map +1 -1
  393. package/dist/components/navigation/top-title-bar/top-title-bar.js +7 -6
  394. package/dist/components/navigation/top-title-bar/top-title-bar.js.map +1 -1
  395. package/dist/components/nl.generated-Ny3Kwppu.js +61 -0
  396. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.d.ts.map +1 -1
  397. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.js +2 -1
  398. package/dist/components/status-and-feedback/activity-indicator/activity-indicator.js.map +1 -1
  399. package/dist/components/status-and-feedback/badge/badge.d.ts.map +1 -1
  400. package/dist/components/status-and-feedback/badge/badge.js +3 -6
  401. package/dist/components/status-and-feedback/badge/badge.js.map +1 -1
  402. package/dist/components/status-and-feedback/banner/banner.d.ts.map +1 -1
  403. package/dist/components/status-and-feedback/banner/banner.js +2 -1
  404. package/dist/components/status-and-feedback/banner/banner.js.map +1 -1
  405. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.d.ts.map +1 -1
  406. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js +2 -1
  407. package/dist/components/status-and-feedback/inline-dialog/inline-dialog.js.map +1 -1
  408. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.d.ts.map +1 -1
  409. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js +2 -1
  410. package/dist/components/status-and-feedback/just-in-time-education/just-in-time-education.js.map +1 -1
  411. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts +0 -3
  412. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.d.ts.map +1 -1
  413. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js +2 -14
  414. package/dist/components/status-and-feedback/modal-dialog/modal-dialog.js.map +1 -1
  415. package/dist/components/status-and-feedback/notification/notification.d.ts.map +1 -1
  416. package/dist/components/status-and-feedback/notification/notification.js +3 -7
  417. package/dist/components/status-and-feedback/notification/notification.js.map +1 -1
  418. package/dist/components/status-and-feedback/progress-bar/progress-bar.d.ts.map +1 -1
  419. package/dist/components/status-and-feedback/progress-bar/progress-bar.js +4 -5
  420. package/dist/components/status-and-feedback/progress-bar/progress-bar.js.map +1 -1
  421. package/dist/components/status-and-feedback/progress-circle/progress-circle.d.ts.map +1 -1
  422. package/dist/components/status-and-feedback/progress-circle/progress-circle.js +2 -1
  423. package/dist/components/status-and-feedback/progress-circle/progress-circle.js.map +1 -1
  424. package/dist/components/status-and-feedback/status-bar/status-bar.d.ts +1 -1
  425. package/dist/components/status-and-feedback/status-bar/status-bar.d.ts.map +1 -1
  426. package/dist/components/status-and-feedback/status-bar/status-bar.js +8 -7
  427. package/dist/components/status-and-feedback/status-bar/status-bar.js.map +1 -1
  428. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts +0 -7
  429. package/dist/components/status-and-feedback/step-bar/step-bar.d.ts.map +1 -1
  430. package/dist/components/status-and-feedback/step-bar/step-bar.js +2 -24
  431. package/dist/components/status-and-feedback/step-bar/step-bar.js.map +1 -1
  432. package/dist/components/{visibility-mixin-C-K7ho5Q.js → visibility-mixin-DcwzF0_a.js} +1 -7
  433. package/dist/components/{with-translations-DRuOq3QK.js → with-translations-DLzmBSkU.js} +26 -5
  434. package/dist/nldd.min.js +775 -775
  435. package/dist/types/vue.d.ts +76 -6
  436. package/dist/utilities/codemirror/codemirror-input.d.ts +0 -2
  437. package/dist/utilities/codemirror/codemirror-input.d.ts.map +1 -1
  438. package/dist/utilities/codemirror/codemirror-input.js +0 -14
  439. package/dist/utilities/codemirror/codemirror-input.js.map +1 -1
  440. package/dist/utilities/custom-element.d.ts +7 -0
  441. package/dist/utilities/custom-element.d.ts.map +1 -0
  442. package/dist/utilities/custom-element.js +7 -0
  443. package/dist/utilities/custom-element.js.map +1 -0
  444. package/dist/utilities/dev-checks-trigger.d.ts +2 -0
  445. package/dist/utilities/dev-checks-trigger.d.ts.map +1 -0
  446. package/dist/utilities/dev-checks-trigger.js +10 -0
  447. package/dist/utilities/dev-checks-trigger.js.map +1 -0
  448. package/dist/utilities/dev-checks.d.ts +40 -0
  449. package/dist/utilities/dev-checks.d.ts.map +1 -0
  450. package/dist/utilities/dev-checks.js +115 -0
  451. package/dist/utilities/dev-checks.js.map +1 -0
  452. package/dist/utilities/dev-rules.generated.d.ts +3 -0
  453. package/dist/utilities/dev-rules.generated.d.ts.map +1 -0
  454. package/dist/utilities/dev-rules.generated.js +2472 -0
  455. package/dist/utilities/dev-rules.generated.js.map +1 -0
  456. package/dist/utilities/element-state.d.ts +19 -0
  457. package/dist/utilities/element-state.d.ts.map +1 -0
  458. package/dist/utilities/element-state.js +49 -0
  459. package/dist/utilities/element-state.js.map +1 -0
  460. package/dist/utilities/form-associated-mixin.d.ts.map +1 -1
  461. package/dist/utilities/form-associated-mixin.js +2 -1
  462. package/dist/utilities/form-associated-mixin.js.map +1 -1
  463. package/dist/utilities/link-hint.d.ts +2 -21
  464. package/dist/utilities/link-hint.d.ts.map +1 -1
  465. package/dist/utilities/link-hint.js +22 -8
  466. package/dist/utilities/link-hint.js.map +1 -1
  467. package/dist/utilities/spacing-scale.d.ts +4 -5
  468. package/dist/utilities/spacing-scale.d.ts.map +1 -1
  469. package/dist/utilities/spacing-scale.js +4 -23
  470. package/dist/utilities/spacing-scale.js.map +1 -1
  471. package/dist/utilities/translations.d.ts.map +1 -1
  472. package/dist/utilities/translations.js +3 -15
  473. package/dist/utilities/translations.js.map +1 -1
  474. package/dist/utilities/visibility-mixin.d.ts +7 -0
  475. package/dist/utilities/visibility-mixin.d.ts.map +1 -1
  476. package/dist/utilities/visibility-mixin.js +0 -10
  477. package/dist/utilities/visibility-mixin.js.map +1 -1
  478. package/lint/cli.js +18 -0
  479. package/lint/data.generated.json +1 -0
  480. package/lint/engine.js +191 -0
  481. package/lint/fix.js +293 -0
  482. package/lint/format.js +133 -0
  483. package/lint/frontends.js +483 -0
  484. package/lint/linter.js +262 -0
  485. package/lint/main.js +279 -0
  486. package/lint/project.js +143 -0
  487. package/lint/rule-data.js +83 -0
  488. package/lint/rule-index.js +20 -0
  489. package/lint/rule.schema.json +65 -0
  490. package/lint/tree.js +131 -0
  491. package/package.json +21 -4
package/lint/linter.js ADDED
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Lints one source text: parse, built-in checks from the component contract,
3
+ * rules from src/rules/, then the suppressions written in the file.
4
+ */
5
+
6
+ import { createEngine } from './engine.js';
7
+ import { canFix, stuckTags } from './fix.js';
8
+ import { applyWrappers, parseSource } from './frontends.js';
9
+ import { BUILT_IN_RULES, createCanonical, loadData } from './rule-data.js';
10
+ import { BOUND, walk } from './tree.js';
11
+
12
+ export { BUILT_IN_RULES, createCanonical, loadData };
13
+
14
+
15
+ /** Valid on any element, so the manifest does not list them per component. */
16
+ const GLOBAL_ATTRIBUTE =
17
+ /^(id|class|style|slot|hidden|lang|dir|title|role|tabindex|part|inert|draggable|contenteditable|spellcheck|translate|accesskey|autofocus|enterkeyhint|inputmode|is|nonce|popover|key|ref|exportparts|item(prop|scope|type|id|ref)|i18n(-.*)?|data-.*|aria-.*|hx-.*|x-.*|on(?!ly$)[a-z]+)$/;
18
+
19
+ /** Set as a property on any element: in markup these are bindings, not attributes. */
20
+ const DOM_PROPERTY = /^(textContent|innerHTML|innerText|outerHTML|className|tabIndex|aria[A-Z].*)$/;
21
+
22
+ /** An Angular directive of the app. Angular's own, such as `ngIf` and `routerLink`, take no inputs here. */
23
+ const APP_DIRECTIVE = /^(?!(ng|router|form)[A-Z])[a-z]+[A-Z]/;
24
+ const hasAppDirective = (node) => [...node.attrs.keys()].some((name) => APP_DIRECTIVE.test(name));
25
+
26
+ const ICON_ATTRIBUTES = new Set(['icon', 'start-icon', 'end-icon', 'selected-icon']);
27
+
28
+
29
+ const toCamelCase = (name) => name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
30
+
31
+ /** `[accessibleLabel]` and `:accessibleLabel` set the same thing as `accessible-label`. */
32
+ function readPropertyNames(roots, tags, isPlainHtml) {
33
+ const visit = (node) => {
34
+ const contract = tags[node.name];
35
+ for (const [name, value] of contract ? [...node.attrs] : []) {
36
+ const attribute = name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
37
+ // In HTML itself a capital means nothing: the browser lowercases the name.
38
+ if (attribute === name || !contract.attrs[attribute] || (isPlainHtml && value !== BOUND)) continue;
39
+ node.attrs.delete(name);
40
+ node.attrs.set(attribute, value);
41
+ }
42
+ };
43
+ for (const root of roots) walk(root, visit);
44
+ return roots;
45
+ }
46
+
47
+ function checkAttributes(node, { tags, icons, anyChildAttrs, isPlainHtml }, report) {
48
+ if (node.templated) return;
49
+ const contract = tags[node.name];
50
+ // A parent in another file may be the one reading it, so any child attribute goes.
51
+ const fromParent = node.parent.opaque ? anyChildAttrs : (tags[node.parent.name]?.childAttrs ?? {});
52
+ for (const [name, value] of node.attrs) {
53
+ const attribute = contract.attrs[name] ?? fromParent[name];
54
+ if (ICON_ATTRIBUTES.has(name) && attribute && typeof value === 'string' && value !== '') {
55
+ if (!icons.has(value)) report('unknown-icon', `There is no icon named "${value}".`);
56
+ }
57
+ if (attribute?.deprecated) {
58
+ const detail = attribute.deprecated === true ? '' : ` ${attribute.deprecated}`;
59
+ report('deprecated', `\`${name}\` on ${node.name} is deprecated.${detail}`, name);
60
+ }
61
+ if (attribute) {
62
+ if (attribute.values && typeof value === 'string' && !attribute.values.includes(value)) {
63
+ const allowed = attribute.values.filter(Boolean).join(', ');
64
+ report('invalid-value', `\`${name}="${value}"\` is not valid on ${node.name}: use ${allowed}.`, name);
65
+ }
66
+ } else if (value === BOUND && contract.props.includes(toCamelCase(name))) {
67
+ // A property without an attribute, which only a binding can reach.
68
+ } else if (value === BOUND && DOM_PROPERTY.test(name)) {
69
+ // Every element has this one.
70
+ } else if (isPlainHtml && /[A-Z]/.test(name)) {
71
+ // HTML has no capitals, so in an .html file this is a template directive.
72
+ } else if (contract.attrs[name.toLowerCase()]) {
73
+ // `maxLength`: no such property, so it ends up as the attribute, in lowercase.
74
+ } else if (!GLOBAL_ATTRIBUTE.test(name.toLowerCase()) && !node.wrapped) {
75
+ // `[show]` next to `appSheetSync` may be an input of that directive, or a typo.
76
+ const maybeInput = isPlainHtml && value === BOUND && hasAppDirective(node);
77
+ if (maybeInput) report('unknown-attribute', `${node.name} has no attribute \`${name}\`. That is fine if a directive on this element takes it.`, name, 'hint');
78
+ else report('unknown-attribute', `${node.name} has no attribute \`${name}\`.`, name);
79
+ }
80
+ }
81
+ }
82
+
83
+ function checkSlot(node, tags, report) {
84
+ const slot = node.attrs.get('slot');
85
+ const parent = node.parent;
86
+ if (typeof slot !== 'string' || !slot || parent.opaque || !parent.name.startsWith('nldd-')) return;
87
+ const contract = tags[parent.name];
88
+ if (contract && !contract.anySlot && !contract.slots.includes(slot)) {
89
+ report('unknown-slot', `${parent.name} has no slot "${slot}".`, 'slot');
90
+ }
91
+ }
92
+
93
+ function builtInFindings(root, context) {
94
+ const { tags } = context;
95
+ const findings = [];
96
+ walk(root, (node) => {
97
+ if (!node.name.startsWith('nldd-')) return;
98
+ const report = (rule, message, attribute, severity = BUILT_IN_RULES[rule].severity) =>
99
+ findings.push({ rule, severity, message, node, attribute });
100
+ const contract = tags[node.name];
101
+ if (!contract) {
102
+ report('unknown-element', `${node.name} does not exist in this version.`, node.name);
103
+ return;
104
+ }
105
+ checkAttributes(node, context, report);
106
+ checkSlot(node, tags, report);
107
+ });
108
+ return findings;
109
+ }
110
+
111
+ const SUPPRESSION = /nldd-lint-disable-next-line\s+([\w-]+(?:\s*,\s*[\w-]+)*)(?:\s+--(?!-*>)\s*(\S.*?))?\s*(?:-->|\*\/|-?#\}|$)/;
112
+
113
+ function readSuppressions(source, canonical) {
114
+ const suppressed = new Map();
115
+ const missingReason = [];
116
+ source.split('\n').forEach((text, index) => {
117
+ const match = text.trimEnd().match(SUPPRESSION);
118
+ if (!match) return;
119
+ if (!match[2]) missingReason.push(index + 1);
120
+ suppressed.set(index + 2, new Set(match[1].split(',').map((id) => canonical(id.trim()))));
121
+ });
122
+ return { suppressed, missingReason };
123
+ }
124
+
125
+ function syntaxError({ message, offset }, position) {
126
+ const rule = 'syntax-error';
127
+ const { severity, description } = BUILT_IN_RULES[rule];
128
+ return { rule, severity, message: `${description} ${message}`, tag: '', ...position(offset) };
129
+ }
130
+
131
+ function createPositions(source) {
132
+ const starts = [0];
133
+ for (let i = 0; i < source.length; i++) if (source[i] === '\n') starts.push(i + 1);
134
+ return (offset) => {
135
+ let low = 0;
136
+ let high = starts.length - 1;
137
+ while (low < high) {
138
+ const middle = Math.ceil((low + high) / 2);
139
+ if (starts[middle] <= offset) low = middle;
140
+ else high = middle - 1;
141
+ }
142
+ return { line: low + 1, column: offset - starts[low] + 1 };
143
+ };
144
+ }
145
+
146
+
147
+ export function createLinter(data = loadData(), { wrappers = {}, severities: configured = {} } = {}) {
148
+ const canonical = createCanonical(data);
149
+ const severities = Object.fromEntries(Object.entries(configured).map(([id, level]) => [canonical(id), level]));
150
+ const context = {
151
+ tags: data.tags,
152
+ icons: new Set(data.icons),
153
+ anyChildAttrs: Object.assign({}, ...Object.values(data.tags).map((tag) => tag.childAttrs)),
154
+ };
155
+ const engine = createEngine({ classes: data.classes });
156
+ const rules = data.rules.filter((rule) => !rule.runtime && severities[rule.id] !== 'off');
157
+ const ranInSource = (id) => severities[id] !== 'off' && (rules.some((rule) => rule.id === id) || id in BUILT_IN_RULES);
158
+ const isRule = (id) => id in BUILT_IN_RULES || data.rules.some((rule) => rule.id === id);
159
+
160
+ /** A rule about a name or value that is gone says what to use instead; the generic finding adds nothing. */
161
+ function withoutCovered(findings) {
162
+ return findings.filter(
163
+ ({ attribute, node }) =>
164
+ !attribute || !findings.some((other) => other.node === node && other.covers?.includes(attribute)),
165
+ );
166
+ }
167
+
168
+ /** A wrapper has an API of its own, and a bound name can be the input of a directive. */
169
+ function isOurs(node, rule, isPlainHtml) {
170
+ const maybeInput = isPlainHtml && hasAppDirective(node) && rule.removed?.some((name) => node.attrs.has(name));
171
+ return !node.wrapped && !maybeInput;
172
+ }
173
+
174
+ function lintRoots(roots, isPlainHtml) {
175
+ const findings = [];
176
+ const counts = { failed: 0, passed: 0, cantTell: 0 };
177
+ for (const root of roots) {
178
+ findings.push(...builtInFindings(root, { ...context, isPlainHtml }));
179
+ for (const rule of rules) {
180
+ for (const { node, outcome } of engine.evaluate(rule, root)) {
181
+ counts[outcome]++;
182
+ // A name that is gone is wrong whatever the binding holds.
183
+ const namesRemoved = rule.removed?.some((name) => node.attrs.get(name) === BOUND);
184
+ if (outcome !== 'failed' && !(outcome === 'cantTell' && namesRemoved)) continue;
185
+ findings.push({
186
+ rule: rule.id,
187
+ severity: rule.severity,
188
+ message: rule.message,
189
+ node,
190
+ covers: [...(rule.removed ?? []), ...Object.keys(rule.fix?.value ?? {})],
191
+ fix: isOurs(node, rule, isPlainHtml) ? rule.fix : undefined,
192
+ });
193
+ }
194
+ }
195
+ }
196
+ return { findings: withoutCovered(findings), counts };
197
+ }
198
+
199
+ /** @returns {Promise<{ findings: object[], counts: object }>} */
200
+ async function lintSource(source, filename) {
201
+ const parsed = applyWrappers(await parseSource(source, filename), wrappers);
202
+ const isPlainHtml = /\.(html?|j2|jinja2?)$/.test(filename);
203
+ const roots = readPropertyNames(parsed, data.tags, isPlainHtml);
204
+ const { findings, counts } = lintRoots(roots, isPlainHtml);
205
+ const { suppressed, missingReason } = readSuppressions(source, canonical);
206
+ const position = createPositions(source);
207
+ const aboutSuppression = (rule, line, detail = BUILT_IN_RULES[rule].description) => ({
208
+ rule,
209
+ severity: BUILT_IN_RULES[rule].severity,
210
+ message: detail,
211
+ tag: '',
212
+ line,
213
+ column: 1,
214
+ });
215
+ const all = findings
216
+ .map(({ node, severity, covers, attribute, ...finding }) => ({
217
+ ...finding,
218
+ severity,
219
+ tag: node.name,
220
+ offset: node.offset,
221
+ endOffset: node.endOffset,
222
+ ...position(node.offset),
223
+ }));
224
+ const stuck = stuckTags(source, all, /\.[jt]sx$/.test(filename));
225
+ for (const finding of all) {
226
+ if (finding.fix && (!canFix(source, finding) || (finding.fix.tag && stuck.has(finding.tag)))) finding.fix = undefined;
227
+ }
228
+ const fires = (line, id) => all.some((finding) => finding.line === line && finding.rule === id);
229
+ // A rule that did not run here says nothing, and Markdown shows a suppression as an example.
230
+ const unneeded = /\.md$/.test(filename) || parsed.length === 0 || parsed.syntaxError
231
+ ? []
232
+ : [...suppressed].flatMap(([line, ids]) =>
233
+ [...ids]
234
+ .filter((id) => !isRule(id) || (ranInSource(id) && !fires(line, id)))
235
+ .map((id) => {
236
+ const detail = isRule(id) ? 'does not fire on the next line, so this suppression can go.' : 'is not a rule, so this suppression does nothing.';
237
+ return aboutSuppression('suppression-not-needed', line - 1, `\`${id}\` ${detail}`);
238
+ }),
239
+ );
240
+ const located = all
241
+ .filter((finding) => !suppressed.get(finding.line)?.has(finding.rule))
242
+ .concat(missingReason.map((line) => aboutSuppression('suppression-needs-reason', line)), unneeded)
243
+ .concat(parsed.syntaxError ? [syntaxError(parsed.syntaxError, position)] : [])
244
+ .map((finding) => ({ ...finding, severity: severities[finding.rule] ?? finding.severity }))
245
+ .filter((finding) => finding.severity !== 'off');
246
+ located.sort((a, b) => a.line - b.line || a.column - b.column);
247
+ return { findings: located, counts };
248
+ }
249
+
250
+ /** Evaluates one rule on a snippet, for the examples of that rule. */
251
+ async function outcomesOf(rule, snippet) {
252
+ const isDocument = snippet.startsWith('<html');
253
+ const parsed = isDocument
254
+ ? await parseSource(snippet, 'example.html')
255
+ : await parseSource(`<template>${snippet}</template>`, 'example.vue');
256
+ return parsed.flatMap((root) => engine.evaluate(rule, root).map(({ outcome }) => outcome));
257
+ }
258
+
259
+ return { lintSource, outcomesOf };
260
+ }
261
+
262
+ export { BOUND };
package/lint/main.js ADDED
@@ -0,0 +1,279 @@
1
+ /** The `nldd` command, started from cli.js. */
2
+
3
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
4
+ import { dirname, extname, join, relative, resolve, sep } from 'node:path';
5
+ import { parseArgs } from 'node:util';
6
+ import { applyFixes, linesNaming, renameReferences } from './fix.js';
7
+ import { formatGithub, formatJson, formatStatistics, formatText } from './format.js';
8
+ import { BUILT_IN_RULES, createCanonical, loadData, GROUPS, resolveSeverities } from './rule-data.js';
9
+ import { rulesAboutTag } from './rule-index.js';
10
+ import { applyBaseline, findFiles, IGNORED_DIRECTORIES, readBaseline, readConfig, REFERENCE_EXTENSIONS, writeBaseline } from './project.js';
11
+
12
+ const USAGE = `Usage:
13
+ nldd lint [paths...] check files; without paths, the whole project
14
+ --format text|json|github default: text
15
+ --fix apply the fixes that are certain: what only got another name
16
+ --update-baseline accept what is there now, report only new findings
17
+ --max-warnings <n> exit 1 above this number of warnings
18
+ --select <groups or rules> only these, comma separated
19
+ --ignore <groups or rules> all but these
20
+ --statistics count per rule instead of listing every finding
21
+ --stdin --filename <name> check a snippet instead of files
22
+ nldd explain <rule> what a rule checks, and why
23
+ nldd rules [--for <tag>] [--group <group>] [--json]
24
+ list the rules, or those about one component or group
25
+ groups: api, a11y, copy, structure, pattern
26
+ `;
27
+
28
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
29
+
30
+ function findRule(data, id) {
31
+ const rule = data.rules.find((r) => r.id === id || r.aliases?.includes(id));
32
+ if (rule) return rule;
33
+ return BUILT_IN_RULES[id] ? { id, group: 'api', ...BUILT_IN_RULES[id], message: BUILT_IN_RULES[id].description } : undefined;
34
+ }
35
+
36
+ function explain(data, id) {
37
+ const rule = findRule(data, id);
38
+ if (!rule) {
39
+ console.error(`Unknown rule: ${id}`);
40
+ return 2;
41
+ }
42
+ const lines = [`${rule.id} (${rule.group}, ${rule.severity})`, '', rule.message];
43
+ if (rule.url) lines.push('', `Why: ${rule.url}`);
44
+ if (rule.runtime) lines.push('', 'Only the running page can tell, so this runs in the browser while developing.');
45
+ if (rule.examples) {
46
+ lines.push('', 'Fine:', ...rule.examples.passed.map((example) => ` ${example}`));
47
+ lines.push('', 'Wrong:', ...rule.examples.failed.map((example) => ` ${example}`));
48
+ }
49
+ console.log(lines.join('\n'));
50
+ return 0;
51
+ }
52
+
53
+ function listRules(data, { tag, group, json }) {
54
+ if (group && !GROUPS.includes(group)) throw new Error(`Unknown group: ${group}. Use one of ${GROUPS.join(', ')}.`);
55
+ const rules = (tag ? rulesAboutTag(data.rules, tag) : data.rules).filter((rule) => !group || rule.group === group);
56
+ if (json) console.log(JSON.stringify(rules, null, 2));
57
+ else for (const rule of rules) console.log(`${rule.id} (${rule.group}, ${rule.severity}) ${rule.message}`);
58
+ return 0;
59
+ }
60
+
61
+ /** Walks up, so a package in a monorepo finds the version hoisted to the root. */
62
+ function installedVersion(directory) {
63
+ for (;;) {
64
+ const path = join(directory, 'node_modules/@nldd/design-system/package.json');
65
+ if (existsSync(path)) return JSON.parse(readFileSync(path, 'utf8')).version;
66
+ const parent = dirname(directory);
67
+ if (parent === directory) return undefined;
68
+ directory = parent;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * The linter knows the API of its own version, so a project's own `nldd` is always
74
+ * right. A newer one, through `npx @nldd/design-system@latest`, is how you see what
75
+ * an upgrade will break: useful, as long as it is clear that is what you are looking at.
76
+ */
77
+ function noteOtherVersion(root) {
78
+ const installed = installedVersion(root);
79
+ if (installed && installed !== pkg.version) {
80
+ console.error(`Checking against ${pkg.version}, and this project has ${installed}: findings say what changes on upgrading.`);
81
+ }
82
+ }
83
+
84
+ /** Writing back what was read as UTF-8 would destroy any other encoding. */
85
+ function isUtf8(filename) {
86
+ const bytes = readFileSync(filename);
87
+ return bytes.equals(Buffer.from(bytes.toString('utf8')));
88
+ }
89
+
90
+ /** The tag is gone from the markup; what still names it would break or stop matching. */
91
+ function fixReferences(renamedTags, paths, root, exclude) {
92
+ const isBuilt = (file) => relative(root, file).split(sep).some((part) => IGNORED_DIRECTORIES.has(part));
93
+ const inMarkup = findFiles(paths, root, exclude);
94
+ const elsewhere = findFiles(paths, root, exclude, REFERENCE_EXTENSIONS).filter((file) => REFERENCE_EXTENSIONS.includes(extname(file)));
95
+ let fixed = 0;
96
+ let files = 0;
97
+ const remaining = [];
98
+ const kindOf = (file) => (inMarkup.includes(file) ? 'markup' : /\.(css|scss|less)$/.test(file) ? 'styles' : 'script');
99
+ for (const list of [inMarkup, elsewhere]) {
100
+ for (const filename of list.filter((file) => !/\.min\.[cm]?js$/.test(file))) {
101
+ const source = readFileSync(filename, 'utf8');
102
+ const change = isBuilt(filename) ? { source, fixed: 0 } : renameReferences(source, renamedTags, kindOf(filename));
103
+ if (change.fixed > 0 && isUtf8(filename)) {
104
+ writeFileSync(filename, change.source);
105
+ fixed += change.fixed;
106
+ files += 1;
107
+ }
108
+ for (const line of linesNaming(change.source, renamedTags)) remaining.push(`${relative(root, filename)}:${line}`);
109
+ }
110
+ }
111
+ return { fixed, files, remaining };
112
+ }
113
+
114
+ const MAX_FIX_PASSES = 10;
115
+
116
+ /** One fix can open the way for the next: a renamed tag has rules of its own. */
117
+ async function fixUntilStable(linter, original, filename) {
118
+ let source = original;
119
+ let fixed = 0;
120
+ const renamedTags = new Map();
121
+ for (let pass = 0; pass < MAX_FIX_PASSES; pass++) {
122
+ const { findings } = await linter.lintSource(source, filename);
123
+ const change = applyFixes(source, findings);
124
+ if (change.fixed === 0) return { source, fixed, renamedTags, findings };
125
+ source = change.source;
126
+ fixed += change.fixed;
127
+ for (const [from, to] of change.renamedTags) renamedTags.set(from, to);
128
+ }
129
+ return { source, fixed, renamedTags, findings: (await linter.lintSource(source, filename)).findings };
130
+ }
131
+
132
+ async function runLint(data, paths, options) {
133
+ if (!/^\d+$/.test(options['max-warnings'] ?? '0')) throw new Error('--max-warnings takes a whole number, 0 or more.');
134
+ const formatName = options.format ?? 'text';
135
+ const chosen = { text: formatText, json: formatJson, github: formatGithub }[formatName];
136
+ if (!chosen) throw new Error(`Unknown format: ${formatName}`);
137
+ if (options.statistics && formatName !== 'text') throw new Error('--statistics is plain text, so it takes no --format.');
138
+ if (options['update-baseline'] && (options.select || options.ignore)) {
139
+ throw new Error('--update-baseline takes no --select or --ignore: it would forget every finding outside them.');
140
+ }
141
+ const root = process.cwd();
142
+ const started = performance.now();
143
+ if (options.fix && (options.stdin || options['update-baseline'])) {
144
+ throw new Error('--fix writes files, so it takes no --stdin or --update-baseline.');
145
+ }
146
+ const known = new Set([...data.rules.flatMap((r) => [r.id, ...(r.aliases ?? [])]), ...Object.keys(BUILT_IN_RULES), ...GROUPS]);
147
+ const list = (value) => value?.split(',').map((key) => key.trim());
148
+ const select = list(options.select);
149
+ const ignore = list(options.ignore);
150
+ for (const key of [...(select ?? []), ...(ignore ?? [])]) {
151
+ if (!known.has(key)) throw new Error(`Unknown rule or group: ${key}`);
152
+ }
153
+ const config = readConfig(root, known);
154
+ noteOtherVersion(root);
155
+ const canonical = createCanonical(data);
156
+
157
+ const inputs = options.stdin
158
+ ? [{ filename: resolve(root, options.filename ?? 'stdin.html'), source: readFileSync(0, 'utf8') }]
159
+ : findFiles(paths, root, config.exclude).map((filename) => ({
160
+ filename,
161
+ source: readFileSync(filename, 'utf8'),
162
+ }));
163
+
164
+ // Most files in an app use no component at all, and those need no parser either.
165
+ const relevant = inputs.filter(({ source }) => /nldd-|Nldd/.test(source) || config.wrappers);
166
+ const results = [];
167
+ let fixed = 0;
168
+ let fixedFiles = 0;
169
+ const renamedTags = new Map();
170
+ if (relevant.length > 0) {
171
+ const { createLinter } = await import('./linter.js');
172
+ const linter = createLinter(data, { wrappers: config.wrappers, severities: resolveSeverities(data, config.rules, { select, ignore }) });
173
+ for (const { filename, source } of relevant) {
174
+ const canWrite = options.fix && isUtf8(filename);
175
+ if (options.fix && !canWrite) console.error(`Skipped ${relative(root, filename)}: it is not UTF-8.`);
176
+ if (!canWrite) {
177
+ results.push({ filename, source, ...(await linter.lintSource(source, filename)) });
178
+ continue;
179
+ }
180
+ const change = await fixUntilStable(linter, source, filename);
181
+ if (change.fixed > 0) {
182
+ writeFileSync(filename, change.source);
183
+ fixed += change.fixed;
184
+ fixedFiles += 1;
185
+ for (const [from, to] of change.renamedTags) renamedTags.set(from, to);
186
+ }
187
+ results.push({ filename, source: change.source, findings: change.findings });
188
+ }
189
+ }
190
+ if (options.fix) console.error(`Fixed ${fixed} in ${fixedFiles} of ${inputs.length} files.`);
191
+ if (renamedTags.size > 0) {
192
+ const references = fixReferences(renamedTags, paths, root, config.exclude);
193
+ if (references.fixed > 0) console.error(`Renamed ${references.fixed} imports, classes and selectors of old tags in ${references.files} files.`);
194
+ for (const place of references.remaining) console.error(`Still names an old tag: ${place}`);
195
+ if (paths.some((path) => resolve(root, path) !== root)) {
196
+ console.error('Only in the paths you named: run it without paths to reach the rest of the project.');
197
+ }
198
+ }
199
+
200
+ if (options['update-baseline']) {
201
+ writeBaseline(results, root, canonical);
202
+ const accepted = results.flatMap(({ findings }) => findings).filter(({ severity }) => severity !== 'hint').length;
203
+ console.log(`Baseline updated: ${accepted} findings accepted.`);
204
+ return 0;
205
+ }
206
+
207
+ const baseline = readBaseline(root, canonical);
208
+ let skipped = 0;
209
+ const reported = results.map((result) => {
210
+ const fresh = applyBaseline(result.filename, result.findings, baseline, root);
211
+ skipped += result.findings.length - fresh.length;
212
+ return { ...result, findings: fresh };
213
+ });
214
+
215
+ const context = {
216
+ root,
217
+ files: inputs.length,
218
+ ms: Math.round(performance.now() - started),
219
+ skipped,
220
+ explainRule: (id) => findRule(data, id),
221
+ };
222
+ const format = options.statistics ? formatStatistics : chosen;
223
+ const output = format(reported, context);
224
+ if (output) console.log(output);
225
+
226
+ const all = reported.flatMap((result) => result.findings);
227
+ const errors = all.filter((finding) => finding.severity === 'error').length;
228
+ const warnings = all.filter((finding) => finding.severity === 'warn').length;
229
+ const tooManyWarnings =
230
+ options['max-warnings'] !== undefined && warnings > Number(options['max-warnings']);
231
+ return errors > 0 || tooManyWarnings ? 1 : 0;
232
+ }
233
+
234
+ async function main() {
235
+ const { values, positionals } = parseArgs({
236
+ allowPositionals: true,
237
+ options: {
238
+ format: { type: 'string' },
239
+ 'update-baseline': { type: 'boolean' },
240
+ 'max-warnings': { type: 'string' },
241
+ stdin: { type: 'boolean' },
242
+ filename: { type: 'string' },
243
+ for: { type: 'string' },
244
+ group: { type: 'string' },
245
+ select: { type: 'string' },
246
+ ignore: { type: 'string' },
247
+ statistics: { type: 'boolean' },
248
+ fix: { type: 'boolean' },
249
+ json: { type: 'boolean' },
250
+ version: { type: 'boolean', short: 'v' },
251
+ help: { type: 'boolean', short: 'h' },
252
+ },
253
+ });
254
+ if (values.version) {
255
+ console.log(pkg.version);
256
+ return 0;
257
+ }
258
+ const [command, ...rest] = positionals;
259
+ if (values.help || !command) {
260
+ console.log(USAGE);
261
+ return command || values.help ? 0 : 2;
262
+ }
263
+ const data = loadData();
264
+ if (command === 'lint') return runLint(data, rest, values);
265
+ if (command === 'explain' && rest[0]) return explain(data, rest[0]);
266
+ if (command === 'rules') return listRules(data, { tag: values.for, group: values.group, json: values.json });
267
+ console.error(USAGE);
268
+ return 2;
269
+ }
270
+
271
+ main().then(
272
+ (code) => {
273
+ process.exitCode = code;
274
+ },
275
+ (error) => {
276
+ console.error(error.message);
277
+ process.exitCode = 2;
278
+ },
279
+ );
@@ -0,0 +1,143 @@
1
+ /** Everything about the consumer's project: its files, config and baseline. */
2
+
3
+ import { execFileSync } from 'node:child_process';
4
+ import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
5
+ import { extname, join, relative, resolve } from 'node:path';
6
+
7
+ export const IGNORED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', 'coverage', '.git', '.next', '.nuxt']);
8
+ /** Markdown is linted on request: documentation is full of deliberately wrong examples. */
9
+ const DEFAULT_EXTENSIONS = ['.html', '.htm', '.j2', '.jinja', '.jinja2', '.vue', '.jsx', '.tsx'];
10
+
11
+ /** Where a tag name stands outside markup: the linter does not read these, a renamed tag does. */
12
+ export const REFERENCE_EXTENSIONS = ['.js', '.mjs', '.cjs', '.ts', '.css', '.scss', '.less'];
13
+
14
+ function walkDirectory(directory, found, extensions) {
15
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
16
+ if (entry.isDirectory()) {
17
+ if (!IGNORED_DIRECTORIES.has(entry.name)) walkDirectory(join(directory, entry.name), found, extensions);
18
+ } else if (extensions.includes(extname(entry.name))) {
19
+ found.push(join(directory, entry.name));
20
+ }
21
+ }
22
+ return found;
23
+ }
24
+
25
+ /** `git ls-files` honors .gitignore without this tool parsing it. */
26
+ function trackedFiles(root, extensions) {
27
+ try {
28
+ const output = execFileSync('git', ['ls-files', '-coz', '--exclude-standard'], {
29
+ cwd: root,
30
+ encoding: 'utf8',
31
+ stdio: ['ignore', 'pipe', 'ignore'],
32
+ maxBuffer: 256 * 1024 * 1024,
33
+ });
34
+ return output
35
+ .split('\0')
36
+ .filter((file) => extensions.includes(extname(file)))
37
+ .map((file) => join(root, file));
38
+ } catch {
39
+ return undefined;
40
+ }
41
+ }
42
+
43
+ function matchesExclude(path, patterns) {
44
+ return patterns.some((pattern) => path.includes(pattern));
45
+ }
46
+
47
+ export function findFiles(paths, root, exclude = [], extensions = DEFAULT_EXTENSIONS) {
48
+ const files =
49
+ paths.length === 0
50
+ ? (trackedFiles(root, extensions) ?? walkDirectory(root, [], extensions))
51
+ : paths.flatMap((path) => {
52
+ const full = resolve(root, path);
53
+ if (!existsSync(full)) throw new Error(`No such file or directory: ${path}`);
54
+ return statSync(full).isDirectory() ? walkDirectory(full, [], extensions) : [full];
55
+ });
56
+ return [...new Set(files)].filter((file) => existsSync(file) && !matchesExclude(relative(root, file), exclude));
57
+ }
58
+
59
+ const CONFIG_FILE = '.nldd-lint.json';
60
+
61
+ export function readConfig(root, knownRules) {
62
+ const path = join(root, CONFIG_FILE);
63
+ if (!existsSync(path)) return {};
64
+ let config;
65
+ try {
66
+ config = JSON.parse(readFileSync(path, 'utf8'));
67
+ } catch (error) {
68
+ throw new Error(`${CONFIG_FILE}: ${error.message}`);
69
+ }
70
+ const isMap = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
71
+ if (!isMap(config)) throw new Error(`${CONFIG_FILE}: expected an object.`);
72
+ if (config.rules !== undefined && !isMap(config.rules)) throw new Error(`${CONFIG_FILE}: "rules" takes an object.`);
73
+ if (config.wrappers !== undefined && (!isMap(config.wrappers) || !Object.values(config.wrappers).every((tag) => typeof tag === 'string'))) {
74
+ throw new Error(`${CONFIG_FILE}: "wrappers" maps a component to a tag name.`);
75
+ }
76
+ if (config.exclude !== undefined && !Array.isArray(config.exclude)) throw new Error(`${CONFIG_FILE}: "exclude" takes a list.`);
77
+ for (const [rule, level] of Object.entries(config.rules ?? {})) {
78
+ if (!knownRules.has(rule)) throw new Error(`${CONFIG_FILE}: unknown rule "${rule}".`);
79
+ if (!['off', 'hint', 'warn', 'error'].includes(level)) {
80
+ throw new Error(`${CONFIG_FILE}: "${rule}" takes off, hint, warn or error, not ${JSON.stringify(level)}.`);
81
+ }
82
+ }
83
+ return config;
84
+ }
85
+
86
+ export const BASELINE_FILE = '.nldd-lint-baseline.json';
87
+
88
+ /**
89
+ * Counts per file, rule and tag rather than positions, so moving code around
90
+ * does not turn accepted findings into new ones. The findings in a file beyond
91
+ * the accepted count are the new ones.
92
+ */
93
+ function mergeRenamed(entries, canonical) {
94
+ const merged = {};
95
+ for (const [key, count] of Object.entries(entries)) {
96
+ const [rule, ...tag] = key.split('|');
97
+ const renamed = [canonical(rule), ...tag].join('|');
98
+ merged[renamed] = (merged[renamed] ?? 0) + count;
99
+ }
100
+ return merged;
101
+ }
102
+
103
+ export function readBaseline(root, canonical = (id) => id) {
104
+ const path = join(root, BASELINE_FILE);
105
+ if (!existsSync(path)) return {};
106
+ const baseline = JSON.parse(readFileSync(path, 'utf8'));
107
+ return Object.fromEntries(
108
+ Object.entries(baseline).map(([file, entries]) => [
109
+ file,
110
+ mergeRenamed(entries, canonical),
111
+ ]),
112
+ );
113
+ }
114
+
115
+ const baselineKey = ({ rule, tag }) => `${rule}|${tag}`;
116
+
117
+ export function applyBaseline(filename, findings, baseline, root) {
118
+ const accepted = { ...baseline[relative(root, filename)] };
119
+ return findings.filter((finding) => {
120
+ const key = baselineKey(finding);
121
+ // A hint is never in a baseline, so it must not use up a warning of the same rule.
122
+ if (finding.severity === 'hint' || !accepted[key]) return true;
123
+ accepted[key]--;
124
+ return false;
125
+ });
126
+ }
127
+
128
+ export function writeBaseline(results, root, canonical) {
129
+ const baseline = readBaseline(root, canonical);
130
+ for (const { filename, findings } of results) {
131
+ const key = relative(root, filename);
132
+ delete baseline[key];
133
+ if (findings.every(({ severity }) => severity === 'hint')) continue;
134
+ baseline[key] = {};
135
+ // A hint fails nothing, so there is nothing to accept.
136
+ for (const finding of findings.filter(({ severity }) => severity !== 'hint')) {
137
+ const entry = baselineKey(finding);
138
+ baseline[key][entry] = (baseline[key][entry] ?? 0) + 1;
139
+ }
140
+ }
141
+ const sorted = Object.fromEntries(Object.entries(baseline).sort(([a], [b]) => a.localeCompare(b)));
142
+ writeFileSync(join(root, BASELINE_FILE), `${JSON.stringify(sorted, null, '\t')}\n`);
143
+ }