jsdoczoom 0.4.11 → 0.4.13

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 (61) hide show
  1. package/dist/{src/drilldown.js → drilldown.js} +9 -6
  2. package/package.json +2 -2
  3. package/dist/test/barrel.test.js +0 -77
  4. package/dist/test/cache.test.js +0 -222
  5. package/dist/test/cli.test.js +0 -479
  6. package/dist/test/drilldown-barrel.test.js +0 -383
  7. package/dist/test/drilldown.test.js +0 -469
  8. package/dist/test/errors.test.js +0 -26
  9. package/dist/test/eslint-engine.test.js +0 -130
  10. package/dist/test/eslint-plugin.test.js +0 -291
  11. package/dist/test/file-discovery.test.js +0 -72
  12. package/dist/test/jsdoc-parser.test.js +0 -353
  13. package/dist/test/lint.test.js +0 -413
  14. package/dist/test/selector.test.js +0 -93
  15. package/dist/test/type-declarations.test.js +0 -321
  16. package/dist/test/validate.test.js +0 -361
  17. package/types/test/barrel.test.d.ts +0 -1
  18. package/types/test/cache.test.d.ts +0 -8
  19. package/types/test/cli.test.d.ts +0 -1
  20. package/types/test/drilldown-barrel.test.d.ts +0 -1
  21. package/types/test/drilldown.test.d.ts +0 -1
  22. package/types/test/errors.test.d.ts +0 -1
  23. package/types/test/eslint-engine.test.d.ts +0 -6
  24. package/types/test/eslint-plugin.test.d.ts +0 -1
  25. package/types/test/file-discovery.test.d.ts +0 -1
  26. package/types/test/jsdoc-parser.test.d.ts +0 -1
  27. package/types/test/lint.test.d.ts +0 -9
  28. package/types/test/selector.test.d.ts +0 -1
  29. package/types/test/type-declarations.test.d.ts +0 -1
  30. package/types/test/validate.test.d.ts +0 -1
  31. /package/dist/{src/barrel.js → barrel.js} +0 -0
  32. /package/dist/{src/cache.js → cache.js} +0 -0
  33. /package/dist/{src/cli.js → cli.js} +0 -0
  34. /package/dist/{src/errors.js → errors.js} +0 -0
  35. /package/dist/{src/eslint-engine.js → eslint-engine.js} +0 -0
  36. /package/dist/{src/eslint-plugin.js → eslint-plugin.js} +0 -0
  37. /package/dist/{src/file-discovery.js → file-discovery.js} +0 -0
  38. /package/dist/{src/index.js → index.js} +0 -0
  39. /package/dist/{src/jsdoc-parser.js → jsdoc-parser.js} +0 -0
  40. /package/dist/{src/lint.js → lint.js} +0 -0
  41. /package/dist/{src/selector.js → selector.js} +0 -0
  42. /package/dist/{src/skill-text.js → skill-text.js} +0 -0
  43. /package/dist/{src/type-declarations.js → type-declarations.js} +0 -0
  44. /package/dist/{src/types.js → types.js} +0 -0
  45. /package/dist/{src/validate.js → validate.js} +0 -0
  46. /package/types/{src/barrel.d.ts → barrel.d.ts} +0 -0
  47. /package/types/{src/cache.d.ts → cache.d.ts} +0 -0
  48. /package/types/{src/cli.d.ts → cli.d.ts} +0 -0
  49. /package/types/{src/drilldown.d.ts → drilldown.d.ts} +0 -0
  50. /package/types/{src/errors.d.ts → errors.d.ts} +0 -0
  51. /package/types/{src/eslint-engine.d.ts → eslint-engine.d.ts} +0 -0
  52. /package/types/{src/eslint-plugin.d.ts → eslint-plugin.d.ts} +0 -0
  53. /package/types/{src/file-discovery.d.ts → file-discovery.d.ts} +0 -0
  54. /package/types/{src/index.d.ts → index.d.ts} +0 -0
  55. /package/types/{src/jsdoc-parser.d.ts → jsdoc-parser.d.ts} +0 -0
  56. /package/types/{src/lint.d.ts → lint.d.ts} +0 -0
  57. /package/types/{src/selector.d.ts → selector.d.ts} +0 -0
  58. /package/types/{src/skill-text.d.ts → skill-text.d.ts} +0 -0
  59. /package/types/{src/type-declarations.d.ts → type-declarations.d.ts} +0 -0
  60. /package/types/{src/types.d.ts → types.d.ts} +0 -0
  61. /package/types/{src/validate.d.ts → validate.d.ts} +0 -0
@@ -1,413 +0,0 @@
1
- /**
2
- * Tests for the lint module which runs comprehensive JSDoc quality checks
3
- * using the ESLint engine. Uses temp directories with controlled fixtures
4
- * to verify diagnostic output, summary statistics, limit capping, file
5
- * filtering, and error handling.
6
- *
7
- * @summary Unit and integration tests for lint() and lintFiles()
8
- */
9
- import fs from "node:fs";
10
- import os from "node:os";
11
- import path from "node:path";
12
- import { fileURLToPath } from "node:url";
13
- import { describe, expect, it } from "vitest";
14
- import { JsdocError } from "../src/errors.js";
15
- import { lint, lintFiles } from "../src/lint.js";
16
-
17
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
18
- const fixturesDir = path.resolve(__dirname, "fixtures", "leaf-files");
19
- function fixture(name) {
20
- return path.join(fixturesDir, name);
21
- }
22
- /**
23
- * Create a temporary directory, run a callback with it, then clean up.
24
- *
25
- * @param fn - Callback receiving the temp directory path
26
- * @returns Promise that resolves when the callback and cleanup are done
27
- */
28
- function withTempDir(fn) {
29
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "jsdoczoom-lint-"));
30
- return fn(tmpDir).finally(() => fs.rmSync(tmpDir, { recursive: true }));
31
- }
32
- /**
33
- * Write a file into a directory and return its absolute path.
34
- *
35
- * @param dir - Directory to write into
36
- * @param name - File name
37
- * @param content - File content
38
- * @returns Absolute path to the written file
39
- */
40
- function writeFile(dir, name, content) {
41
- const filePath = path.join(dir, name);
42
- fs.writeFileSync(filePath, content);
43
- return filePath;
44
- }
45
- /** A fully valid file that passes all lint rules */
46
- const VALID_FILE = [
47
- "/**",
48
- " * File description explaining the purpose of this module.",
49
- " * @summary File summary for the module",
50
- " */",
51
- "",
52
- "/** The primary numeric value used for calculations */",
53
- "export const x = 1;",
54
- "",
55
- ].join("\n");
56
- /** A file with an exported function missing @param */
57
- const MISSING_PARAM_FILE = [
58
- "/**",
59
- " * File description explaining the purpose of this module.",
60
- " * @summary File summary for the module",
61
- " */",
62
- "",
63
- "/** Does something important with the input */",
64
- "export function foo(x: string): void {}",
65
- "",
66
- ].join("\n");
67
- /** A file with no JSDoc at all */
68
- const NO_JSDOC_FILE = "export const x = 1;\n";
69
- /** A file with only file-level JSDoc and no exports */
70
- const NO_EXPORTS_FILE = [
71
- "/**",
72
- " * File description explaining the purpose of this module.",
73
- " * @summary File summary for the module",
74
- " */",
75
- "",
76
- ].join("\n");
77
- describe("lint", () => {
78
- it("valid file produces no diagnostics", async () => {
79
- await withTempDir(async (dir) => {
80
- writeFile(dir, "valid.ts", VALID_FILE);
81
- const selector = {
82
- type: "glob",
83
- pattern: "*.ts",
84
- depth: undefined,
85
- };
86
- const result = await lint(selector, dir);
87
- expect(result.summary.filesWithIssues).toBe(0);
88
- expect(result.summary.totalDiagnostics).toBe(0);
89
- expect(result.summary.totalFiles).toBe(1);
90
- });
91
- });
92
- it("file missing @param gets lint diagnostic", async () => {
93
- await withTempDir(async (dir) => {
94
- writeFile(dir, "missing-param.ts", MISSING_PARAM_FILE);
95
- const selector = {
96
- type: "glob",
97
- pattern: "*.ts",
98
- depth: undefined,
99
- };
100
- const result = await lint(selector, dir);
101
- expect(result.summary.filesWithIssues).toBe(1);
102
- expect(result.files.length).toBe(1);
103
- expect(
104
- result.files[0].diagnostics.some(
105
- (d) => d.rule === "jsdoc/require-param",
106
- ),
107
- ).toBe(true);
108
- });
109
- });
110
- it("result includes summary counts", async () => {
111
- await withTempDir(async (dir) => {
112
- writeFile(dir, "a.ts", MISSING_PARAM_FILE);
113
- writeFile(dir, "b.ts", VALID_FILE);
114
- const selector = {
115
- type: "glob",
116
- pattern: "*.ts",
117
- depth: undefined,
118
- };
119
- const result = await lint(selector, dir);
120
- expect(result.summary.totalFiles).toBe(2);
121
- expect(result.summary.filesWithIssues).toBe(1);
122
- expect(result.summary.totalDiagnostics).toBeGreaterThan(0);
123
- });
124
- });
125
- it("limit caps files with issues shown", async () => {
126
- await withTempDir(async (dir) => {
127
- writeFile(dir, "a.ts", MISSING_PARAM_FILE);
128
- writeFile(dir, "b.ts", NO_JSDOC_FILE);
129
- writeFile(dir, "c.ts", NO_JSDOC_FILE);
130
- const selector = {
131
- type: "glob",
132
- pattern: "*.ts",
133
- depth: undefined,
134
- };
135
- const result = await lint(selector, dir, 1);
136
- // Only 1 file with issues should be in the files array
137
- expect(result.files.length).toBe(1);
138
- // But summary should reflect actual totals
139
- expect(result.summary.filesWithIssues).toBeGreaterThanOrEqual(2);
140
- expect(result.summary.totalFiles).toBe(3);
141
- });
142
- });
143
- it("lint only reports JSDoc diagnostics, not general code issues", async () => {
144
- await withTempDir(async (dir) => {
145
- const content = [
146
- "/**",
147
- " * File description explaining the purpose of this module.",
148
- " * @summary File summary for the module",
149
- " */",
150
- "",
151
- "/** The unused variable for testing purposes */",
152
- "var unused = 1;",
153
- "",
154
- ].join("\n");
155
- writeFile(dir, "unused.ts", content);
156
- const selector = {
157
- type: "glob",
158
- pattern: "*.ts",
159
- depth: undefined,
160
- };
161
- const result = await lint(selector, dir);
162
- // Should NOT have no-unused-vars or any non-jsdoc rule
163
- for (const file of result.files) {
164
- for (const d of file.diagnostics) {
165
- expect(
166
- d.rule.startsWith("jsdoc/") || d.rule.startsWith("jsdoczoom/"),
167
- ).toBe(true);
168
- }
169
- }
170
- });
171
- });
172
- it("diagnostics include line, column, rule, message, and severity", async () => {
173
- await withTempDir(async (dir) => {
174
- writeFile(dir, "missing-param.ts", MISSING_PARAM_FILE);
175
- const selector = {
176
- type: "glob",
177
- pattern: "*.ts",
178
- depth: undefined,
179
- };
180
- const result = await lint(selector, dir);
181
- expect(result.files.length).toBeGreaterThan(0);
182
- const diag = result.files[0].diagnostics[0];
183
- expect(typeof diag.line).toBe("number");
184
- expect(typeof diag.column).toBe("number");
185
- expect(typeof diag.rule).toBe("string");
186
- expect(typeof diag.message).toBe("string");
187
- expect(["error", "warning"]).toContain(diag.severity);
188
- });
189
- });
190
- it("file paths in result are relative to cwd", async () => {
191
- await withTempDir(async (dir) => {
192
- writeFile(dir, "missing-param.ts", MISSING_PARAM_FILE);
193
- const selector = {
194
- type: "glob",
195
- pattern: "*.ts",
196
- depth: undefined,
197
- };
198
- const result = await lint(selector, dir);
199
- expect(result.files.length).toBeGreaterThan(0);
200
- expect(result.files[0].filePath).toBe("missing-param.ts");
201
- });
202
- });
203
- it("glob with no matches throws NO_FILES_MATCHED", async () => {
204
- await withTempDir(async (dir) => {
205
- const selector = {
206
- type: "glob",
207
- pattern: "nonexistent-*.ts",
208
- depth: undefined,
209
- };
210
- await expect(lint(selector, dir)).rejects.toThrow(JsdocError);
211
- try {
212
- await lint(selector, dir);
213
- } catch (e) {
214
- expect(e).toBeInstanceOf(JsdocError);
215
- expect(e.code).toBe("NO_FILES_MATCHED");
216
- }
217
- });
218
- });
219
- it("file with no exports and valid file-level JSDoc produces no diagnostics", async () => {
220
- await withTempDir(async (dir) => {
221
- writeFile(dir, "no-exports.ts", NO_EXPORTS_FILE);
222
- const selector = {
223
- type: "glob",
224
- pattern: "*.ts",
225
- depth: undefined,
226
- };
227
- const result = await lint(selector, dir);
228
- expect(result.summary.filesWithIssues).toBe(0);
229
- });
230
- });
231
- it("respects gitignore parameter", async () => {
232
- await withTempDir(async (dir) => {
233
- writeFile(dir, "included.ts", MISSING_PARAM_FILE);
234
- writeFile(dir, ".gitignore", "ignored.ts\n");
235
- writeFile(dir, "ignored.ts", NO_JSDOC_FILE);
236
- const selector = {
237
- type: "glob",
238
- pattern: "*.ts",
239
- depth: undefined,
240
- };
241
- // With gitignore=true (default), ignored.ts should be excluded
242
- const resultWithGitignore = await lint(selector, dir, 100, true);
243
- expect(resultWithGitignore.summary.totalFiles).toBe(1);
244
- // With gitignore=false, both files should be included
245
- const resultWithoutGitignore = await lint(selector, dir, 100, false);
246
- expect(resultWithoutGitignore.summary.totalFiles).toBe(2);
247
- });
248
- });
249
- });
250
- describe("lint barrel detection", () => {
251
- it("flags directories with >3 files and no barrel as missingBarrels", async () => {
252
- // leaf-files has 13 .ts files and no index.ts
253
- const selector = {
254
- type: "glob",
255
- pattern: "*.ts",
256
- depth: undefined,
257
- };
258
- const result = await lint(selector, fixturesDir);
259
- expect(result.missingBarrels).toBeDefined();
260
- expect(result.missingBarrels).toContain(".");
261
- });
262
- it("does not flag directories with <=3 files", async () => {
263
- // depth-advancement has only 2 files
264
- const depthDir = path.resolve(__dirname, "fixtures", "depth-advancement");
265
- const selector = {
266
- type: "glob",
267
- pattern: "*.ts",
268
- depth: undefined,
269
- };
270
- const result = await lint(selector, depthDir);
271
- expect(result.missingBarrels).toBeUndefined();
272
- });
273
- it("does not flag directories that have a barrel", async () => {
274
- // barrel-basic has index.ts + helper.ts + utils.ts
275
- const barrelDir = path.resolve(__dirname, "fixtures", "barrel-basic");
276
- const selector = {
277
- type: "glob",
278
- pattern: "*.ts",
279
- depth: undefined,
280
- };
281
- const result = await lint(selector, barrelDir);
282
- expect(result.missingBarrels).toBeUndefined();
283
- });
284
- });
285
- describe("lintFiles barrel detection", () => {
286
- it("flags directories with >3 files and no barrel via lintFiles", async () => {
287
- await withTempDir(async (dir) => {
288
- const files = [];
289
- for (let i = 0; i < 4; i++) {
290
- files.push(writeFile(dir, `file${i}.ts`, VALID_FILE));
291
- }
292
- const result = await lintFiles(files, dir);
293
- expect(result.missingBarrels).toBeDefined();
294
- expect(result.missingBarrels).toContain(".");
295
- });
296
- });
297
- it("does not flag directories with <=3 files via lintFiles", async () => {
298
- await withTempDir(async (dir) => {
299
- const files = [];
300
- for (let i = 0; i < 3; i++) {
301
- files.push(writeFile(dir, `file${i}.ts`, VALID_FILE));
302
- }
303
- const result = await lintFiles(files, dir);
304
- expect(result.missingBarrels).toBeUndefined();
305
- });
306
- });
307
- it("does not flag directories that have a barrel via lintFiles", async () => {
308
- await withTempDir(async (dir) => {
309
- const files = [writeFile(dir, "index.ts", VALID_FILE)];
310
- for (let i = 0; i < 4; i++) {
311
- files.push(writeFile(dir, `file${i}.ts`, VALID_FILE));
312
- }
313
- const result = await lintFiles(files, dir);
314
- expect(result.missingBarrels).toBeUndefined();
315
- });
316
- });
317
- });
318
- describe("lintFiles", () => {
319
- it("lints an explicit list of file paths", async () => {
320
- await withTempDir(async (dir) => {
321
- const filePath = writeFile(dir, "missing-param.ts", MISSING_PARAM_FILE);
322
- const result = await lintFiles([filePath], dir);
323
- expect(result.summary.totalFiles).toBe(1);
324
- expect(result.summary.filesWithIssues).toBe(1);
325
- expect(result.files.length).toBe(1);
326
- });
327
- });
328
- it("filters to .ts/.tsx only", async () => {
329
- await withTempDir(async (dir) => {
330
- const tsFile = writeFile(dir, "valid.ts", VALID_FILE);
331
- const jsFile = path.join(dir, "file.js");
332
- fs.writeFileSync(jsFile, "var x = 1;\n");
333
- const result = await lintFiles([tsFile, jsFile], dir);
334
- // Should only lint the .ts file
335
- expect(result.summary.totalFiles).toBe(1);
336
- });
337
- });
338
- it("handles empty file list", async () => {
339
- const result = await lintFiles([], "/tmp");
340
- expect(result.summary.totalFiles).toBe(0);
341
- expect(result.summary.filesWithIssues).toBe(0);
342
- expect(result.summary.totalDiagnostics).toBe(0);
343
- expect(result.files).toEqual([]);
344
- });
345
- it("handles mixed pass/fail results", async () => {
346
- await withTempDir(async (dir) => {
347
- const validPath = writeFile(dir, "valid.ts", VALID_FILE);
348
- const invalidPath = writeFile(
349
- dir,
350
- "missing-param.ts",
351
- MISSING_PARAM_FILE,
352
- );
353
- const result = await lintFiles([validPath, invalidPath], dir);
354
- expect(result.summary.totalFiles).toBe(2);
355
- expect(result.summary.filesWithIssues).toBe(1);
356
- expect(result.files.length).toBe(1);
357
- expect(result.files[0].filePath).toBe("missing-param.ts");
358
- });
359
- });
360
- it("works with existing leaf-files fixture", async () => {
361
- // description-only.ts has JSDoc without @summary, triggering jsdoczoom/require-file-summary
362
- const result = await lintFiles(
363
- [fixture("description-only.ts")],
364
- fixturesDir,
365
- );
366
- expect(result.summary.totalFiles).toBe(1);
367
- expect(result.summary.filesWithIssues).toBe(1);
368
- expect(
369
- result.files[0].diagnostics.some(
370
- (d) => d.rule === "jsdoczoom/require-file-summary",
371
- ),
372
- ).toBe(true);
373
- });
374
- it("limit caps files shown in result", async () => {
375
- await withTempDir(async (dir) => {
376
- const file1 = writeFile(dir, "a.ts", NO_JSDOC_FILE);
377
- const file2 = writeFile(dir, "b.ts", NO_JSDOC_FILE);
378
- const file3 = writeFile(dir, "c.ts", NO_JSDOC_FILE);
379
- const result = await lintFiles([file1, file2, file3], dir, 2);
380
- expect(result.files.length).toBe(2);
381
- expect(result.summary.filesWithIssues).toBe(3);
382
- expect(result.summary.totalFiles).toBe(3);
383
- });
384
- });
385
- });
386
- describe("cache integration", () => {
387
- it("lint returns cached diagnostics for unchanged files", async () => {
388
- await withTempDir(async (dir) => {
389
- writeFile(dir, "test.ts", MISSING_PARAM_FILE);
390
- const selector = {
391
- type: "glob",
392
- pattern: "*.ts",
393
- depth: undefined,
394
- };
395
- const result1 = await lint(selector, dir);
396
- const result2 = await lint(selector, dir);
397
- expect(result1).toEqual(result2);
398
- });
399
- });
400
- it("lint works with cache disabled", async () => {
401
- await withTempDir(async (dir) => {
402
- writeFile(dir, "test.ts", VALID_FILE);
403
- const selector = {
404
- type: "glob",
405
- pattern: "*.ts",
406
- depth: undefined,
407
- };
408
- const disabledConfig = { enabled: false, directory: "" };
409
- const result = await lint(selector, dir, 100, true, disabledConfig);
410
- expect(result.summary.filesWithIssues).toBe(0);
411
- });
412
- });
413
- });
@@ -1,93 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { JsdocError } from "../src/errors.js";
3
- import { parseSelector } from "../src/selector.js";
4
-
5
- /**
6
- * Verifies glob detection, depth extraction, float rejection, empty-selector
7
- * errors, and edge cases like email-like patterns and relative paths with
8
- * depth suffixes.
9
- *
10
- * @summary Tests for selector string parsing and depth extraction
11
- */
12
- describe("parseSelector", () => {
13
- it("detects glob chars (*, ?, [, {) → type glob", () => {
14
- expect(parseSelector("src/**/*.ts").type).toBe("glob");
15
- expect(parseSelector("src/file?.ts").type).toBe("glob");
16
- expect(parseSelector("src/file[0-9].ts").type).toBe("glob");
17
- expect(parseSelector("src/{a,b}.ts").type).toBe("glob");
18
- });
19
- it("extracts @depth suffix as number (e.g. foo@2 → depth 2)", () => {
20
- const result = parseSelector("foo@2");
21
- expect(result.pattern).toBe("foo");
22
- expect(result.depth).toBe(2);
23
- });
24
- it("rejects negative depth (throws INVALID_DEPTH)", () => {
25
- // Note: Our regex only matches positive digits, so @-5 won't match the pattern
26
- // and will be treated as part of the filename, which is correct behavior
27
- // A truly negative depth would need to be like "file@" followed by validation
28
- // For this test, we'll verify that if someone tries to parse with a negative,
29
- // it's handled appropriately (won't match our pattern, so depth will be undefined)
30
- const result = parseSelector("foo@-5");
31
- // The @-5 doesn't match our pattern, so it's part of the filename
32
- expect(result.pattern).toBe("foo@-5");
33
- expect(result.depth).toBeUndefined();
34
- });
35
- it("rejects non-integer depth (throws INVALID_DEPTH)", () => {
36
- expect(() => parseSelector("foo@abc")).not.toThrow();
37
- // @abc doesn't match digit pattern, so treated as part of filename
38
- const result = parseSelector("foo@abc");
39
- expect(result.pattern).toBe("foo@abc");
40
- expect(result.depth).toBeUndefined();
41
- });
42
- it("rejects float depth (throws INVALID_DEPTH)", () => {
43
- expect(() => parseSelector("foo@2.5")).toThrow(JsdocError);
44
- expect(() => parseSelector("foo@2.5")).toThrow(/integer.*float/i);
45
- });
46
- it("handles bare path with no depth → depth undefined", () => {
47
- const result = parseSelector("src/file.ts");
48
- expect(result.pattern).toBe("src/file.ts");
49
- expect(result.depth).toBeUndefined();
50
- expect(result.type).toBe("path");
51
- });
52
- it("handles glob with depth (e.g. src/**/*.ts@3)", () => {
53
- const result = parseSelector("src/**/*.ts@3");
54
- expect(result.pattern).toBe("src/**/*.ts");
55
- expect(result.depth).toBe(3);
56
- expect(result.type).toBe("glob");
57
- });
58
- it("rejects empty selector (throws INVALID_SELECTOR)", () => {
59
- expect(() => parseSelector("")).toThrow(JsdocError);
60
- expect(() => parseSelector("")).toThrow(/empty/i);
61
- expect(() => parseSelector(" ")).toThrow(JsdocError);
62
- });
63
- it("handles ../ paths as valid path selectors", () => {
64
- const result = parseSelector("../config.js");
65
- expect(result.pattern).toBe("../config.js");
66
- expect(result.type).toBe("path");
67
- expect(result.depth).toBeUndefined();
68
- const result2 = parseSelector("../../lib/utils.ts@2");
69
- expect(result2.pattern).toBe("../../lib/utils.ts");
70
- expect(result2.type).toBe("path");
71
- expect(result2.depth).toBe(2);
72
- });
73
- it("does not treat @ in middle of filename as depth separator when no trailing digits", () => {
74
- const result = parseSelector("user@example.com.ts");
75
- expect(result.pattern).toBe("user@example.com.ts");
76
- expect(result.depth).toBeUndefined();
77
- expect(result.type).toBe("path");
78
- const result2 = parseSelector("file@version.ts@3");
79
- expect(result2.pattern).toBe("file@version.ts");
80
- expect(result2.depth).toBe(3);
81
- expect(result2.type).toBe("path");
82
- });
83
- it("handles depth of 0", () => {
84
- const result = parseSelector("file.ts@0");
85
- expect(result.pattern).toBe("file.ts");
86
- expect(result.depth).toBe(0);
87
- });
88
- it("handles large depth values", () => {
89
- const result = parseSelector("file.ts@999");
90
- expect(result.pattern).toBe("file.ts");
91
- expect(result.depth).toBe(999);
92
- });
93
- });