UNPKG

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.

36 lines (30 loc) 1.66 kB
require('qtests/setup'); // setup qtests before imports const { test, expect, describe, beforeAll, afterAll } = require('@jest/globals'); // jest globals const fs = require('fs'); // file system operations const path = require('path'); // path utilities const os = require('os'); // OS utilities for tmp dir const utils = require('../utils'); // utilities under test const localVars = require('../../config/localVars'); // central constants let tmpDir; // temporary directory path let clientFile; // file path containing use client directive let clientFileNoSemi; // file with directive missing semicolon beforeAll(() => { tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'unqommented-')); // create temp directory clientFile = path.join(tmpDir, 'client.js'); // temp file path fs.writeFileSync(clientFile, localVars.STRICT_MODES[2]); // write 'use client'; clientFileNoSemi = path.join(tmpDir, 'clientNoSemi.js'); // path for no semicolon fs.writeFileSync(clientFileNoSemi, localVars.STRICT_MODES[6]); // write without semicolon }); afterAll(() => { fs.rmSync(tmpDir, { recursive: true, force: true }); // cleanup temp directory }); describe('hasUncommentedCode client mode directive', () => { test('returns false for file containing only use client', async () => { const result = await utils.hasUncommentedCode(clientFile); // run check expect(result).toBe(false); // should be false since only directive }); test('returns false for use client without semicolon', async () => { const result = await utils.hasUncommentedCode(clientFileNoSemi); // run check expect(result).toBe(false); // should still be false }); });