@autobusal/utilities 1.5.1 → 1.5.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.3
4
+
5
+ ### Fixed
6
+
7
+ - **The backtick guard tripped on prose about styled-components**, and was refusing to publish the whole repo. Its opening pattern matches `styled.x` followed by a backtick as *text*, so a JSDoc line describing another file - "labels as `<span>` (Viewer/styles.ts: `Label = styled.span`)" - opened a template no code had opened, and every comment up to the next `` `; `` in the file counted as inside it. A comment about the hazard tripping the guard against the hazard. Openings found inside comments are now ignored; backticks inside comments, which are the thing being hunted, still are not.
8
+
9
+ ## 1.5.2
10
+
11
+ ### Changed
12
+
13
+ - DOMPurify raised to `^3.4.14` for GHSA-55q2-fjhq-7xh7. It rates as moderate, which understates it here: DOMPurify is what `sanitizeHtml` is, so it sits directly on the path every piece of admin-authored and model-generated HTML takes before reaching a browser.
14
+
3
15
  ## 1.5.1
4
16
 
5
17
  ### Changed
@@ -52,10 +52,44 @@ const walk = (dir) => readdirSync(dir).flatMap((entry) => {
52
52
 
53
53
  const found = [];
54
54
 
55
+ /**
56
+ * Where the comments are, as [start, end) offsets.
57
+ *
58
+ * Edited: Claude - Date: 2026-08-21
59
+ *
60
+ * Needed because OPEN matches `styled.x` + a backtick as TEXT, and prose
61
+ * about styled-components looks exactly like styled-components. A JSDoc
62
+ * line reading "labels as <span> (Viewer/styles.ts: `Label = styled.span`)"
63
+ * opened a template here that no code ever opened, and everything up to the
64
+ * next `; in the file - thirty-six lines of unrelated JSDoc - was then
65
+ * inside it. That is what refused to publish this repo: a comment ABOUT the
66
+ * hazard tripping the guard against the hazard.
67
+ *
68
+ * Comments cannot simply be stripped first: backticks in comments are the
69
+ * whole thing being looked for. Only the OPENING has to ignore them.
70
+ */
71
+ const commentRanges = (text) => {
72
+ const ranges = [];
73
+ const pattern = /\/\*[\s\S]*?\*\/|\/\/[^\n]*/g;
74
+
75
+ for (const match of text.matchAll(pattern)) {
76
+ ranges.push([match.index, match.index + match[0].length]);
77
+ }
78
+
79
+ return ranges;
80
+ };
81
+
55
82
  for (const path of walk(process.argv[2] ?? 'packages')) {
56
83
  const text = readFileSync(path, 'utf8');
84
+ const comments = commentRanges(text);
85
+ const commented = (at) => comments.some(([from, to]) => at >= from && at < to);
57
86
 
58
87
  for (const match of text.matchAll(OPEN)) {
88
+ // a styled template named inside a comment is prose, not a template
89
+ if (commented(match.index)) {
90
+ continue;
91
+ }
92
+
59
93
  const start = match.index + match[0].length;
60
94
  const end = text.indexOf('`;', start);
61
95
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@autobusal/utilities",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts",
7
7
  "dependencies": {
8
- "dompurify": "^3.4.12"
8
+ "dompurify": "^3.4.14"
9
9
  }
10
10
  }