unqommented
Version:
A Node.js utility that quickly identifies files with uncommented code in your codebase. Designed for developers who want to efficiently tell LLMs exactly which files need comments added.
27 lines (22 loc) • 1.12 kB
JavaScript
require('qtests/setup'); // ensure qtests modifies modules before import
const { test, expect, describe, beforeAll, afterAll } = require('@jest/globals'); // jest globals
const fs = require('fs'); // file system utilities
const path = require('path'); // path utilities
const os = require('os'); // OS utilities for tmp dir
const utils = require('../utils'); // utilities under test
let tmpDir; // temporary directory path
let crlfFile; // file path with CRLF line endings
beforeAll(() => {
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'unqommented-')); // create temp dir
crlfFile = path.join(tmpDir, 'crlf.js'); // path for test file
fs.writeFileSync(crlfFile, `const x = 1;\r\n// comment\r\n`); // write file with CRLF endings
});
afterAll(() => {
fs.rmSync(tmpDir, { recursive: true, force: true }); // remove temp dir
});
describe('hasUncommentedCode CRLF handling', () => {
test('detects uncommented code in CRLF file without errors', async () => {
const result = await utils.hasUncommentedCode(crlfFile); // check file
expect(result).toBe(true); // should detect uncommented code
});
});