@formspec/eslint-plugin 0.1.0-alpha.10

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 (74) hide show
  1. package/README.md +237 -0
  2. package/dist/index.d.ts +71 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +117 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/rules/consistent-constraints.d.ts +22 -0
  7. package/dist/rules/consistent-constraints.d.ts.map +1 -0
  8. package/dist/rules/consistent-constraints.js +178 -0
  9. package/dist/rules/consistent-constraints.js.map +1 -0
  10. package/dist/rules/constraints/allowed-field-types.d.ts +16 -0
  11. package/dist/rules/constraints/allowed-field-types.d.ts.map +1 -0
  12. package/dist/rules/constraints/allowed-field-types.js +133 -0
  13. package/dist/rules/constraints/allowed-field-types.js.map +1 -0
  14. package/dist/rules/constraints/allowed-layouts.d.ts +17 -0
  15. package/dist/rules/constraints/allowed-layouts.d.ts.map +1 -0
  16. package/dist/rules/constraints/allowed-layouts.js +83 -0
  17. package/dist/rules/constraints/allowed-layouts.js.map +1 -0
  18. package/dist/rules/constraints/index.d.ts +9 -0
  19. package/dist/rules/constraints/index.d.ts.map +1 -0
  20. package/dist/rules/constraints/index.js +9 -0
  21. package/dist/rules/constraints/index.js.map +1 -0
  22. package/dist/rules/decorator-allowed-field-types.d.ts +17 -0
  23. package/dist/rules/decorator-allowed-field-types.d.ts.map +1 -0
  24. package/dist/rules/decorator-allowed-field-types.js +71 -0
  25. package/dist/rules/decorator-allowed-field-types.js.map +1 -0
  26. package/dist/rules/decorator-field-type-mismatch.d.ts +14 -0
  27. package/dist/rules/decorator-field-type-mismatch.d.ts.map +1 -0
  28. package/dist/rules/decorator-field-type-mismatch.js +116 -0
  29. package/dist/rules/decorator-field-type-mismatch.js.map +1 -0
  30. package/dist/rules/enum-options-match-type.d.ts +26 -0
  31. package/dist/rules/enum-options-match-type.d.ts.map +1 -0
  32. package/dist/rules/enum-options-match-type.js +115 -0
  33. package/dist/rules/enum-options-match-type.js.map +1 -0
  34. package/dist/rules/index.d.ts +13 -0
  35. package/dist/rules/index.d.ts.map +1 -0
  36. package/dist/rules/index.js +13 -0
  37. package/dist/rules/index.js.map +1 -0
  38. package/dist/rules/no-conflicting-decorators.d.ts +15 -0
  39. package/dist/rules/no-conflicting-decorators.d.ts.map +1 -0
  40. package/dist/rules/no-conflicting-decorators.js +72 -0
  41. package/dist/rules/no-conflicting-decorators.js.map +1 -0
  42. package/dist/rules/no-duplicate-decorators.d.ts +19 -0
  43. package/dist/rules/no-duplicate-decorators.d.ts.map +1 -0
  44. package/dist/rules/no-duplicate-decorators.js +59 -0
  45. package/dist/rules/no-duplicate-decorators.js.map +1 -0
  46. package/dist/rules/prefer-custom-decorator.d.ts +22 -0
  47. package/dist/rules/prefer-custom-decorator.d.ts.map +1 -0
  48. package/dist/rules/prefer-custom-decorator.js +72 -0
  49. package/dist/rules/prefer-custom-decorator.js.map +1 -0
  50. package/dist/rules/showwhen-field-exists.d.ts +21 -0
  51. package/dist/rules/showwhen-field-exists.d.ts.map +1 -0
  52. package/dist/rules/showwhen-field-exists.js +68 -0
  53. package/dist/rules/showwhen-field-exists.js.map +1 -0
  54. package/dist/rules/showwhen-suggests-optional.d.ts +19 -0
  55. package/dist/rules/showwhen-suggests-optional.d.ts.map +1 -0
  56. package/dist/rules/showwhen-suggests-optional.js +53 -0
  57. package/dist/rules/showwhen-suggests-optional.js.map +1 -0
  58. package/dist/utils/decorator-utils.d.ts +105 -0
  59. package/dist/utils/decorator-utils.d.ts.map +1 -0
  60. package/dist/utils/decorator-utils.js +216 -0
  61. package/dist/utils/decorator-utils.js.map +1 -0
  62. package/dist/utils/index.d.ts +6 -0
  63. package/dist/utils/index.d.ts.map +1 -0
  64. package/dist/utils/index.js +6 -0
  65. package/dist/utils/index.js.map +1 -0
  66. package/dist/utils/jsdoc-utils.d.ts +31 -0
  67. package/dist/utils/jsdoc-utils.d.ts.map +1 -0
  68. package/dist/utils/jsdoc-utils.js +81 -0
  69. package/dist/utils/jsdoc-utils.js.map +1 -0
  70. package/dist/utils/type-utils.d.ts +82 -0
  71. package/dist/utils/type-utils.d.ts.map +1 -0
  72. package/dist/utils/type-utils.js +216 -0
  73. package/dist/utils/type-utils.js.map +1 -0
  74. package/package.json +50 -0
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Utility functions for working with decorator AST nodes.
3
+ */
4
+ import { TSESTree } from "@typescript-eslint/utils";
5
+ /**
6
+ * Information extracted from a decorator.
7
+ */
8
+ export interface DecoratorInfo {
9
+ /** The decorator name (e.g., "Minimum", "Field", "EnumOptions") */
10
+ name: string;
11
+ /** The arguments passed to the decorator */
12
+ args: TSESTree.Expression[];
13
+ /** The original decorator node */
14
+ node: TSESTree.Decorator;
15
+ }
16
+ /**
17
+ * FormSpec decorator names that imply specific field types.
18
+ */
19
+ export declare const DECORATOR_TYPE_HINTS: {
20
+ readonly Minimum: "number";
21
+ readonly Maximum: "number";
22
+ readonly ExclusiveMinimum: "number";
23
+ readonly ExclusiveMaximum: "number";
24
+ readonly MinLength: "string";
25
+ readonly MaxLength: "string";
26
+ readonly Pattern: "string";
27
+ readonly EnumOptions: "enum";
28
+ };
29
+ export type TypeHintDecorator = keyof typeof DECORATOR_TYPE_HINTS;
30
+ /**
31
+ * All known FormSpec decorator names.
32
+ */
33
+ export declare const FORMSPEC_DECORATORS: Set<string>;
34
+ /**
35
+ * Extracts decorator information from a Decorator AST node.
36
+ *
37
+ * Handles both:
38
+ * - `@DecoratorName` (identifier)
39
+ * - `@DecoratorName(args)` (call expression)
40
+ *
41
+ * @param decorator - The decorator AST node
42
+ * @returns Decorator info or null if not a recognized pattern
43
+ */
44
+ export declare function getDecoratorInfo(decorator: TSESTree.Decorator): DecoratorInfo | null;
45
+ /**
46
+ * Finds all decorators on a property definition.
47
+ *
48
+ * @param node - The property definition node
49
+ * @returns Array of decorator info objects for FormSpec decorators
50
+ */
51
+ export declare function getFormSpecDecorators(node: TSESTree.PropertyDefinition): DecoratorInfo[];
52
+ /**
53
+ * Finds a specific decorator by name on a property.
54
+ *
55
+ * @param node - The property definition node
56
+ * @param name - The decorator name to find
57
+ * @returns The decorator info or null if not found
58
+ */
59
+ export declare function findDecorator(node: TSESTree.PropertyDefinition, name: string): DecoratorInfo | null;
60
+ /**
61
+ * Checks if a property has a specific decorator.
62
+ *
63
+ * @param node - The property definition node
64
+ * @param name - The decorator name to check
65
+ * @returns True if the decorator is present
66
+ */
67
+ export declare function hasDecorator(node: TSESTree.PropertyDefinition, name: string): boolean;
68
+ /**
69
+ * Gets the first argument of a decorator as a literal value.
70
+ *
71
+ * @param decorator - The decorator info
72
+ * @returns The literal value or null if not a literal
73
+ */
74
+ export declare function getDecoratorLiteralArg(decorator: DecoratorInfo): unknown;
75
+ /**
76
+ * Gets the first argument of a decorator as an array of values.
77
+ * Used for @EnumOptions(["a", "b", "c"]).
78
+ *
79
+ * @param decorator - The decorator info
80
+ * @returns Array of values or null if not an array expression
81
+ */
82
+ export declare function getDecoratorArrayArg(decorator: DecoratorInfo): unknown[] | null;
83
+ /**
84
+ * Gets the field reference from a @ShowWhen predicate.
85
+ * @ShowWhen({ _predicate: "equals", field: "foo", value: "bar" })
86
+ *
87
+ * @param decorator - The ShowWhen decorator info
88
+ * @returns The field name or null if not found
89
+ */
90
+ export declare function getShowWhenField(decorator: DecoratorInfo): string | null;
91
+ /**
92
+ * Gets the property name from a PropertyDefinition.
93
+ *
94
+ * @param node - The property definition node
95
+ * @returns The property name or null if computed/symbol
96
+ */
97
+ export declare function getPropertyName(node: TSESTree.PropertyDefinition): string | null;
98
+ /**
99
+ * Gets all property names from a class definition.
100
+ *
101
+ * @param classNode - The class declaration/expression node
102
+ * @returns Set of property names
103
+ */
104
+ export declare function getClassPropertyNames(classNode: TSESTree.ClassDeclaration | TSESTree.ClassExpression): Set<string>;
105
+ //# sourceMappingURL=decorator-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator-utils.d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AAI,CAqBxE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAQhF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,QAAQ,CAAC,gBAAgB,GAAG,QAAQ,CAAC,eAAe,GAC9D,GAAG,CAAC,MAAM,CAAC,CAWb"}
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Utility functions for working with decorator AST nodes.
3
+ */
4
+ import { TSESTree, AST_NODE_TYPES } from "@typescript-eslint/utils";
5
+ import { FORMSPEC_DECORATOR_NAMES } from "@formspec/core";
6
+ /**
7
+ * FormSpec decorator names that imply specific field types.
8
+ */
9
+ export const DECORATOR_TYPE_HINTS = {
10
+ Minimum: "number",
11
+ Maximum: "number",
12
+ ExclusiveMinimum: "number",
13
+ ExclusiveMaximum: "number",
14
+ MinLength: "string",
15
+ MaxLength: "string",
16
+ Pattern: "string",
17
+ EnumOptions: "enum",
18
+ };
19
+ /**
20
+ * All known FormSpec decorator names.
21
+ */
22
+ export const FORMSPEC_DECORATORS = new Set(FORMSPEC_DECORATOR_NAMES);
23
+ /**
24
+ * Extracts decorator information from a Decorator AST node.
25
+ *
26
+ * Handles both:
27
+ * - `@DecoratorName` (identifier)
28
+ * - `@DecoratorName(args)` (call expression)
29
+ *
30
+ * @param decorator - The decorator AST node
31
+ * @returns Decorator info or null if not a recognized pattern
32
+ */
33
+ export function getDecoratorInfo(decorator) {
34
+ const expr = decorator.expression;
35
+ // Case 1: @DecoratorName() - CallExpression
36
+ if (expr.type === AST_NODE_TYPES.CallExpression) {
37
+ const callee = expr.callee;
38
+ if (callee.type === AST_NODE_TYPES.Identifier) {
39
+ return {
40
+ name: callee.name,
41
+ args: expr.arguments,
42
+ node: decorator,
43
+ };
44
+ }
45
+ }
46
+ // Case 2: @DecoratorName - Identifier (no parentheses)
47
+ if (expr.type === AST_NODE_TYPES.Identifier) {
48
+ return {
49
+ name: expr.name,
50
+ args: [],
51
+ node: decorator,
52
+ };
53
+ }
54
+ return null;
55
+ }
56
+ /**
57
+ * Finds all decorators on a property definition.
58
+ *
59
+ * @param node - The property definition node
60
+ * @returns Array of decorator info objects for FormSpec decorators
61
+ */
62
+ export function getFormSpecDecorators(node) {
63
+ const decorators = node.decorators;
64
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- decorators can be undefined
65
+ if (!decorators || decorators.length === 0) {
66
+ return [];
67
+ }
68
+ const result = [];
69
+ for (const decorator of decorators) {
70
+ const info = getDecoratorInfo(decorator);
71
+ if (info && FORMSPEC_DECORATORS.has(info.name)) {
72
+ result.push(info);
73
+ }
74
+ }
75
+ return result;
76
+ }
77
+ /**
78
+ * Finds a specific decorator by name on a property.
79
+ *
80
+ * @param node - The property definition node
81
+ * @param name - The decorator name to find
82
+ * @returns The decorator info or null if not found
83
+ */
84
+ export function findDecorator(node, name) {
85
+ const decorators = getFormSpecDecorators(node);
86
+ return decorators.find((d) => d.name === name) ?? null;
87
+ }
88
+ /**
89
+ * Checks if a property has a specific decorator.
90
+ *
91
+ * @param node - The property definition node
92
+ * @param name - The decorator name to check
93
+ * @returns True if the decorator is present
94
+ */
95
+ export function hasDecorator(node, name) {
96
+ return findDecorator(node, name) !== null;
97
+ }
98
+ /**
99
+ * Gets the first argument of a decorator as a literal value.
100
+ *
101
+ * @param decorator - The decorator info
102
+ * @returns The literal value or null if not a literal
103
+ */
104
+ export function getDecoratorLiteralArg(decorator) {
105
+ const arg = decorator.args[0];
106
+ if (!arg) {
107
+ return null;
108
+ }
109
+ if (arg.type === AST_NODE_TYPES.Literal) {
110
+ return arg.value;
111
+ }
112
+ // Handle negative numbers: -5 is a UnaryExpression('-', Literal(5))
113
+ if (arg.type === AST_NODE_TYPES.UnaryExpression &&
114
+ arg.operator === "-" &&
115
+ arg.argument.type === AST_NODE_TYPES.Literal &&
116
+ typeof arg.argument.value === "number") {
117
+ return -arg.argument.value;
118
+ }
119
+ return null;
120
+ }
121
+ /**
122
+ * Gets the first argument of a decorator as an array of values.
123
+ * Used for @EnumOptions(["a", "b", "c"]).
124
+ *
125
+ * @param decorator - The decorator info
126
+ * @returns Array of values or null if not an array expression
127
+ */
128
+ export function getDecoratorArrayArg(decorator) {
129
+ const arg = decorator.args[0];
130
+ if (!arg) {
131
+ return null;
132
+ }
133
+ if (arg.type === AST_NODE_TYPES.ArrayExpression) {
134
+ const values = [];
135
+ for (const element of arg.elements) {
136
+ if (!element)
137
+ continue;
138
+ if (element.type === AST_NODE_TYPES.Literal) {
139
+ values.push(element.value);
140
+ }
141
+ else if (element.type === AST_NODE_TYPES.ObjectExpression) {
142
+ // Handle { id: "x", label: "X" } objects
143
+ const obj = {};
144
+ for (const prop of element.properties) {
145
+ if (prop.type === AST_NODE_TYPES.Property &&
146
+ prop.key.type === AST_NODE_TYPES.Identifier &&
147
+ prop.value.type === AST_NODE_TYPES.Literal) {
148
+ obj[prop.key.name] = prop.value.value;
149
+ }
150
+ }
151
+ values.push(obj);
152
+ }
153
+ }
154
+ return values;
155
+ }
156
+ return null;
157
+ }
158
+ /**
159
+ * Gets the field reference from a @ShowWhen predicate.
160
+ * @ShowWhen({ _predicate: "equals", field: "foo", value: "bar" })
161
+ *
162
+ * @param decorator - The ShowWhen decorator info
163
+ * @returns The field name or null if not found
164
+ */
165
+ export function getShowWhenField(decorator) {
166
+ const arg = decorator.args[0];
167
+ if (!arg) {
168
+ return null;
169
+ }
170
+ if (arg.type === AST_NODE_TYPES.ObjectExpression) {
171
+ for (const prop of arg.properties) {
172
+ if (prop.type === AST_NODE_TYPES.Property &&
173
+ prop.key.type === AST_NODE_TYPES.Identifier &&
174
+ prop.key.name === "field" &&
175
+ prop.value.type === AST_NODE_TYPES.Literal &&
176
+ typeof prop.value.value === "string") {
177
+ return prop.value.value;
178
+ }
179
+ }
180
+ }
181
+ return null;
182
+ }
183
+ /**
184
+ * Gets the property name from a PropertyDefinition.
185
+ *
186
+ * @param node - The property definition node
187
+ * @returns The property name or null if computed/symbol
188
+ */
189
+ export function getPropertyName(node) {
190
+ if (node.key.type === AST_NODE_TYPES.Identifier) {
191
+ return node.key.name;
192
+ }
193
+ if (node.key.type === AST_NODE_TYPES.Literal && typeof node.key.value === "string") {
194
+ return node.key.value;
195
+ }
196
+ return null;
197
+ }
198
+ /**
199
+ * Gets all property names from a class definition.
200
+ *
201
+ * @param classNode - The class declaration/expression node
202
+ * @returns Set of property names
203
+ */
204
+ export function getClassPropertyNames(classNode) {
205
+ const names = new Set();
206
+ for (const member of classNode.body.body) {
207
+ if (member.type === AST_NODE_TYPES.PropertyDefinition) {
208
+ const name = getPropertyName(member);
209
+ if (name) {
210
+ names.add(name);
211
+ }
212
+ }
213
+ }
214
+ return names;
215
+ }
216
+ //# sourceMappingURL=decorator-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator-utils.js","sourceRoot":"","sources":["../../src/utils/decorator-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAc1D;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,QAAQ;IACjB,gBAAgB,EAAE,QAAQ;IAC1B,gBAAgB,EAAE,QAAQ;IAC1B,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,QAAQ;IACnB,OAAO,EAAE,QAAQ;IACjB,WAAW,EAAE,MAAM;CACX,CAAC;AAIX;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAS,wBAAwB,CAAC,CAAC;AAE7E;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA6B;IAC5D,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC;IAElC,4CAA4C;IAC5C,IAAI,I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}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utility functions for FormSpec ESLint rules.
3
+ */
4
+ export * from "./decorator-utils.js";
5
+ export * from "./type-utils.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utility functions for FormSpec ESLint rules.
3
+ */
4
+ export * from "./decorator-utils.js";
5
+ export * from "./type-utils.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Utility functions for extracting constraint tags from JSDoc comments.
3
+ */
4
+ import { type TSESTree } from "@typescript-eslint/utils";
5
+ import type { SourceCode } from "@typescript-eslint/utils/ts-eslint";
6
+ /** A constraint extracted from a JSDoc comment tag. */
7
+ export interface JSDocConstraint {
8
+ /** The constraint name (e.g., "Minimum", "Maximum") */
9
+ name: string;
10
+ /** The parsed value */
11
+ value: number | string;
12
+ /** The comment node (for error reporting location) */
13
+ comment: TSESTree.Comment;
14
+ }
15
+ /**
16
+ * Extracts constraint tags from JSDoc comments preceding a node.
17
+ *
18
+ * @param node - The AST node to check for preceding JSDoc comments
19
+ * @param sourceCode - The ESLint source code object
20
+ * @returns Array of parsed JSDoc constraints
21
+ */
22
+ export declare function getJSDocConstraints(node: TSESTree.Node, sourceCode: SourceCode): JSDocConstraint[];
23
+ /**
24
+ * Finds a specific constraint by name in a JSDoc constraints array.
25
+ *
26
+ * @param constraints - The array of JSDoc constraints to search
27
+ * @param name - The constraint name to find
28
+ * @returns The matching constraint or null if not found
29
+ */
30
+ export declare function findJSDocConstraint(constraints: JSDocConstraint[], name: string): JSDocConstraint | null;
31
+ //# sourceMappingURL=jsdoc-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsdoc-utils.d.ts","sourceRoot":"","sources":["../../src/utils/jsdoc-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAGrE,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,sDAAsD;IACtD,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC;CAC3B;AAiBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,QAAQ,CAAC,IAAI,EACnB,UAAU,EAAE,UAAU,GACrB,eAAe,EAAE,CAsDnB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,eAAe,EAAE,EAC9B,IAAI,EAAE,MAAM,GACX,eAAe,GAAG,IAAI,CAExB"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Utility functions for extracting constraint tags from JSDoc comments.
3
+ */
4
+ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
5
+ import { CONSTRAINT_TAG_DEFINITIONS } from "@formspec/core";
6
+ const NUMERIC_TAG_NAMES = Object.keys(CONSTRAINT_TAG_DEFINITIONS).filter((k) => CONSTRAINT_TAG_DEFINITIONS[k] === "number");
7
+ const NUMERIC_TAGS_PATTERN = NUMERIC_TAG_NAMES.join("|");
8
+ // Numeric tags: value stops at the next `@` tag, `*/`, or end-of-line
9
+ const NUMERIC_TAG_REGEX = new RegExp(`@(${NUMERIC_TAGS_PATTERN})\\s+(.+?)(?=\\s*@|\\s*\\*\\/|\\s*$)`, "gm");
10
+ // Pattern tag: value captures everything until `*/` or end-of-line,
11
+ // because regex patterns can contain `@` (e.g., email validation)
12
+ const PATTERN_TAG_REGEX = /@Pattern\s+(.+?)(?=\s*\*\/|\s*$)/gm;
13
+ /**
14
+ * Extracts constraint tags from JSDoc comments preceding a node.
15
+ *
16
+ * @param node - The AST node to check for preceding JSDoc comments
17
+ * @param sourceCode - The ESLint source code object
18
+ * @returns Array of parsed JSDoc constraints
19
+ */
20
+ export function getJSDocConstraints(node, sourceCode) {
21
+ // Collect comments before the node itself
22
+ const comments = [...sourceCode.getCommentsBefore(node)];
23
+ // For PropertyDefinition with decorators, also check comments before the
24
+ // property key. JSDoc comments placed between decorators and the property
25
+ // name (e.g., `@Minimum(5)\n/** @Maximum 100 */\nvalue!: number;`) are
26
+ // not "before" the PropertyDefinition node — they're between the
27
+ // decorator and the key.
28
+ if (node.type === AST_NODE_TYPES.PropertyDefinition && node.decorators.length > 0) {
29
+ const keyComments = sourceCode.getCommentsBefore(node.key);
30
+ for (const c of keyComments) {
31
+ if (!comments.includes(c)) {
32
+ comments.push(c);
33
+ }
34
+ }
35
+ }
36
+ const results = [];
37
+ for (const comment of comments) {
38
+ // Only process JSDoc-style block comments (/** ... */)
39
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- TSESTree.Comment uses "Block"/"Line" strings, not AST_NODE_TYPES enum
40
+ if (comment.type !== "Block" || !comment.value.startsWith("*")) {
41
+ continue;
42
+ }
43
+ // Extract numeric constraint tags (Minimum, Maximum, MinLength, etc.)
44
+ NUMERIC_TAG_REGEX.lastIndex = 0;
45
+ let match;
46
+ while ((match = NUMERIC_TAG_REGEX.exec(comment.value)) !== null) {
47
+ const name = match[1];
48
+ const rawValue = match[2];
49
+ if (!name || !rawValue)
50
+ continue;
51
+ const cleanedValue = rawValue.replace(/^\s*\*\s*/gm, "").trim();
52
+ const parsed = Number(cleanedValue);
53
+ if (Number.isNaN(parsed))
54
+ continue;
55
+ results.push({ name, value: parsed, comment });
56
+ }
57
+ // Extract @Pattern separately — its value can contain `@` (e.g., email regex)
58
+ PATTERN_TAG_REGEX.lastIndex = 0;
59
+ while ((match = PATTERN_TAG_REGEX.exec(comment.value)) !== null) {
60
+ const rawValue = match[1];
61
+ if (!rawValue)
62
+ continue;
63
+ const cleanedValue = rawValue.replace(/^\s*\*\s*/gm, "").trim();
64
+ if (cleanedValue === "")
65
+ continue;
66
+ results.push({ name: "Pattern", value: cleanedValue, comment });
67
+ }
68
+ }
69
+ return results;
70
+ }
71
+ /**
72
+ * Finds a specific constraint by name in a JSDoc constraints array.
73
+ *
74
+ * @param constraints - The array of JSDoc constraints to search
75
+ * @param name - The constraint name to find
76
+ * @returns The matching constraint or null if not found
77
+ */
78
+ export function findJSDocConstraint(constraints, name) {
79
+ return constraints.find((c) => c.name === name) ?? null;
80
+ }
81
+ //# sourceMappingURL=jsdoc-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsdoc-utils.js","sourceRoot":"","sources":["../../src/utils/jsdoc-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAY5D,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,MAAM,CACtE,CAAC,CAAC,EAAE,EAAE,CAAC,0BAA0B,CAAC,CAA4C,CAAC,KAAK,QAAQ,CAC7F,CAAC;AACF,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEzD,sEAAsE;AACtE,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAClC,KAAK,oBAAoB,sCAAsC,EAC/D,IAAI,CACL,CAAC;AAEF,oEAAoE;AACpE,kEAAkE;AAClE,MAAM,iBAAiB,GAAG,oCAAoC,CAAC;AAE/D;;;;;;GAM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,QAAQ;gBAAE,SAAS;YAEjC,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YAChE,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;YACpC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;gBAAE,SAAS;YACnC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;QACjD,CAAC;QAED,8EAA8E;QAC9E,iBAAiB,CAAC,SAAS,GAAG,CAAC,CAAC;QAChC,OAAO,CAAC,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAChE,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAExB,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YAChE,IAAI,YAAY,KAAK,EAAE;gBAAE,SAAS;YAClC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,WAA8B,EAC9B,IAAY;IAEZ,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Utility functions for TypeScript type checking in ESLint rules.
3
+ */
4
+ import type { ParserServicesWithTypeInformation } from "@typescript-eslint/utils";
5
+ import type { TSESTree } from "@typescript-eslint/utils";
6
+ import type ts from "typescript";
7
+ /**
8
+ * Field type categories for FormSpec.
9
+ */
10
+ export type FieldTypeCategory = "string" | "number" | "boolean" | "array" | "object" | "union" | "unknown";
11
+ /**
12
+ * Checks if a TypeScript type is a string type.
13
+ *
14
+ * Handles string primitives, string literals, and unions of string types.
15
+ *
16
+ * @param type - The TypeScript type to check
17
+ * @param checker - The TypeScript type checker instance
18
+ * @returns True if the type is string, a string literal, or a union of string types
19
+ */
20
+ export declare function isStringType(type: ts.Type, checker: ts.TypeChecker): boolean;
21
+ /**
22
+ * Checks if a TypeScript type is a number type.
23
+ *
24
+ * Handles number primitives, number literals, and unions of number types.
25
+ *
26
+ * @param type - The TypeScript type to check
27
+ * @param checker - The TypeScript type checker instance
28
+ * @returns True if the type is number, a number literal, or a union of number types
29
+ */
30
+ export declare function isNumberType(type: ts.Type, checker: ts.TypeChecker): boolean;
31
+ /**
32
+ * Checks if a TypeScript type is a boolean type.
33
+ *
34
+ * Handles boolean primitives, boolean literals (true/false), and unions of boolean types.
35
+ *
36
+ * @param type - The TypeScript type to check
37
+ * @param checker - The TypeScript type checker instance
38
+ * @returns True if the type is boolean, true, false, or a union of boolean types
39
+ */
40
+ export declare function isBooleanType(type: ts.Type, checker: ts.TypeChecker): boolean;
41
+ /**
42
+ * Checks if a TypeScript type is an array type.
43
+ *
44
+ * Handles Array<T>, T[], and readonly arrays.
45
+ *
46
+ * @param type - The TypeScript type to check
47
+ * @param checker - The TypeScript type checker instance
48
+ * @returns True if the type is an array type
49
+ */
50
+ export declare function isArrayType(type: ts.Type, checker: ts.TypeChecker): boolean;
51
+ /**
52
+ * Determines the field type category from a TypeScript type.
53
+ *
54
+ * Categories help determine which decorators are valid for a field.
55
+ *
56
+ * @param type - The TypeScript type to categorize
57
+ * @param checker - The TypeScript type checker instance
58
+ * @returns The field type category
59
+ */
60
+ export declare function getFieldTypeCategory(type: ts.Type, checker: ts.TypeChecker): FieldTypeCategory;
61
+ /**
62
+ * Gets the TypeScript type of a class property.
63
+ */
64
+ export declare function getPropertyType(node: TSESTree.PropertyDefinition, services: ParserServicesWithTypeInformation): ts.Type | null;
65
+ /**
66
+ * Extracts string literal values from a union type.
67
+ * For type "a" | "b" | "c", returns ["a", "b", "c"].
68
+ */
69
+ export declare function getStringLiteralUnionValues(type: ts.Type, _checker: ts.TypeChecker): string[] | null;
70
+ /**
71
+ * Checks if a field is marked as optional (has `?` modifier).
72
+ */
73
+ export declare function isOptionalProperty(node: TSESTree.PropertyDefinition): boolean;
74
+ /**
75
+ * Gets the type checker from parser services.
76
+ */
77
+ export declare function getTypeChecker(services: ParserServicesWithTypeInformation): ts.TypeChecker;
78
+ /**
79
+ * Converts a TypeScript type to a readable string.
80
+ */
81
+ export declare function typeToString(type: ts.Type, checker: ts.TypeChecker): string;
82
+ //# sourceMappingURL=type-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../src/utils/type-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,OAAO,GACP,QAAQ,GACR,OAAO,GACP,SAAS,CAAC;AAEd;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,OAAO,CAiB5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,OAAO,CAiB5E;AAED;;;;;;;;GAQG;A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