@api-extractor-tools/eslint-plugin 0.1.0-alpha.0 → 0.1.0-alpha.2
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/ARCHITECTURE.md +204 -0
- package/CHANGELOG.md +32 -0
- package/README.md +306 -10
- package/api-extractor.json +1 -0
- package/dist/configs/recommended.d.ts +1 -1
- package/dist/configs/recommended.d.ts.map +1 -1
- package/dist/configs/recommended.js +7 -1
- package/dist/configs/recommended.js.map +1 -1
- package/dist/index.d.ts +9 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -15
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +28 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +41 -0
- package/dist/node.js.map +1 -0
- package/dist/rules/extra-release-tag.d.ts +24 -0
- package/dist/rules/extra-release-tag.d.ts.map +1 -0
- package/dist/rules/extra-release-tag.js +141 -0
- package/dist/rules/extra-release-tag.js.map +1 -0
- package/dist/rules/forgotten-export.d.ts +24 -0
- package/dist/rules/forgotten-export.d.ts.map +1 -0
- package/dist/rules/forgotten-export.js +212 -0
- package/dist/rules/forgotten-export.js.map +1 -0
- package/dist/rules/incompatible-release-tags.d.ts +25 -0
- package/dist/rules/incompatible-release-tags.d.ts.map +1 -0
- package/dist/rules/incompatible-release-tags.js +237 -0
- package/dist/rules/incompatible-release-tags.js.map +1 -0
- package/dist/rules/index.d.ts +8 -2
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +13 -1
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/missing-release-tag.d.ts +4 -0
- package/dist/rules/missing-release-tag.d.ts.map +1 -1
- package/dist/rules/missing-release-tag.js +14 -21
- package/dist/rules/missing-release-tag.js.map +1 -1
- package/dist/rules/override-keyword.d.ts +4 -0
- package/dist/rules/override-keyword.d.ts.map +1 -1
- package/dist/rules/override-keyword.js +9 -11
- package/dist/rules/override-keyword.js.map +1 -1
- package/dist/rules/package-documentation.d.ts +5 -2
- package/dist/rules/package-documentation.d.ts.map +1 -1
- package/dist/rules/package-documentation.js +45 -35
- package/dist/rules/package-documentation.js.map +1 -1
- package/dist/rules/public-on-non-exported.d.ts +24 -0
- package/dist/rules/public-on-non-exported.d.ts.map +1 -0
- package/dist/rules/public-on-non-exported.js +191 -0
- package/dist/rules/public-on-non-exported.js.map +1 -0
- package/dist/rules/public-on-private-member.d.ts +24 -0
- package/dist/rules/public-on-private-member.d.ts.map +1 -0
- package/dist/rules/public-on-private-member.js +111 -0
- package/dist/rules/public-on-private-member.js.map +1 -0
- package/dist/rules/valid-enum-type.d.ts +17 -0
- package/dist/rules/valid-enum-type.d.ts.map +1 -0
- package/dist/rules/valid-enum-type.js +206 -0
- package/dist/rules/valid-enum-type.js.map +1 -0
- package/dist/types.d.ts +66 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/tsdoc-parser.d.ts +37 -6
- package/dist/utils/tsdoc-parser.d.ts.map +1 -1
- package/dist/utils/tsdoc-parser.js +40 -0
- package/dist/utils/tsdoc-parser.js.map +1 -1
- package/docs/rules/valid-enum-type.md +153 -0
- package/package.json +22 -8
- package/src/configs/recommended.ts +7 -1
- package/src/index.ts +21 -15
- package/src/node.ts +50 -0
- package/src/rules/extra-release-tag.ts +201 -0
- package/src/rules/forgotten-export.ts +274 -0
- package/src/rules/incompatible-release-tags.ts +331 -0
- package/src/rules/index.ts +13 -1
- package/src/rules/missing-release-tag.ts +11 -26
- package/src/rules/override-keyword.ts +6 -8
- package/src/rules/package-documentation.ts +54 -40
- package/src/rules/public-on-non-exported.ts +265 -0
- package/src/rules/public-on-private-member.ts +157 -0
- package/src/rules/valid-enum-type.ts +252 -0
- package/src/types.ts +60 -17
- package/src/utils/config-loader.ts +1 -0
- package/src/utils/entry-point.ts +1 -0
- package/src/utils/tsdoc-parser.ts +67 -0
- package/temp/eslint-plugin.api.md +101 -32
- package/test/index.test.ts +1 -0
- package/test/rules/extra-release-tag.test.ts +276 -0
- package/test/rules/forgotten-export.test.ts +190 -0
- package/test/rules/incompatible-release-tags.test.ts +340 -0
- package/test/rules/missing-release-tag.test.ts +2 -1
- package/test/rules/override-keyword.test.ts +2 -1
- package/test/rules/package-documentation.test.ts +113 -64
- package/test/rules/public-on-non-exported.test.ts +201 -0
- package/test/rules/public-on-private-member.test.ts +207 -0
- package/test/rules/valid-enum-type.test.ts +409 -0
- package/test/types.test-d.ts +20 -0
- package/test/utils/config-loader.test.ts +1 -0
- package/test/utils/tsdoc-parser.test.ts +117 -9
- package/tsconfig.json +1 -0
- package/vitest.config.mts +1 -0
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -21
- package/dist/utils/index.js.map +0 -1
- package/src/utils/index.ts +0 -17
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { RuleTester } from '@typescript-eslint/rule-tester'
|
|
2
|
+
import { describe, it, afterAll } from 'vitest'
|
|
3
|
+
import { validEnumType } from '../../src/rules/valid-enum-type'
|
|
4
|
+
import parser from '@typescript-eslint/parser'
|
|
5
|
+
|
|
6
|
+
RuleTester.afterAll = afterAll
|
|
7
|
+
RuleTester.describe = describe
|
|
8
|
+
RuleTester.it = it
|
|
9
|
+
|
|
10
|
+
const ruleTester = new RuleTester({
|
|
11
|
+
languageOptions: {
|
|
12
|
+
parser,
|
|
13
|
+
parserOptions: {
|
|
14
|
+
ecmaVersion: 2022,
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe('valid-enum-type', () => {
|
|
21
|
+
ruleTester.run('valid-enum-type', validEnumType, {
|
|
22
|
+
valid: [
|
|
23
|
+
// @enumType open on enum declaration
|
|
24
|
+
{
|
|
25
|
+
code: `
|
|
26
|
+
/**
|
|
27
|
+
* Feature flags that may expand over time.
|
|
28
|
+
* @enumType open
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export enum FeatureFlag {
|
|
32
|
+
DarkMode = 'dark_mode',
|
|
33
|
+
BetaFeatures = 'beta_features',
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
},
|
|
37
|
+
// @enumType closed on enum declaration
|
|
38
|
+
{
|
|
39
|
+
code: `
|
|
40
|
+
/**
|
|
41
|
+
* Status values for an order.
|
|
42
|
+
* @enumType closed
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export enum OrderStatus {
|
|
46
|
+
Pending = 'pending',
|
|
47
|
+
Shipped = 'shipped',
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
},
|
|
51
|
+
// @enumType open on string literal union type
|
|
52
|
+
{
|
|
53
|
+
code: `
|
|
54
|
+
/**
|
|
55
|
+
* Payment method types - new methods may be added.
|
|
56
|
+
* @enumType open
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export type PaymentMethod = 'card' | 'bank_transfer' | 'crypto';
|
|
60
|
+
`,
|
|
61
|
+
},
|
|
62
|
+
// @enumType closed on string literal union type
|
|
63
|
+
{
|
|
64
|
+
code: `
|
|
65
|
+
/**
|
|
66
|
+
* Fixed set of log levels.
|
|
67
|
+
* @enumType closed
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
71
|
+
`,
|
|
72
|
+
},
|
|
73
|
+
// Case-insensitive: @enumType Open
|
|
74
|
+
{
|
|
75
|
+
code: `
|
|
76
|
+
/**
|
|
77
|
+
* @enumType Open
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export enum Flags { A = 'a' }
|
|
81
|
+
`,
|
|
82
|
+
},
|
|
83
|
+
// Case-insensitive: @enumType CLOSED
|
|
84
|
+
{
|
|
85
|
+
code: `
|
|
86
|
+
/**
|
|
87
|
+
* @enumType CLOSED
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
export type Status = 'ok' | 'error';
|
|
91
|
+
`,
|
|
92
|
+
},
|
|
93
|
+
// Enum without @enumType (valid unless requireOnExported is true)
|
|
94
|
+
{
|
|
95
|
+
code: `
|
|
96
|
+
/**
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export enum MyEnum { A, B }
|
|
100
|
+
`,
|
|
101
|
+
},
|
|
102
|
+
// String literal union without @enumType
|
|
103
|
+
{
|
|
104
|
+
code: `
|
|
105
|
+
/**
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
export type MyType = 'a' | 'b';
|
|
109
|
+
`,
|
|
110
|
+
},
|
|
111
|
+
// Non-exported enum without @enumType
|
|
112
|
+
{
|
|
113
|
+
code: `
|
|
114
|
+
enum PrivateEnum { A, B }
|
|
115
|
+
`,
|
|
116
|
+
},
|
|
117
|
+
// Interface without @enumType (no error - @enumType not applicable)
|
|
118
|
+
{
|
|
119
|
+
code: `
|
|
120
|
+
/**
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export interface MyInterface {}
|
|
124
|
+
`,
|
|
125
|
+
},
|
|
126
|
+
// Class without @enumType (no error - @enumType not applicable)
|
|
127
|
+
{
|
|
128
|
+
code: `
|
|
129
|
+
/**
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
export class MyClass {}
|
|
133
|
+
`,
|
|
134
|
+
},
|
|
135
|
+
// Non-string-literal union type without @enumType (valid)
|
|
136
|
+
{
|
|
137
|
+
code: `
|
|
138
|
+
/**
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export type MyType = string | number;
|
|
142
|
+
`,
|
|
143
|
+
},
|
|
144
|
+
// const enum with @enumType
|
|
145
|
+
{
|
|
146
|
+
code: `
|
|
147
|
+
/**
|
|
148
|
+
* @enumType closed
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
export const enum Direction { Up, Down }
|
|
152
|
+
`,
|
|
153
|
+
},
|
|
154
|
+
// Empty enum with @enumType
|
|
155
|
+
{
|
|
156
|
+
code: `
|
|
157
|
+
/**
|
|
158
|
+
* @enumType open
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
export enum EmptyEnum {}
|
|
162
|
+
`,
|
|
163
|
+
},
|
|
164
|
+
// Single-literal union with @enumType
|
|
165
|
+
{
|
|
166
|
+
code: `
|
|
167
|
+
/**
|
|
168
|
+
* @enumType closed
|
|
169
|
+
* @public
|
|
170
|
+
*/
|
|
171
|
+
export type Single = 'only';
|
|
172
|
+
`,
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
invalid: [
|
|
176
|
+
// @enumType without value
|
|
177
|
+
{
|
|
178
|
+
code: `
|
|
179
|
+
/**
|
|
180
|
+
* @enumType
|
|
181
|
+
* @public
|
|
182
|
+
*/
|
|
183
|
+
export enum MyEnum { A, B }
|
|
184
|
+
`,
|
|
185
|
+
errors: [{ messageId: 'missingValue' }],
|
|
186
|
+
},
|
|
187
|
+
// @enumType with invalid value "foo"
|
|
188
|
+
{
|
|
189
|
+
code: `
|
|
190
|
+
/**
|
|
191
|
+
* @enumType foo
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export enum MyEnum { A, B }
|
|
195
|
+
`,
|
|
196
|
+
errors: [{ messageId: 'invalidValue', data: { value: 'foo' } }],
|
|
197
|
+
},
|
|
198
|
+
// @enumType with invalid value "opened"
|
|
199
|
+
{
|
|
200
|
+
code: `
|
|
201
|
+
/**
|
|
202
|
+
* @enumType opened
|
|
203
|
+
* @public
|
|
204
|
+
*/
|
|
205
|
+
export type Status = 'a' | 'b';
|
|
206
|
+
`,
|
|
207
|
+
errors: [{ messageId: 'invalidValue', data: { value: 'opened' } }],
|
|
208
|
+
},
|
|
209
|
+
// @enumType with invalid value "close"
|
|
210
|
+
{
|
|
211
|
+
code: `
|
|
212
|
+
/**
|
|
213
|
+
* @enumType close
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
export enum MyEnum { A }
|
|
217
|
+
`,
|
|
218
|
+
errors: [{ messageId: 'invalidValue', data: { value: 'close' } }],
|
|
219
|
+
},
|
|
220
|
+
// @enumType with invalid value "true"
|
|
221
|
+
{
|
|
222
|
+
code: `
|
|
223
|
+
/**
|
|
224
|
+
* @enumType true
|
|
225
|
+
* @public
|
|
226
|
+
*/
|
|
227
|
+
export type MyType = 'x' | 'y';
|
|
228
|
+
`,
|
|
229
|
+
errors: [{ messageId: 'invalidValue', data: { value: 'true' } }],
|
|
230
|
+
},
|
|
231
|
+
// Multiple @enumType tags
|
|
232
|
+
{
|
|
233
|
+
code: `
|
|
234
|
+
/**
|
|
235
|
+
* @enumType open
|
|
236
|
+
* @enumType closed
|
|
237
|
+
* @public
|
|
238
|
+
*/
|
|
239
|
+
export enum MyEnum { A, B }
|
|
240
|
+
`,
|
|
241
|
+
errors: [{ messageId: 'multipleEnumTypes' }],
|
|
242
|
+
},
|
|
243
|
+
// @enumType on interface (invalid construct)
|
|
244
|
+
{
|
|
245
|
+
code: `
|
|
246
|
+
/**
|
|
247
|
+
* @enumType open
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
export interface MyInterface {}
|
|
251
|
+
`,
|
|
252
|
+
errors: [{ messageId: 'invalidConstruct' }],
|
|
253
|
+
},
|
|
254
|
+
// @enumType on class (invalid construct)
|
|
255
|
+
{
|
|
256
|
+
code: `
|
|
257
|
+
/**
|
|
258
|
+
* @enumType open
|
|
259
|
+
* @public
|
|
260
|
+
*/
|
|
261
|
+
export class MyClass {}
|
|
262
|
+
`,
|
|
263
|
+
errors: [{ messageId: 'invalidConstruct' }],
|
|
264
|
+
},
|
|
265
|
+
// @enumType on function (invalid construct)
|
|
266
|
+
{
|
|
267
|
+
code: `
|
|
268
|
+
/**
|
|
269
|
+
* @enumType open
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
export function myFunction() {}
|
|
273
|
+
`,
|
|
274
|
+
errors: [{ messageId: 'invalidConstruct' }],
|
|
275
|
+
},
|
|
276
|
+
// @enumType on variable (invalid construct)
|
|
277
|
+
{
|
|
278
|
+
code: `
|
|
279
|
+
/**
|
|
280
|
+
* @enumType open
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
export const MY_CONST = 42;
|
|
284
|
+
`,
|
|
285
|
+
errors: [{ messageId: 'invalidConstruct' }],
|
|
286
|
+
},
|
|
287
|
+
// @enumType on numeric type (invalid construct)
|
|
288
|
+
{
|
|
289
|
+
code: `
|
|
290
|
+
/**
|
|
291
|
+
* @enumType open
|
|
292
|
+
* @public
|
|
293
|
+
*/
|
|
294
|
+
export type MyType = number;
|
|
295
|
+
`,
|
|
296
|
+
errors: [{ messageId: 'invalidConstruct' }],
|
|
297
|
+
},
|
|
298
|
+
// @enumType on numeric literal union (invalid construct)
|
|
299
|
+
{
|
|
300
|
+
code: `
|
|
301
|
+
/**
|
|
302
|
+
* @enumType open
|
|
303
|
+
* @public
|
|
304
|
+
*/
|
|
305
|
+
export type Status = 0 | 1 | 2;
|
|
306
|
+
`,
|
|
307
|
+
errors: [{ messageId: 'invalidConstruct' }],
|
|
308
|
+
},
|
|
309
|
+
// @enumType on mixed literal union (invalid construct)
|
|
310
|
+
{
|
|
311
|
+
code: `
|
|
312
|
+
/**
|
|
313
|
+
* @enumType open
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
export type Mixed = 'a' | 1;
|
|
317
|
+
`,
|
|
318
|
+
errors: [{ messageId: 'invalidConstruct' }],
|
|
319
|
+
},
|
|
320
|
+
// @enumType on non-union, non-literal type alias (invalid construct)
|
|
321
|
+
{
|
|
322
|
+
code: `
|
|
323
|
+
/**
|
|
324
|
+
* @enumType open
|
|
325
|
+
* @public
|
|
326
|
+
*/
|
|
327
|
+
export type MyType = string;
|
|
328
|
+
`,
|
|
329
|
+
errors: [{ messageId: 'invalidConstruct' }],
|
|
330
|
+
},
|
|
331
|
+
],
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
// Test with requireOnExported option
|
|
335
|
+
describe('with requireOnExported option', () => {
|
|
336
|
+
ruleTester.run('valid-enum-type with requireOnExported', validEnumType, {
|
|
337
|
+
valid: [
|
|
338
|
+
// Exported enum with @enumType (satisfies requirement)
|
|
339
|
+
{
|
|
340
|
+
code: `
|
|
341
|
+
/**
|
|
342
|
+
* @enumType open
|
|
343
|
+
* @public
|
|
344
|
+
*/
|
|
345
|
+
export enum MyEnum { A }
|
|
346
|
+
`,
|
|
347
|
+
options: [{ requireOnExported: true }],
|
|
348
|
+
},
|
|
349
|
+
// Exported string literal union with @enumType
|
|
350
|
+
{
|
|
351
|
+
code: `
|
|
352
|
+
/**
|
|
353
|
+
* @enumType closed
|
|
354
|
+
* @public
|
|
355
|
+
*/
|
|
356
|
+
export type Status = 'ok' | 'error';
|
|
357
|
+
`,
|
|
358
|
+
options: [{ requireOnExported: true }],
|
|
359
|
+
},
|
|
360
|
+
// Non-exported enum without @enumType (not required)
|
|
361
|
+
{
|
|
362
|
+
code: `
|
|
363
|
+
enum PrivateEnum { A }
|
|
364
|
+
`,
|
|
365
|
+
options: [{ requireOnExported: true }],
|
|
366
|
+
},
|
|
367
|
+
// Non-exported type alias without @enumType
|
|
368
|
+
{
|
|
369
|
+
code: `
|
|
370
|
+
type PrivateType = 'a' | 'b';
|
|
371
|
+
`,
|
|
372
|
+
options: [{ requireOnExported: true }],
|
|
373
|
+
},
|
|
374
|
+
],
|
|
375
|
+
invalid: [
|
|
376
|
+
// Exported enum without @enumType
|
|
377
|
+
{
|
|
378
|
+
code: `
|
|
379
|
+
/**
|
|
380
|
+
* @public
|
|
381
|
+
*/
|
|
382
|
+
export enum MyEnum { A }
|
|
383
|
+
`,
|
|
384
|
+
options: [{ requireOnExported: true }],
|
|
385
|
+
errors: [{ messageId: 'missingEnumType' }],
|
|
386
|
+
},
|
|
387
|
+
// Exported string literal union without @enumType
|
|
388
|
+
{
|
|
389
|
+
code: `
|
|
390
|
+
/**
|
|
391
|
+
* @public
|
|
392
|
+
*/
|
|
393
|
+
export type Status = 'ok' | 'error';
|
|
394
|
+
`,
|
|
395
|
+
options: [{ requireOnExported: true }],
|
|
396
|
+
errors: [{ messageId: 'missingEnumType' }],
|
|
397
|
+
},
|
|
398
|
+
// Exported enum without any TSDoc comment
|
|
399
|
+
{
|
|
400
|
+
code: `
|
|
401
|
+
export enum MyEnum { A }
|
|
402
|
+
`,
|
|
403
|
+
options: [{ requireOnExported: true }],
|
|
404
|
+
errors: [{ messageId: 'missingEnumType' }],
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
})
|
|
408
|
+
})
|
|
409
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { expectType, expectAssignable } from 'tsd'
|
|
2
|
+
import type {
|
|
3
|
+
ReleaseTag,
|
|
4
|
+
ApiExtractorConfig,
|
|
5
|
+
MissingReleaseTagRuleOptions,
|
|
6
|
+
} from '../src/index'
|
|
7
|
+
import { RELEASE_TAGS } from '../src/index'
|
|
8
|
+
|
|
9
|
+
// Test type exports - ReleaseTag is a union type
|
|
10
|
+
expectAssignable<ReleaseTag>('alpha')
|
|
11
|
+
expectAssignable<ReleaseTag>('beta')
|
|
12
|
+
expectAssignable<ReleaseTag>('public')
|
|
13
|
+
expectAssignable<ReleaseTag>('internal')
|
|
14
|
+
|
|
15
|
+
// Test option types
|
|
16
|
+
expectAssignable<ApiExtractorConfig>({})
|
|
17
|
+
expectAssignable<MissingReleaseTagRuleOptions>({})
|
|
18
|
+
|
|
19
|
+
// Test constant exports
|
|
20
|
+
expectType<typeof RELEASE_TAGS>(RELEASE_TAGS)
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
extractReleaseTag,
|
|
5
5
|
hasOverrideTag,
|
|
6
6
|
hasPackageDocumentation,
|
|
7
|
+
extractEnumType,
|
|
7
8
|
} from '../../src/utils/tsdoc-parser'
|
|
8
9
|
|
|
9
10
|
describe('tsdoc-parser', () => {
|
|
@@ -33,7 +34,7 @@ describe('tsdoc-parser', () => {
|
|
|
33
34
|
* @public
|
|
34
35
|
*/`
|
|
35
36
|
const result = parseTSDocComment(comment)
|
|
36
|
-
const tag = extractReleaseTag(result.docComment
|
|
37
|
+
const tag = extractReleaseTag(result.docComment)
|
|
37
38
|
expect(tag).toBe('public')
|
|
38
39
|
})
|
|
39
40
|
|
|
@@ -42,7 +43,7 @@ describe('tsdoc-parser', () => {
|
|
|
42
43
|
* @beta
|
|
43
44
|
*/`
|
|
44
45
|
const result = parseTSDocComment(comment)
|
|
45
|
-
const tag = extractReleaseTag(result.docComment
|
|
46
|
+
const tag = extractReleaseTag(result.docComment)
|
|
46
47
|
expect(tag).toBe('beta')
|
|
47
48
|
})
|
|
48
49
|
|
|
@@ -51,7 +52,7 @@ describe('tsdoc-parser', () => {
|
|
|
51
52
|
* @alpha
|
|
52
53
|
*/`
|
|
53
54
|
const result = parseTSDocComment(comment)
|
|
54
|
-
const tag = extractReleaseTag(result.docComment
|
|
55
|
+
const tag = extractReleaseTag(result.docComment)
|
|
55
56
|
expect(tag).toBe('alpha')
|
|
56
57
|
})
|
|
57
58
|
|
|
@@ -60,7 +61,7 @@ describe('tsdoc-parser', () => {
|
|
|
60
61
|
* @internal
|
|
61
62
|
*/`
|
|
62
63
|
const result = parseTSDocComment(comment)
|
|
63
|
-
const tag = extractReleaseTag(result.docComment
|
|
64
|
+
const tag = extractReleaseTag(result.docComment)
|
|
64
65
|
expect(tag).toBe('internal')
|
|
65
66
|
})
|
|
66
67
|
|
|
@@ -69,7 +70,7 @@ describe('tsdoc-parser', () => {
|
|
|
69
70
|
* Just a description.
|
|
70
71
|
*/`
|
|
71
72
|
const result = parseTSDocComment(comment)
|
|
72
|
-
const tag = extractReleaseTag(result.docComment
|
|
73
|
+
const tag = extractReleaseTag(result.docComment)
|
|
73
74
|
expect(tag).toBeUndefined()
|
|
74
75
|
})
|
|
75
76
|
})
|
|
@@ -80,7 +81,7 @@ describe('tsdoc-parser', () => {
|
|
|
80
81
|
* @override
|
|
81
82
|
*/`
|
|
82
83
|
const result = parseTSDocComment(comment)
|
|
83
|
-
expect(hasOverrideTag(result.docComment
|
|
84
|
+
expect(hasOverrideTag(result.docComment)).toBe(true)
|
|
84
85
|
})
|
|
85
86
|
|
|
86
87
|
it('should return false when no @override tag', () => {
|
|
@@ -88,7 +89,7 @@ describe('tsdoc-parser', () => {
|
|
|
88
89
|
* Just a comment.
|
|
89
90
|
*/`
|
|
90
91
|
const result = parseTSDocComment(comment)
|
|
91
|
-
expect(hasOverrideTag(result.docComment
|
|
92
|
+
expect(hasOverrideTag(result.docComment)).toBe(false)
|
|
92
93
|
})
|
|
93
94
|
})
|
|
94
95
|
|
|
@@ -99,7 +100,7 @@ describe('tsdoc-parser', () => {
|
|
|
99
100
|
* @packageDocumentation
|
|
100
101
|
*/`
|
|
101
102
|
const result = parseTSDocComment(comment)
|
|
102
|
-
expect(hasPackageDocumentation(result.docComment
|
|
103
|
+
expect(hasPackageDocumentation(result.docComment)).toBe(true)
|
|
103
104
|
})
|
|
104
105
|
|
|
105
106
|
it('should return false when no @packageDocumentation tag', () => {
|
|
@@ -107,7 +108,114 @@ describe('tsdoc-parser', () => {
|
|
|
107
108
|
* Just a comment.
|
|
108
109
|
*/`
|
|
109
110
|
const result = parseTSDocComment(comment)
|
|
110
|
-
expect(hasPackageDocumentation(result.docComment
|
|
111
|
+
expect(hasPackageDocumentation(result.docComment)).toBe(false)
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
describe('extractEnumType', () => {
|
|
116
|
+
it('should extract @enumType open', () => {
|
|
117
|
+
const comment = `/**
|
|
118
|
+
* @enumType open
|
|
119
|
+
*/`
|
|
120
|
+
const result = extractEnumType(comment)
|
|
121
|
+
expect(result.found).toBe(true)
|
|
122
|
+
expect(result.count).toBe(1)
|
|
123
|
+
expect(result.value).toBe('open')
|
|
124
|
+
expect(result.isValid).toBe(true)
|
|
125
|
+
expect(result.rawValue).toBe('open')
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('should extract @enumType closed', () => {
|
|
129
|
+
const comment = `/**
|
|
130
|
+
* @enumType closed
|
|
131
|
+
*/`
|
|
132
|
+
const result = extractEnumType(comment)
|
|
133
|
+
expect(result.found).toBe(true)
|
|
134
|
+
expect(result.count).toBe(1)
|
|
135
|
+
expect(result.value).toBe('closed')
|
|
136
|
+
expect(result.isValid).toBe(true)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('should handle case-insensitive values (Open)', () => {
|
|
140
|
+
const comment = `/**
|
|
141
|
+
* @enumType Open
|
|
142
|
+
*/`
|
|
143
|
+
const result = extractEnumType(comment)
|
|
144
|
+
expect(result.found).toBe(true)
|
|
145
|
+
expect(result.value).toBe('open')
|
|
146
|
+
expect(result.isValid).toBe(true)
|
|
147
|
+
expect(result.rawValue).toBe('Open')
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
it('should handle case-insensitive values (CLOSED)', () => {
|
|
151
|
+
const comment = `/**
|
|
152
|
+
* @enumType CLOSED
|
|
153
|
+
*/`
|
|
154
|
+
const result = extractEnumType(comment)
|
|
155
|
+
expect(result.found).toBe(true)
|
|
156
|
+
expect(result.value).toBe('closed')
|
|
157
|
+
expect(result.isValid).toBe(true)
|
|
158
|
+
expect(result.rawValue).toBe('CLOSED')
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('should detect invalid value', () => {
|
|
162
|
+
const comment = `/**
|
|
163
|
+
* @enumType foo
|
|
164
|
+
*/`
|
|
165
|
+
const result = extractEnumType(comment)
|
|
166
|
+
expect(result.found).toBe(true)
|
|
167
|
+
expect(result.count).toBe(1)
|
|
168
|
+
expect(result.value).toBe('foo')
|
|
169
|
+
expect(result.isValid).toBe(false)
|
|
170
|
+
expect(result.rawValue).toBe('foo')
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('should detect missing value', () => {
|
|
174
|
+
const comment = `/**
|
|
175
|
+
* @enumType
|
|
176
|
+
* @public
|
|
177
|
+
*/`
|
|
178
|
+
const result = extractEnumType(comment)
|
|
179
|
+
expect(result.found).toBe(true)
|
|
180
|
+
expect(result.count).toBe(1)
|
|
181
|
+
expect(result.rawValue).toBeUndefined()
|
|
182
|
+
expect(result.isValid).toBe(false)
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('should detect multiple @enumType tags', () => {
|
|
186
|
+
const comment = `/**
|
|
187
|
+
* @enumType open
|
|
188
|
+
* @enumType closed
|
|
189
|
+
*/`
|
|
190
|
+
const result = extractEnumType(comment)
|
|
191
|
+
expect(result.found).toBe(true)
|
|
192
|
+
expect(result.count).toBe(2)
|
|
193
|
+
// First value is captured
|
|
194
|
+
expect(result.value).toBe('open')
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it('should return not found when no @enumType tag', () => {
|
|
198
|
+
const comment = `/**
|
|
199
|
+
* Just a comment.
|
|
200
|
+
* @public
|
|
201
|
+
*/`
|
|
202
|
+
const result = extractEnumType(comment)
|
|
203
|
+
expect(result.found).toBe(false)
|
|
204
|
+
expect(result.count).toBe(0)
|
|
205
|
+
expect(result.value).toBeUndefined()
|
|
206
|
+
expect(result.isValid).toBe(false)
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('should handle @enumType with other tags', () => {
|
|
210
|
+
const comment = `/**
|
|
211
|
+
* Description of the enum.
|
|
212
|
+
* @enumType open
|
|
213
|
+
* @public
|
|
214
|
+
*/`
|
|
215
|
+
const result = extractEnumType(comment)
|
|
216
|
+
expect(result.found).toBe(true)
|
|
217
|
+
expect(result.value).toBe('open')
|
|
218
|
+
expect(result.isValid).toBe(true)
|
|
111
219
|
})
|
|
112
220
|
})
|
|
113
221
|
})
|
package/tsconfig.json
CHANGED
package/vitest.config.mts
CHANGED
package/dist/utils/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility module exports.
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export { resolveConfig, getMessageLogLevel } from './config-loader';
|
|
6
|
-
export { parseTSDocComment, extractReleaseTag, hasOverrideTag, hasPackageDocumentation, getLeadingTSDocComment, findAllTSDocComments, } from './tsdoc-parser';
|
|
7
|
-
export { findPackageJson, isEntryPoint } from './entry-point';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEnE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/utils/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Utility module exports.
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.isEntryPoint = exports.findPackageJson = exports.findAllTSDocComments = exports.getLeadingTSDocComment = exports.hasPackageDocumentation = exports.hasOverrideTag = exports.extractReleaseTag = exports.parseTSDocComment = exports.getMessageLogLevel = exports.resolveConfig = void 0;
|
|
8
|
-
var config_loader_1 = require("./config-loader");
|
|
9
|
-
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return config_loader_1.resolveConfig; } });
|
|
10
|
-
Object.defineProperty(exports, "getMessageLogLevel", { enumerable: true, get: function () { return config_loader_1.getMessageLogLevel; } });
|
|
11
|
-
var tsdoc_parser_1 = require("./tsdoc-parser");
|
|
12
|
-
Object.defineProperty(exports, "parseTSDocComment", { enumerable: true, get: function () { return tsdoc_parser_1.parseTSDocComment; } });
|
|
13
|
-
Object.defineProperty(exports, "extractReleaseTag", { enumerable: true, get: function () { return tsdoc_parser_1.extractReleaseTag; } });
|
|
14
|
-
Object.defineProperty(exports, "hasOverrideTag", { enumerable: true, get: function () { return tsdoc_parser_1.hasOverrideTag; } });
|
|
15
|
-
Object.defineProperty(exports, "hasPackageDocumentation", { enumerable: true, get: function () { return tsdoc_parser_1.hasPackageDocumentation; } });
|
|
16
|
-
Object.defineProperty(exports, "getLeadingTSDocComment", { enumerable: true, get: function () { return tsdoc_parser_1.getLeadingTSDocComment; } });
|
|
17
|
-
Object.defineProperty(exports, "findAllTSDocComments", { enumerable: true, get: function () { return tsdoc_parser_1.findAllTSDocComments; } });
|
|
18
|
-
var entry_point_1 = require("./entry-point");
|
|
19
|
-
Object.defineProperty(exports, "findPackageJson", { enumerable: true, get: function () { return entry_point_1.findPackageJson; } });
|
|
20
|
-
Object.defineProperty(exports, "isEntryPoint", { enumerable: true, get: function () { return entry_point_1.isEntryPoint; } });
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iDAAmE;AAA1D,8GAAA,aAAa,OAAA;AAAE,mHAAA,kBAAkB,OAAA;AAE1C,+CAOuB;AANrB,iHAAA,iBAAiB,OAAA;AACjB,iHAAA,iBAAiB,OAAA;AACjB,8GAAA,cAAc,OAAA;AACd,uHAAA,uBAAuB,OAAA;AACvB,sHAAA,sBAAsB,OAAA;AACtB,oHAAA,oBAAoB,OAAA;AAGtB,6CAA6D;AAApD,8GAAA,eAAe,OAAA;AAAE,2GAAA,YAAY,OAAA"}
|
package/src/utils/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility module exports.
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export { resolveConfig, getMessageLogLevel } from './config-loader'
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
parseTSDocComment,
|
|
10
|
-
extractReleaseTag,
|
|
11
|
-
hasOverrideTag,
|
|
12
|
-
hasPackageDocumentation,
|
|
13
|
-
getLeadingTSDocComment,
|
|
14
|
-
findAllTSDocComments,
|
|
15
|
-
} from './tsdoc-parser'
|
|
16
|
-
|
|
17
|
-
export { findPackageJson, isEntryPoint } from './entry-point'
|