@jomae/catalog 0.6.0 → 0.9.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 (194) hide show
  1. package/README.md +1 -1
  2. package/dist/generated/baseline-history.js +4 -4
  3. package/dist/generated/baseline.d.ts.map +1 -1
  4. package/dist/generated/baseline.js +113 -1
  5. package/dist/generated/baseline.js.map +1 -1
  6. package/dist/generated/guides.d.ts.map +1 -1
  7. package/dist/generated/guides.js +6 -2
  8. package/dist/generated/guides.js.map +1 -1
  9. package/dist/generated/lint-rules.d.ts +26 -0
  10. package/dist/generated/lint-rules.d.ts.map +1 -0
  11. package/dist/generated/lint-rules.js +361 -0
  12. package/dist/generated/lint-rules.js.map +1 -0
  13. package/dist/generated/sizes.d.ts.map +1 -1
  14. package/dist/generated/sizes.js +128 -13
  15. package/dist/generated/sizes.js.map +1 -1
  16. package/dist/generated/support-claims.d.ts.map +1 -1
  17. package/dist/generated/support-claims.js +7 -1
  18. package/dist/generated/support-claims.js.map +1 -1
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/lint.d.ts +53 -0
  24. package/dist/lint.d.ts.map +1 -0
  25. package/dist/lint.js +41 -0
  26. package/dist/lint.js.map +1 -0
  27. package/dist/markdown.d.ts +31 -0
  28. package/dist/markdown.d.ts.map +1 -0
  29. package/dist/markdown.js +273 -0
  30. package/dist/markdown.js.map +1 -0
  31. package/dist/rules/abort-controller.d.ts.map +1 -1
  32. package/dist/rules/abort-controller.js +3 -0
  33. package/dist/rules/abort-controller.js.map +1 -1
  34. package/dist/rules/accordion.d.ts.map +1 -1
  35. package/dist/rules/accordion.js +3 -0
  36. package/dist/rules/accordion.js.map +1 -1
  37. package/dist/rules/array-grouping.d.ts.map +1 -1
  38. package/dist/rules/array-grouping.js +1 -0
  39. package/dist/rules/array-grouping.js.map +1 -1
  40. package/dist/rules/aspect-ratio.d.ts.map +1 -1
  41. package/dist/rules/aspect-ratio.js +4 -0
  42. package/dist/rules/aspect-ratio.js.map +1 -1
  43. package/dist/rules/base64.d.ts.map +1 -1
  44. package/dist/rules/base64.js +3 -0
  45. package/dist/rules/base64.js.map +1 -1
  46. package/dist/rules/broadcast-channel.d.ts.map +1 -1
  47. package/dist/rules/broadcast-channel.js +3 -0
  48. package/dist/rules/broadcast-channel.js.map +1 -1
  49. package/dist/rules/carousel.d.ts.map +1 -1
  50. package/dist/rules/carousel.js +5 -0
  51. package/dist/rules/carousel.js.map +1 -1
  52. package/dist/rules/clipboard.d.ts.map +1 -1
  53. package/dist/rules/clipboard.js +3 -0
  54. package/dist/rules/clipboard.js.map +1 -1
  55. package/dist/rules/container-queries.d.ts.map +1 -1
  56. package/dist/rules/container-queries.js +3 -0
  57. package/dist/rules/container-queries.js.map +1 -1
  58. package/dist/rules/date-time-input.d.ts.map +1 -1
  59. package/dist/rules/date-time-input.js +4 -0
  60. package/dist/rules/date-time-input.js.map +1 -1
  61. package/dist/rules/dialog.d.ts.map +1 -1
  62. package/dist/rules/dialog.js +4 -0
  63. package/dist/rules/dialog.js.map +1 -1
  64. package/dist/rules/discrete-transitions.d.ts.map +1 -1
  65. package/dist/rules/discrete-transitions.js +4 -0
  66. package/dist/rules/discrete-transitions.js.map +1 -1
  67. package/dist/rules/display-names.d.ts +3 -0
  68. package/dist/rules/display-names.d.ts.map +1 -0
  69. package/dist/rules/display-names.js +33 -0
  70. package/dist/rules/display-names.js.map +1 -0
  71. package/dist/rules/duration-format.d.ts.map +1 -1
  72. package/dist/rules/duration-format.js +3 -0
  73. package/dist/rules/duration-format.js.map +1 -1
  74. package/dist/rules/event-target.d.ts.map +1 -1
  75. package/dist/rules/event-target.js +1 -0
  76. package/dist/rules/event-target.js.map +1 -1
  77. package/dist/rules/focus-visible.d.ts.map +1 -1
  78. package/dist/rules/focus-visible.js +4 -0
  79. package/dist/rules/focus-visible.js.map +1 -1
  80. package/dist/rules/fullscreen.d.ts.map +1 -1
  81. package/dist/rules/fullscreen.js +3 -0
  82. package/dist/rules/fullscreen.js.map +1 -1
  83. package/dist/rules/height-animation.d.ts.map +1 -1
  84. package/dist/rules/height-animation.js +5 -1
  85. package/dist/rules/height-animation.js.map +1 -1
  86. package/dist/rules/index.d.ts.map +1 -1
  87. package/dist/rules/index.js +16 -0
  88. package/dist/rules/index.js.map +1 -1
  89. package/dist/rules/inert.d.ts.map +1 -1
  90. package/dist/rules/inert.js +4 -0
  91. package/dist/rules/inert.js.map +1 -1
  92. package/dist/rules/intersection-observer.d.ts.map +1 -1
  93. package/dist/rules/intersection-observer.js +1 -0
  94. package/dist/rules/intersection-observer.js.map +1 -1
  95. package/dist/rules/lazy-loading.d.ts.map +1 -1
  96. package/dist/rules/lazy-loading.js +4 -0
  97. package/dist/rules/lazy-loading.js.map +1 -1
  98. package/dist/rules/line-clamp.d.ts.map +1 -1
  99. package/dist/rules/line-clamp.js +4 -0
  100. package/dist/rules/line-clamp.js.map +1 -1
  101. package/dist/rules/list-format.d.ts +3 -0
  102. package/dist/rules/list-format.d.ts.map +1 -0
  103. package/dist/rules/list-format.js +37 -0
  104. package/dist/rules/list-format.js.map +1 -0
  105. package/dist/rules/masonry.d.ts.map +1 -1
  106. package/dist/rules/masonry.js +4 -0
  107. package/dist/rules/masonry.js.map +1 -1
  108. package/dist/rules/natural-sort.d.ts.map +1 -1
  109. package/dist/rules/natural-sort.js +4 -0
  110. package/dist/rules/natural-sort.js.map +1 -1
  111. package/dist/rules/number-format.d.ts.map +1 -1
  112. package/dist/rules/number-format.js +4 -0
  113. package/dist/rules/number-format.js.map +1 -1
  114. package/dist/rules/page-visibility.d.ts.map +1 -1
  115. package/dist/rules/page-visibility.js +3 -0
  116. package/dist/rules/page-visibility.js.map +1 -1
  117. package/dist/rules/popover.d.ts.map +1 -1
  118. package/dist/rules/popover.js +5 -0
  119. package/dist/rules/popover.js.map +1 -1
  120. package/dist/rules/random-uuid.d.ts.map +1 -1
  121. package/dist/rules/random-uuid.js +4 -0
  122. package/dist/rules/random-uuid.js.map +1 -1
  123. package/dist/rules/relative-time.d.ts.map +1 -1
  124. package/dist/rules/relative-time.js +4 -0
  125. package/dist/rules/relative-time.js.map +1 -1
  126. package/dist/rules/resizable-panels.d.ts.map +1 -1
  127. package/dist/rules/resizable-panels.js +3 -0
  128. package/dist/rules/resizable-panels.js.map +1 -1
  129. package/dist/rules/resize-observer.d.ts.map +1 -1
  130. package/dist/rules/resize-observer.js +4 -0
  131. package/dist/rules/resize-observer.js.map +1 -1
  132. package/dist/rules/scroll-animations.d.ts.map +1 -1
  133. package/dist/rules/scroll-animations.js +4 -0
  134. package/dist/rules/scroll-animations.js.map +1 -1
  135. package/dist/rules/scroll-lock.d.ts.map +1 -1
  136. package/dist/rules/scroll-lock.js +3 -0
  137. package/dist/rules/scroll-lock.js.map +1 -1
  138. package/dist/rules/scrollbars.d.ts.map +1 -1
  139. package/dist/rules/scrollbars.js +3 -0
  140. package/dist/rules/scrollbars.js.map +1 -1
  141. package/dist/rules/segmenter.d.ts +3 -0
  142. package/dist/rules/segmenter.d.ts.map +1 -0
  143. package/dist/rules/segmenter.js +41 -0
  144. package/dist/rules/segmenter.js.map +1 -0
  145. package/dist/rules/select.d.ts.map +1 -1
  146. package/dist/rules/select.js +3 -0
  147. package/dist/rules/select.js.map +1 -1
  148. package/dist/rules/signal-timeout.d.ts +3 -0
  149. package/dist/rules/signal-timeout.d.ts.map +1 -0
  150. package/dist/rules/signal-timeout.js +31 -0
  151. package/dist/rules/signal-timeout.js.map +1 -0
  152. package/dist/rules/smooth-scroll.d.ts.map +1 -1
  153. package/dist/rules/smooth-scroll.js +4 -0
  154. package/dist/rules/smooth-scroll.js.map +1 -1
  155. package/dist/rules/sticky.d.ts.map +1 -1
  156. package/dist/rules/sticky.js +4 -0
  157. package/dist/rules/sticky.js.map +1 -1
  158. package/dist/rules/structured-clone.d.ts.map +1 -1
  159. package/dist/rules/structured-clone.js +1 -0
  160. package/dist/rules/structured-clone.js.map +1 -1
  161. package/dist/rules/text-wrap-balance.d.ts.map +1 -1
  162. package/dist/rules/text-wrap-balance.js +3 -0
  163. package/dist/rules/text-wrap-balance.js.map +1 -1
  164. package/dist/rules/url-pattern.d.ts +3 -0
  165. package/dist/rules/url-pattern.d.ts.map +1 -0
  166. package/dist/rules/url-pattern.js +36 -0
  167. package/dist/rules/url-pattern.js.map +1 -0
  168. package/dist/rules/url-search-params.d.ts.map +1 -1
  169. package/dist/rules/url-search-params.js +1 -0
  170. package/dist/rules/url-search-params.js.map +1 -1
  171. package/dist/rules/web-animations.d.ts +3 -0
  172. package/dist/rules/web-animations.d.ts.map +1 -0
  173. package/dist/rules/web-animations.js +40 -0
  174. package/dist/rules/web-animations.js.map +1 -0
  175. package/dist/rules/web-locks.d.ts +3 -0
  176. package/dist/rules/web-locks.d.ts.map +1 -0
  177. package/dist/rules/web-locks.js +35 -0
  178. package/dist/rules/web-locks.js.map +1 -0
  179. package/dist/rules/web-share.d.ts.map +1 -1
  180. package/dist/rules/web-share.js +3 -0
  181. package/dist/rules/web-share.js.map +1 -1
  182. package/dist/rules/with-resolvers.d.ts +3 -0
  183. package/dist/rules/with-resolvers.d.ts.map +1 -0
  184. package/dist/rules/with-resolvers.js +30 -0
  185. package/dist/rules/with-resolvers.js.map +1 -0
  186. package/dist/schema.d.ts +4 -0
  187. package/dist/schema.d.ts.map +1 -1
  188. package/dist/schema.js +34 -0
  189. package/dist/schema.js.map +1 -1
  190. package/dist/search.d.ts +29 -0
  191. package/dist/search.d.ts.map +1 -0
  192. package/dist/search.js +84 -0
  193. package/dist/search.js.map +1 -0
  194. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"text-wrap-balance.js","sourceRoot":"","sources":["../../src/rules/text-wrap-balance.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAS;IACnC,EAAE,EAAE,mBAAmB;IACvB,KAAK,EAAE,mBAAmB;IAC1B,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,CAAC,qBAAqB,EAAE,cAAc,CAAC;IACjD,UAAU,EAAE,CAAC,mBAAmB,CAAC;IACjC,MAAM,EAAE,oBAAoB;IAC5B,KAAK,EAAE;QACL,SAAS,EACP,qbAAqb;QACvb,OAAO,EAAE;;;;;;;;;;;EAWX;QACE,MAAM,EAAE,4DAA4D;KACrE;IACD,KAAK,EAAE;QACL,IAAI,EAAE,gFAAgF;QACtF,MAAM,EAAE;YACN,4JAA4J;YAC5J,mKAAmK;YACnK,gIAAgI;YAChI,gJAAgJ;SACjJ;QACD,OAAO,EAAE;yBACY;KACtB;IACD,MAAM,EAAE,CAAC,oCAAoC,CAAC;CAC/C,CAAC"}
1
+ {"version":3,"file":"text-wrap-balance.js","sourceRoot":"","sources":["../../src/rules/text-wrap-balance.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAS;IACnC,EAAE,EAAE,mBAAmB;IACvB,KAAK,EAAE,mBAAmB;IAC1B,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,CAAC,qBAAqB,EAAE,cAAc,CAAC;IACjD,UAAU,EAAE,CAAC,mBAAmB,CAAC;IACjC,MAAM,EAAE,oBAAoB;IAC5B,KAAK,EAAE;QACL,SAAS,EACP,qbAAqb;QACvb,OAAO,EAAE;;;;;;;;;;;EAWX;QACE,MAAM,EAAE,4DAA4D;KACrE;IACD,KAAK,EAAE;QACL,IAAI,EAAE,gFAAgF;QACtF,MAAM,EAAE;YACN,4JAA4J;YAC5J,mKAAmK;YACnK,gIAAgI;YAChI,gJAAgJ;SACjJ;QACD,OAAO,EAAE;yBACY;QACrB,UAAU,EAAE;YACV,0GAA0G;SAC3G;KACF;IACD,MAAM,EAAE,CAAC,oCAAoC,CAAC;CAC/C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from "../schema.ts";
2
+ export declare const urlPattern: Rule;
3
+ //# sourceMappingURL=url-pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-pattern.d.ts","sourceRoot":"","sources":["../../src/rules/url-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,UAAU,EAAE,IAmCxB,CAAC"}
@@ -0,0 +1,36 @@
1
+ export const urlPattern = {
2
+ id: "urlpattern",
3
+ title: "Matching URL patterns",
4
+ category: "async-data",
5
+ replaces: ["path-to-regexp", "url-pattern", "route-parser"],
6
+ featureIds: ["urlpattern"],
7
+ native: "URLPattern",
8
+ human: {
9
+ explainer: 'These libraries compile a route string such as "/users/:id" into a regular expression and hand back the named groups when it matches. URLPattern is that same idea built in, with one extra: it matches every part of a URL, so protocol, hostname and search can take part in the pattern rather than only the path. A match returns an object keyed by URL part, each with its own groups.',
10
+ snippet: `const pattern = new URLPattern({ pathname: "/users/:id/posts/:postId" });
11
+
12
+ pattern.test("https://example.com/users/42/posts/7"); // true
13
+
14
+ const match = pattern.exec("https://example.com/users/42/posts/7");
15
+ match.pathname.groups; // { id: "42", postId: "7" }
16
+
17
+ // Other parts of the URL can take part too.
18
+ new URLPattern({ hostname: ":tenant.example.com" })
19
+ .exec("https://acme.example.com/")
20
+ .hostname.groups; // { tenant: "acme" }`,
21
+ mdnUrl: "https://developer.mozilla.org/en-US/docs/Web/API/URLPattern",
22
+ },
23
+ agent: {
24
+ when: "matching a URL against a route pattern and reading the named parameters",
25
+ unless: [
26
+ 'You build URLs from the pattern as well as matching them. path-to-regexp\'s compile() turns "/users/:id" plus params back into a path, and URLPattern only goes in the matching direction.',
27
+ "You are replacing the matcher inside a router you do not control. Express and React Router depend on path-to-regexp directly, so it stays in the tree regardless of what your own code uses.",
28
+ "Your routes rely on path-to-regexp syntax that does not carry over, such as its custom match patterns or its handling of unnamed groups. The two syntaxes are close enough to look interchangeable and different enough to break quietly.",
29
+ "The code runs on a server runtime that has no URLPattern global, which is the case for Node before it shipped one.",
30
+ ],
31
+ snippet: `const pattern = new URLPattern({ pathname: "/users/:id" });
32
+ const match = pattern.exec(url);
33
+ const id = match?.pathname.groups.id;`,
34
+ },
35
+ };
36
+ //# sourceMappingURL=url-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-pattern.js","sourceRoot":"","sources":["../../src/rules/url-pattern.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,EAAE,EAAE,YAAY;IAChB,KAAK,EAAE,uBAAuB;IAC9B,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,CAAC,gBAAgB,EAAE,aAAa,EAAE,cAAc,CAAC;IAC3D,UAAU,EAAE,CAAC,YAAY,CAAC;IAC1B,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE;QACL,SAAS,EACP,8XAA8X;QAChY,OAAO,EAAE;;;;;;;;;;0CAU6B;QACtC,MAAM,EAAE,6DAA6D;KACtE;IACD,KAAK,EAAE;QACL,IAAI,EAAE,yEAAyE;QAC/E,MAAM,EAAE;YACN,4LAA4L;YAC5L,8LAA8L;YAC9L,2OAA2O;YAC3O,oHAAoH;SACrH;QACD,OAAO,EAAE;;sCAEyB;KACnC;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"url-search-params.d.ts","sourceRoot":"","sources":["../../src/rules/url-search-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,eAAe,EAAE,IAyC7B,CAAC"}
1
+ {"version":3,"file":"url-search-params.d.ts","sourceRoot":"","sources":["../../src/rules/url-search-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,eAAe,EAAE,IA0C7B,CAAC"}
@@ -38,5 +38,6 @@ params.get("page");
38
38
  params.getAll("tag");
39
39
  new URLSearchParams({ q: "css" }).toString();`,
40
40
  },
41
+ lintRule: "unicorn/prefer-url-search-parameters",
41
42
  };
42
43
  //# sourceMappingURL=url-search-params.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"url-search-params.js","sourceRoot":"","sources":["../../src/rules/url-search-params.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAS;IACnC,EAAE,EAAE,mBAAmB;IACvB,KAAK,EAAE,sBAAsB;IAC7B,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,CAAC,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,CAAC;IAC/D,UAAU,EAAE,EAAE;IACd,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,6aAA6a;KACpb;IACD,MAAM,EAAE,yCAAyC;IACjD,KAAK,EAAE;QACL,SAAS,EACP,ybAAyb;QAC3b,OAAO,EAAE;;;;;;;;0BAQa;QACtB,MAAM,EAAE,kEAAkE;KAC3E;IACD,KAAK,EAAE;QACL,IAAI,EAAE,4DAA4D;QAClE,MAAM,EAAE;YACN,4JAA4J;YAC5J,0JAA0J;YAC1J,oJAAoJ;YACpJ,mKAAmK;YACnK,iHAAiH;YACjH,6QAA6Q;SAC9Q;QACD,OAAO,EAAE;;;8CAGiC;KAC3C;CACF,CAAC"}
1
+ {"version":3,"file":"url-search-params.js","sourceRoot":"","sources":["../../src/rules/url-search-params.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAS;IACnC,EAAE,EAAE,mBAAmB;IACvB,KAAK,EAAE,sBAAsB;IAC7B,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,CAAC,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,CAAC;IAC/D,UAAU,EAAE,EAAE;IACd,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,6aAA6a;KACpb;IACD,MAAM,EAAE,yCAAyC;IACjD,KAAK,EAAE;QACL,SAAS,EACP,ybAAyb;QAC3b,OAAO,EAAE;;;;;;;;0BAQa;QACtB,MAAM,EAAE,kEAAkE;KAC3E;IACD,KAAK,EAAE;QACL,IAAI,EAAE,4DAA4D;QAClE,MAAM,EAAE;YACN,4JAA4J;YAC5J,0JAA0J;YAC1J,oJAAoJ;YACpJ,mKAAmK;YACnK,iHAAiH;YACjH,6QAA6Q;SAC9Q;QACD,OAAO,EAAE;;;8CAGiC;KAC3C;IACD,QAAQ,EAAE,sCAAsC;CACjD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from "../schema.ts";
2
+ export declare const webAnimations: Rule;
3
+ //# sourceMappingURL=web-animations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-animations.d.ts","sourceRoot":"","sources":["../../src/rules/web-animations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,aAAa,EAAE,IAwC3B,CAAC"}
@@ -0,0 +1,40 @@
1
+ export const webAnimations = {
2
+ id: "web-animations",
3
+ title: "Animating from JavaScript",
4
+ category: "animation",
5
+ replaces: ["animejs", "popmotion", "velocity-animate"],
6
+ featureIds: ["web-animations"],
7
+ native: "element.animate()",
8
+ human: {
9
+ explainer: "These libraries run their own tick loop, working out each frame's values in JavaScript and writing them to the element's style. element.animate() hands the same keyframes to the engine that already runs CSS animations, so transforms and opacity are animated off the main thread and keep going while JavaScript is busy. It returns an Animation with play, pause, reverse, cancel and finish on it, plus a finished promise to await.",
10
+ snippet: `const animation = card.animate(
11
+ [
12
+ { transform: "translateY(12px)", opacity: 0 },
13
+ { transform: "none", opacity: 1 },
14
+ ],
15
+ { duration: 240, easing: "cubic-bezier(0.2, 0, 0, 1)", fill: "both" },
16
+ );
17
+
18
+ await animation.finished;
19
+
20
+ // The same handle drives it afterwards.
21
+ animation.reverse();`,
22
+ mdnUrl: "https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API",
23
+ },
24
+ agent: {
25
+ when: "animating an element's styles from JavaScript and needing a handle to control it",
26
+ unless: [
27
+ "You animate something that is not a CSS property on an element: a number in a counter, a canvas, a scroll offset, an SVG path's shape. anime.js animates arbitrary object properties, where element.animate() only writes styles.",
28
+ "The motion is spring-based or driven by a gesture's velocity. Web Animations takes a duration and an easing curve, so anything that has to respond to how fast a finger was moving is still the library's job.",
29
+ "You sequence many elements on one timeline with staggers and relative offsets. That timeline is the reason a lot of people install anime.js, and composing it by hand means computing every delay yourself.",
30
+ "A plain CSS transition or @keyframes would do. Reaching for element.animate() to fade one element in trades a declarative rule for a script that has to run first.",
31
+ "You animate to an intrinsic size such as height: auto, which is interpolate-size and calc-size rather than either approach here.",
32
+ ],
33
+ snippet: `const animation = card.animate(
34
+ [{ opacity: 0 }, { opacity: 1 }],
35
+ { duration: 240, fill: "both" },
36
+ );
37
+ await animation.finished;`,
38
+ },
39
+ };
40
+ //# sourceMappingURL=web-animations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-animations.js","sourceRoot":"","sources":["../../src/rules/web-animations.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAS;IACjC,EAAE,EAAE,gBAAgB;IACpB,KAAK,EAAE,2BAA2B;IAClC,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,kBAAkB,CAAC;IACtD,UAAU,EAAE,CAAC,gBAAgB,CAAC;IAC9B,MAAM,EAAE,mBAAmB;IAC3B,KAAK,EAAE;QACL,SAAS,EACP,8aAA8a;QAChb,OAAO,EAAE;;;;;;;;;;;qBAWQ;QACjB,MAAM,EACJ,qEAAqE;KACxE;IACD,KAAK,EAAE;QACL,IAAI,EAAE,kFAAkF;QACxF,MAAM,EAAE;YACN,mOAAmO;YACnO,gNAAgN;YAChN,6MAA6M;YAC7M,oKAAoK;YACpK,kIAAkI;SACnI;QACD,OAAO,EAAE;;;;0BAIa;KACvB;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from "../schema.ts";
2
+ export declare const webLocks: Rule;
3
+ //# sourceMappingURL=web-locks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-locks.d.ts","sourceRoot":"","sources":["../../src/rules/web-locks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,QAAQ,EAAE,IAkCtB,CAAC"}
@@ -0,0 +1,35 @@
1
+ export const webLocks = {
2
+ id: "web-locks",
3
+ title: "Mutexes and critical sections",
4
+ category: "async-data",
5
+ replaces: ["async-mutex", "await-lock", "mutexify", "p-mutex"],
6
+ featureIds: ["web-locks"],
7
+ native: "navigator.locks.request()",
8
+ human: {
9
+ explainer: "These packages stop two callers entering the same critical section at once by queueing them behind a promise chain held in module memory. navigator.locks.request() does the same queueing, with one difference that decides whether it fits: the browser owns the lock, so it also serialises across every tab, iframe and worker on the origin. The lock is released when your callback's promise settles, including when it throws, so there is no release() to forget.",
10
+ snippet: `await navigator.locks.request("sync-outbox", async () => {
11
+ await flushPendingWrites();
12
+ });
13
+
14
+ // Many readers, one writer, same as a read/write lock.
15
+ await navigator.locks.request("cache", { mode: "shared" }, async () => {
16
+ return readCache();
17
+ });`,
18
+ mdnUrl: "https://developer.mozilla.org/en-US/docs/Web/API/Web_Locks_API",
19
+ },
20
+ agent: {
21
+ when: "serialising async work so two callers cannot run the same section at once",
22
+ unless: [
23
+ "The code also runs on the server. navigator.locks is a browser API, so anything shared with Node keeps the library. This is the common case for code under a framework that renders on both.",
24
+ "You want the lock scoped to your module. Lock names are strings shared by the whole origin, so an unrelated script picking the same name now blocks you, and a name like 'lock' or 'queue' is a collision waiting to happen. An async-mutex instance is private to whoever holds the reference.",
25
+ "You need a semaphore that admits more than one holder at a time. Web Locks offers exclusive and shared only, where async-mutex ships a counting Semaphore.",
26
+ "The same task can request a lock it already holds. Web Locks is not reentrant, so a nested request for the same name waits for a release that cannot happen until the nested call returns.",
27
+ "The page runs on an opaque origin or outside a secure context: a sandboxed iframe without allow-same-origin, a data: or blob: document, or plain http away from localhost. navigator.locks is still present there, so a presence check passes and request() then rejects with a SecurityError. async-mutex has no such limit.",
28
+ "You support browsers below Chrome {{chrome:web-locks}}, Firefox {{firefox:web-locks}} or Safari {{safari:web-locks}}, and calling into an undefined navigator.locks throws rather than degrading.",
29
+ ],
30
+ snippet: `await navigator.locks.request("sync-outbox", async () => {
31
+ await flushPendingWrites();
32
+ });`,
33
+ },
34
+ };
35
+ //# sourceMappingURL=web-locks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-locks.js","sourceRoot":"","sources":["../../src/rules/web-locks.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAS;IAC5B,EAAE,EAAE,WAAW;IACf,KAAK,EAAE,+BAA+B;IACtC,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,CAAC;IAC9D,UAAU,EAAE,CAAC,WAAW,CAAC;IACzB,MAAM,EAAE,2BAA2B;IACnC,KAAK,EAAE;QACL,SAAS,EACP,4cAA4c;QAC9c,OAAO,EAAE;;;;;;;IAOT;QACA,MAAM,EAAE,gEAAgE;KACzE;IACD,KAAK,EAAE;QACL,IAAI,EAAE,2EAA2E;QACjF,MAAM,EAAE;YACN,8LAA8L;YAC9L,iSAAiS;YACjS,4JAA4J;YAC5J,4LAA4L;YAC5L,+TAA+T;YAC/T,mMAAmM;SACpM;QACD,OAAO,EAAE;;IAET;KACD;CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"web-share.d.ts","sourceRoot":"","sources":["../../src/rules/web-share.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,QAAQ,EAAE,IA4BtB,CAAC"}
1
+ {"version":3,"file":"web-share.d.ts","sourceRoot":"","sources":["../../src/rules/web-share.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,QAAQ,EAAE,IA+BtB,CAAC"}
@@ -23,6 +23,9 @@ export const webShare = {
23
23
  "You need to share a file the person doesn't already have a URL for. That needs the file-sharing variant of the API, which has narrower browser support again.",
24
24
  ],
25
25
  snippet: "await navigator.share({ title: document.title, url: location.href });",
26
+ handRolled: [
27
+ "a share menu built from hardcoded intent URLs for each network, opened with window.open",
28
+ ],
26
29
  },
27
30
  };
28
31
  //# sourceMappingURL=web-share.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-share.js","sourceRoot":"","sources":["../../src/rules/web-share.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAS;IAC5B,EAAE,EAAE,WAAW;IACf,KAAK,EAAE,uBAAuB;IAC9B,QAAQ,EAAE,aAAa;IACvB,QAAQ,EAAE,CAAC,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,CAAC;IACnE,UAAU,EAAE,CAAC,OAAO,CAAC;IACrB,MAAM,EAAE,mBAAmB;IAC3B,KAAK,EAAE;QACL,SAAS,EACP,kSAAkS;QACpS,OAAO,EAAE;;;;;EAKX;QACE,MAAM,EAAE,kEAAkE;KAC3E;IACD,KAAK,EAAE;QACL,IAAI,EAAE,0FAA0F;QAChG,MAAM,EAAE;YACN,kLAAkL;YAClL,yFAAyF;YACzF,+JAA+J;SAChK;QACD,OAAO,EACL,uEAAuE;KAC1E;CACF,CAAC"}
1
+ {"version":3,"file":"web-share.js","sourceRoot":"","sources":["../../src/rules/web-share.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAS;IAC5B,EAAE,EAAE,WAAW;IACf,KAAK,EAAE,uBAAuB;IAC9B,QAAQ,EAAE,aAAa;IACvB,QAAQ,EAAE,CAAC,aAAa,EAAE,oBAAoB,EAAE,kBAAkB,CAAC;IACnE,UAAU,EAAE,CAAC,OAAO,CAAC;IACrB,MAAM,EAAE,mBAAmB;IAC3B,KAAK,EAAE;QACL,SAAS,EACP,kSAAkS;QACpS,OAAO,EAAE;;;;;EAKX;QACE,MAAM,EAAE,kEAAkE;KAC3E;IACD,KAAK,EAAE;QACL,IAAI,EAAE,0FAA0F;QAChG,MAAM,EAAE;YACN,kLAAkL;YAClL,yFAAyF;YACzF,+JAA+J;SAChK;QACD,OAAO,EACL,uEAAuE;QACzE,UAAU,EAAE;YACV,yFAAyF;SAC1F;KACF;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from "../schema.ts";
2
+ export declare const withResolvers: Rule;
3
+ //# sourceMappingURL=with-resolvers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-resolvers.d.ts","sourceRoot":"","sources":["../../src/rules/with-resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,aAAa,EAAE,IA8B3B,CAAC"}
@@ -0,0 +1,30 @@
1
+ export const withResolvers = {
2
+ id: "promise-withresolvers",
3
+ title: "Deferred promises",
4
+ category: "async-data",
5
+ replaces: ["p-defer", "defer-promise"],
6
+ featureIds: ["promise-withresolvers"],
7
+ native: "Promise.withResolvers()",
8
+ human: {
9
+ explainer: "A deferred is a promise with its resolve and reject pulled out, so something outside the executor can settle it later. Writing one by hand means declaring two variables, assigning them inside a new Promise, and trusting that the executor ran first. Promise.withResolvers() returns the promise and both functions in one object, which is the whole of what these packages do.",
10
+ snippet: `const { promise, resolve, reject } = Promise.withResolvers();
11
+
12
+ socket.addEventListener("message", (event) => resolve(event.data));
13
+ socket.addEventListener("error", reject);
14
+
15
+ const firstMessage = await promise;`,
16
+ mdnUrl: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers",
17
+ },
18
+ agent: {
19
+ when: "creating a promise that something else will resolve or reject later",
20
+ unless: [
21
+ "The promise can settle inside its own executor. A deferred passed around is often a sign the async boundary sits in the wrong place, and starting the work inside new Promise needs neither this nor the package.",
22
+ "The package arrived as a transitive dependency. p-defer is pulled in by a good deal of the sindresorhus ecosystem, so removing your own import may not remove it from the tree.",
23
+ "You support browsers below Chrome {{chrome:promise-withresolvers}}, Firefox {{firefox:promise-withresolvers}} or Safari {{safari:promise-withresolvers}}, or a server runtime that predates it.",
24
+ "You need more than the three fields, such as a settled flag or a timeout, in which case you are writing a small class and the package is not what it costs.",
25
+ ],
26
+ snippet: "const { promise, resolve, reject } = Promise.withResolvers();",
27
+ },
28
+ lintRule: "unicorn/prefer-promise-with-resolvers",
29
+ };
30
+ //# sourceMappingURL=with-resolvers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-resolvers.js","sourceRoot":"","sources":["../../src/rules/with-resolvers.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAS;IACjC,EAAE,EAAE,uBAAuB;IAC3B,KAAK,EAAE,mBAAmB;IAC1B,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC;IACtC,UAAU,EAAE,CAAC,uBAAuB,CAAC;IACrC,MAAM,EAAE,yBAAyB;IACjC,KAAK,EAAE;QACL,SAAS,EACP,sXAAsX;QACxX,OAAO,EAAE;;;;;oCAKuB;QAChC,MAAM,EACJ,wGAAwG;KAC3G;IACD,KAAK,EAAE;QACL,IAAI,EAAE,qEAAqE;QAC3E,MAAM,EAAE;YACN,mNAAmN;YACnN,iLAAiL;YACjL,iMAAiM;YACjM,6JAA6J;SAC9J;QACD,OAAO,EAAE,+DAA+D;KACzE;IACD,QAAQ,EAAE,uCAAuC;CAClD,CAAC"}
package/dist/schema.d.ts CHANGED
@@ -59,8 +59,10 @@ export declare const ruleSchema: z.ZodObject<{
59
59
  when: z.ZodString;
60
60
  unless: z.ZodArray<z.ZodString>;
61
61
  snippet: z.ZodString;
62
+ handRolled: z.ZodOptional<z.ZodArray<z.ZodString>>;
62
63
  }, z.core.$strip>;
63
64
  guides: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
+ lintRule: z.ZodOptional<z.ZodString>;
64
66
  manualBaseline: z.ZodOptional<z.ZodObject<{
65
67
  status: z.ZodEnum<{
66
68
  limited: "limited";
@@ -98,8 +100,10 @@ export declare const catalogSchema: z.ZodArray<z.ZodObject<{
98
100
  when: z.ZodString;
99
101
  unless: z.ZodArray<z.ZodString>;
100
102
  snippet: z.ZodString;
103
+ handRolled: z.ZodOptional<z.ZodArray<z.ZodString>>;
101
104
  }, z.core.$strip>;
102
105
  guides: z.ZodOptional<z.ZodArray<z.ZodString>>;
106
+ lintRule: z.ZodOptional<z.ZodString>;
103
107
  manualBaseline: z.ZodOptional<z.ZodObject<{
104
108
  status: z.ZodEnum<{
105
109
  limited: "limited";
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;GAIG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;EAK/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAmDlE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;iBAK/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+FnB,CAAC;AAEL,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2BxB,CAAC;AAEH,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,CAEnD"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;GAIG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;EAK/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAmDlE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;iBAK/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqInB,CAAC;AAEL,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2BxB,CAAC;AAEH,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,CAEnD"}
package/dist/schema.js CHANGED
@@ -120,6 +120,22 @@ export const ruleSchema = z
120
120
  .array(z.string().min(1))
121
121
  .min(1, "every rule must state when the dependency is still correct"),
122
122
  snippet: z.string().min(1),
123
+ /**
124
+ * Shapes someone writes by hand instead of using the native feature,
125
+ * one short description each.
126
+ *
127
+ * This is the half of the problem `replaces` cannot see. A hand-written
128
+ * focus trap installs nothing, so no package.json match can ever fire,
129
+ * and the shapes worth naming here are multi-line and stateful, which is
130
+ * why no linter has them either. Where a linter does cover the shape,
131
+ * name it in `lintRule` instead: this field is for the ones that need a
132
+ * person or a model to recognise.
133
+ *
134
+ * Prose, deliberately, and read rather than matched. An agent compares
135
+ * what it is looking at against these, then reads `unless` before
136
+ * deciding, the same as for any other finding.
137
+ */
138
+ handRolled: z.array(z.string().min(1)).min(1).optional(),
123
139
  }),
124
140
  /**
125
141
  * IDs of GoogleChrome/modern-web-guidance guides that cover the
@@ -130,6 +146,24 @@ export const ruleSchema = z
130
146
  * is renamed upstream fails a test instead of shipping as a dead link.
131
147
  */
132
148
  guides: z.array(slug).optional(),
149
+ /**
150
+ * A lint rule that already checks this shape, as `<prefix>/<name>`, e.g.
151
+ * `unicorn/prefer-structured-clone`.
152
+ *
153
+ * Same philosophy as `guides`: references, never copies. Where a linter
154
+ * checks something mechanically, this catalog says so and points at it
155
+ * rather than growing a second implementation of the same check. It also
156
+ * tells a reader which migrations they can automate today and which need
157
+ * judgment, which is a question nothing else answers.
158
+ *
159
+ * Resolved against the snapshot in generated/lint-rules.ts, so a rule
160
+ * renamed upstream fails the freshness check instead of shipping as a dead
161
+ * link.
162
+ */
163
+ lintRule: z
164
+ .string()
165
+ .regex(/^[a-z0-9-]+\/[a-z0-9-]+$/, "expected a lint rule as <prefix>/<name>")
166
+ .optional(),
133
167
  manualBaseline: manualBaselineSchema.optional(),
134
168
  })
135
169
  .superRefine((rule, ctx) => {
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC;IACzC,QAAQ;IACR,OAAO;IACP,SAAS;IACT,SAAS;CACV,CAAC,CAAC;AAGH,MA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AM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;gBACnB,OAAO,EAAE,sBAAsB,IAAI,CAAC,EAAE,GAAG;aAC1C,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAErB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC9B,IAAI,KAAK,EAAE,CAAC;gBACV,GAAG,CAAC,QAAQ,CAAC;oBACX,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC;oBACzB,OAAO,EAAE,IAAI,GAAG,iCAAiC,KAAK,2FAA2F;iBAClJ,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { Rule } from "./schema.ts";
2
+ export interface SearchResult {
3
+ rule: Rule;
4
+ /**
5
+ * The packages from `rule.replaces` the query matched, in the order the rule
6
+ * lists them. Empty when the rule matched by title or native feature alone,
7
+ * which is what tells a surface whether it has anything to show underneath.
8
+ */
9
+ packages: readonly string[];
10
+ }
11
+ export interface SearchOptions {
12
+ /** Defaults to the whole catalog. Present so tests can pass their own. */
13
+ rules?: readonly Rule[];
14
+ }
15
+ /**
16
+ * Two characters. One is a substring of most of the catalog, and a list of
17
+ * everything is what `/rules` is for.
18
+ *
19
+ * Exported because an empty result means two different things. A surface that
20
+ * cannot tell "no rule covers this" from "the search declined to run" tells
21
+ * the reader the catalog has nothing for a query it never ran.
22
+ */
23
+ export declare const MIN_QUERY_LENGTH = 2;
24
+ /**
25
+ * Ranks rules against a query. Returns an empty array for a query too short to
26
+ * narrow anything down.
27
+ */
28
+ export declare function searchRules(query: string, options?: SearchOptions): SearchResult[];
29
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAqBxC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,IAAI,CAAC;IACX;;;;OAIG;IACH,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAsClC;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,GAC1B,YAAY,EAAE,CAyBhB"}
package/dist/search.js ADDED
@@ -0,0 +1,84 @@
1
+ import { rules as defaultRules } from "./rules/index.js";
2
+ /**
3
+ * Free-text lookup over the catalog.
4
+ *
5
+ * `detect()` answers "here is my package.json, what applies", which needs the
6
+ * whole file. This answers the question someone arrives with instead: one name
7
+ * they already have in their head. The catalog covers far more package names
8
+ * than it has rules, and a rule is titled after the native feature rather than
9
+ * after any package it replaces, so most of those names appear nowhere a
10
+ * reader can find them.
11
+ *
12
+ * Pure, like `detect()`. It reads nothing but the rules handed to it.
13
+ */
14
+ /** Why a rule came back, strongest first. Also its sort key. */
15
+ const EXACT_PACKAGE = 4;
16
+ const PACKAGE_PREFIX = 3;
17
+ const PACKAGE_SUBSTRING = 2;
18
+ const RULE_TEXT = 1;
19
+ /**
20
+ * Two characters. One is a substring of most of the catalog, and a list of
21
+ * everything is what `/rules` is for.
22
+ *
23
+ * Exported because an empty result means two different things. A surface that
24
+ * cannot tell "no rule covers this" from "the search declined to run" tells
25
+ * the reader the catalog has nothing for a query it never ran.
26
+ */
27
+ export const MIN_QUERY_LENGTH = 2;
28
+ function scorePackage(name, query) {
29
+ const lower = name.toLowerCase();
30
+ if (lower === query)
31
+ return EXACT_PACKAGE;
32
+ if (lower.startsWith(query))
33
+ return PACKAGE_PREFIX;
34
+ if (lower.includes(query))
35
+ return PACKAGE_SUBSTRING;
36
+ return 0;
37
+ }
38
+ /**
39
+ * Scores one rule. A rule that matches by package never falls back to its
40
+ * title, so the packages array stays a list of what the reader actually
41
+ * typed rather than everything the rule happens to replace.
42
+ */
43
+ function scoreRule(rule, needle) {
44
+ const packages = [];
45
+ let score = 0;
46
+ for (const name of rule.replaces) {
47
+ const packageScore = scorePackage(name, needle);
48
+ if (packageScore === 0)
49
+ continue;
50
+ packages.push(name);
51
+ score = Math.max(score, packageScore);
52
+ }
53
+ if (score > 0)
54
+ return { packages, score };
55
+ const matchesText = rule.title.toLowerCase().includes(needle) ||
56
+ rule.native.toLowerCase().includes(needle);
57
+ return { packages, score: matchesText ? RULE_TEXT : 0 };
58
+ }
59
+ /**
60
+ * Ranks rules against a query. Returns an empty array for a query too short to
61
+ * narrow anything down.
62
+ */
63
+ export function searchRules(query, options = {}) {
64
+ const needle = query.trim().toLowerCase();
65
+ if (needle.length < MIN_QUERY_LENGTH)
66
+ return [];
67
+ const scored = [];
68
+ for (const rule of options.rules ?? defaultRules) {
69
+ const { packages, score } = scoreRule(rule, needle);
70
+ if (score === 0)
71
+ continue;
72
+ scored.push({ result: { rule, packages }, score });
73
+ }
74
+ /*
75
+ * Ties break on how much of the rule the query hit, then on title, so the
76
+ * order is stable rather than dependent on the order rules/index.ts happens
77
+ * to list them in.
78
+ */
79
+ scored.sort((a, b) => b.score - a.score ||
80
+ b.result.packages.length - a.result.packages.length ||
81
+ a.result.rule.title.localeCompare(b.result.rule.title));
82
+ return scored.map((entry) => entry.result);
83
+ }
84
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGzD;;;;;;;;;;;GAWG;AAEH,gEAAgE;AAChE,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,SAAS,GAAG,CAAC,CAAC;AAiBpB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,SAAS,YAAY,CAAC,IAAY,EAAE,KAAa;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,aAAa,CAAC;IAC1C,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,cAAc,CAAC;IACnD,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAC;IACpD,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAChB,IAAU,EACV,MAAc;IAEd,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,KAAK,GAAG,CAAC,C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K,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,IAAI,CACT,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK;QACjB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;QACnD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CACzD,CAAC;IAEF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@jomae/catalog",
3
- "version": "0.6.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "The rule catalog behind youmightnotneed. Maps npm packages to the CSS, HTML, or Web API that replaces them.",
6
6
  "license": "MIT",
7
7
  "author": "Johannes Maendle",
8
- "homepage": "https://youmightnotneed-web.vercel.app",
8
+ "homepage": "https://youmightnotneed.dev",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https://github.com/jomaendle/youmightnotneed.git",