diff options
Diffstat (limited to 'packages/iku/src/checker.test.ts')
| -rw-r--r-- | packages/iku/src/checker.test.ts | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/packages/iku/src/checker.test.ts b/packages/iku/src/checker.test.ts index 58a861c..457d956 100644 --- a/packages/iku/src/checker.test.ts +++ b/packages/iku/src/checker.test.ts @@ -280,4 +280,61 @@ console.log(a); expect(errors).toHaveLength(3); }); }); + describe("comments", () => { + it("detects single-line comments by default", () => { + const content = `const a = 1; +// this is a comment +const b = 2; +`; + const filePath = createTempFile(content); + const errors = checkFile(filePath); + + cleanupTempFile(filePath); + expect(errors.some((error) => error.includes("Comment detected"))).toBe(true); + }); + it("detects multi-line comments by default", () => { + const content = `const a = 1; +/* this is a + multi-line comment */ +const b = 2; +`; + const filePath = createTempFile(content); + const errors = checkFile(filePath); + + cleanupTempFile(filePath); + expect(errors.some((error) => error.includes("Comment detected"))).toBe(true); + }); + it("detects trailing comments by default", () => { + const content = `const a = 1; // trailing comment +`; + const filePath = createTempFile(content); + const errors = checkFile(filePath); + + cleanupTempFile(filePath); + expect(errors.some((error) => error.includes("Comment detected"))).toBe(true); + }); + it("allows comments when noComments is false", () => { + const content = `const a = 1; +// this is a comment +const b = 2; +`; + const filePath = createTempFile(content); + const errors = checkFile(filePath, { noComments: false }); + + cleanupTempFile(filePath); + expect(errors.some((error) => error.includes("Comment detected"))).toBe(false); + }); + it("detects JSDoc comments by default", () => { + const content = `/** + * This is a JSDoc comment + */ +function test() {} +`; + const filePath = createTempFile(content); + const errors = checkFile(filePath); + + cleanupTempFile(filePath); + expect(errors.some((error) => error.includes("Comment detected"))).toBe(true); + }); + }); }); |