@nadicodeai/ui 12.1.61 → 12.1.62

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.
@@ -11,14 +11,39 @@ const DIRECTIVE =
11
11
 
12
12
  const SEAM_MARKER = /^\s*NADIA\((?:added|changed|removed)\):/;
13
13
 
14
+ function moduleHeader(comments, firstTokenStart) {
15
+ const [first, ...rest] = comments;
16
+ if (first === undefined || first.range[1] > firstTokenStart) return [];
17
+ if (first.type === "Block") return [first];
18
+ const run = [first];
19
+ for (const next of rest) {
20
+ if (
21
+ next.type !== "Line" ||
22
+ next.range[1] > firstTokenStart ||
23
+ next.loc.start.line !== run.at(-1).loc.end.line + 1
24
+ ) {
25
+ break;
26
+ }
27
+ run.push(next);
28
+ }
29
+ return run;
30
+ }
31
+
14
32
  export const noComment = {
15
33
  meta: {
16
34
  type: "problem",
17
35
  docs: {
18
36
  description:
19
- "Disallow comments in code, but for directives to a tool and the marker the seam guard requires",
37
+ "Disallow comments in code, but for directives to a tool, the marker the seam guard requires and, when allowed, the one comment that opens a module",
20
38
  },
21
- schema: [],
39
+ schema: [
40
+ {
41
+ type: "object",
42
+ properties: { allowModuleHeader: { type: "boolean" } },
43
+ additionalProperties: false,
44
+ },
45
+ ],
46
+ defaultOptions: [{ allowModuleHeader: false }],
22
47
  messages: {
23
48
  comment:
24
49
  "Code says what it does in its names and its structure, never in a comment. Rename or restructure, or remove the comment.",
@@ -26,17 +51,25 @@ export const noComment = {
26
51
  },
27
52
 
28
53
  create(context) {
54
+ const [{ allowModuleHeader }] = context.options;
55
+ const { sourceCode } = context;
29
56
  return {
30
57
  Program() {
31
- for (const comment of context.sourceCode.getAllComments()) {
32
- if (
33
- comment.type === "Shebang" ||
34
- DIRECTIVE.test(comment.value) ||
35
- SEAM_MARKER.test(comment.value)
36
- ) {
37
- continue;
58
+ const prose = sourceCode
59
+ .getAllComments()
60
+ .filter(
61
+ (comment) =>
62
+ comment.type !== "Shebang" &&
63
+ !DIRECTIVE.test(comment.value) &&
64
+ !SEAM_MARKER.test(comment.value),
65
+ );
66
+ const header = allowModuleHeader
67
+ ? moduleHeader(prose, sourceCode.ast.tokens[0]?.range[0] ?? Infinity)
68
+ : [];
69
+ for (const comment of prose) {
70
+ if (!header.includes(comment)) {
71
+ context.report({ loc: comment.loc, messageId: "comment" });
38
72
  }
39
- context.report({ loc: comment.loc, messageId: "comment" });
40
73
  }
41
74
  },
42
75
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadicodeai/ui",
3
- "version": "12.1.61",
3
+ "version": "12.1.62",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -81,7 +81,7 @@
81
81
  "@assistant-ui/react": "0.15.22",
82
82
  "@assistant-ui/react-markdown": "0.14.17",
83
83
  "@base-ui/react": "^1.8.0",
84
- "@nadicodeai/design-system": "12.1.61",
84
+ "@nadicodeai/design-system": "12.1.62",
85
85
  "class-variance-authority": "^0.7.1",
86
86
  "clsx": "^2.1.1",
87
87
  "cmdk": "^1.1.1",