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.

116 lines (104 loc) 4.03 kB
// ATTENTION LLM AGENTS: This file contains all hardcoded values used in the application. New values may be added, but existing values must not be modified, deleted, or moved. Values are grouped by category when first introduced. Group them under an existing category if one exists, or start a new section (with a comment header) if it’s a new category. Do not move or re-categorize existing values. Ensure that no duplicates or slight variations of existing values are added. Define all environment variables here (example: export const envar = process.env.ENV_VAR) and export them for use from here on the line they are defined on. LLM often slightly mutate the naming of enironment variables throughout the codebase to match examples they are trained on; this avoids that and creates a single source of truth. No where else in the codebase should cite and use environment variables directly but should import them from here. Do not move or re-categorize existing values. Ensure that no duplicates or slight variations of existing values are added. If a variable/value is a duplicate or unused you may not delete it but may flag it with a comment "REMOVE?". Remember in all this, never edit a constant once it resides in localVars.js; never create a section whose header already exists. // Ignored directory names const IGNORED_DIRECTORIES = [ 'node_modules', '.git', '.next', 'dist', 'build', '.cache', 'coverage', '.nyc_output', '__tests__', 'tests', 'test' ]; // Ignored file name patterns const IGNORED_FILENAME_PATTERNS = [ '.test.', '.spec.', 'test.', 'spec.', 'jest.', '.config.', '.d.ts', 'setupTests.js', 'setupTests.ts' ]; // Supported file extensions regex const SUPPORTED_FILE_EXT_REGEX = 'js,ts,jsx,tsx,java,cpp,c,cs,py'; // Character constants const COMMONLY_IGNORED_PATTERNS = { STAR: '*', DOUBLE_SLASH: '//', COMMA: ',', EMPTY_STRING: '', }; // REMOVE? // Regex patterns const REGEX_PATTERNS = { LINE_SPLIT: /\r?\n/, CLOSING_BRACKETS: /^[}\)\];,]*$/, SHEBANG: /^#!(\/usr\/bin\/env node|\/bin\/sh)/, // REMOVE? ALL_COMMENTS: /((\/\*+[\s\S]*?\*\/)|(\/\/.*)|(#.*))/g, ALL_COMMENTS_NO_HASH: /((\/\*+[\s\S]*?\*\/)|(\/\/.*))/g, PATH_BACKSLASH: /\\/g, PATH_ALL_SLASHES: /[\\/]/g, }; // Concurrency limit const CONCURRENCY_LIMIT = 10; // Pre-compiled regex for ignored filenames const IGNORED_FILENAMES_REGEX = new RegExp( IGNORED_FILENAME_PATTERNS.map(pattern => pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') ).join('|') ); // Strict mode directives const STRICT_MODES = [ "'use strict';", '"use strict";', "'use client';", '"use client";', "'use strict'", '"use strict"', "'use client'", '"use client"' ]; // File encoding const FILE_ENCODING = 'utf8'; // CLI Messages const CLI_MESSAGES = { NO_UNCOMMENTED_FILES: 'No files found with uncommented code.', NO_UNCOMMENTED: 'No uncommented code found in the specified files.', ERROR_PREFIX: 'Error:', }; // Error Messages const ERROR_MESSAGES = { INPUT_NOT_STRING: 'Input must be a string', INPUT_EMPTY: 'Input string cannot be empty', EMAIL_NOT_STRING: 'Email must be a string', LENGTH_NOT_POSITIVE: 'Length must be a positive number', LIMIT_NOT_POSITIVE_INT: 'Concurrency limit must be a positive integer', BASEDIR_NOT_STRING: 'Base directory must be a string', DIR_NOT_EXIST_PREFIX: 'Directory does not exist: ', PATH_NOT_DIR_PREFIX: 'Path is not a directory: ', DIR_NOT_EXIST_PREFIX: 'Directory does not exist: ', // REMOVE? OUTPUT_STREAM_INVALID: 'Output stream must implement a write() method', }; // Warning Messages const WARNING_MESSAGES = { CANNOT_READ_FILE_PREFIX: 'Warning: Could not read file ', CANNOT_READ_DIR_PREFIX: 'Warning: Could not read directory ', }; // REMOVE? module.exports = { IGNORED_DIRECTORIES, IGNORED_FILENAME_PATTERNS, REGEX_PATTERNS, CONCURRENCY_LIMIT, IGNORED_FILENAMES_REGEX, STRICT_MODES, FILE_ENCODING, SUPPORTED_FILE_EXT_REGEX, CLI_MESSAGES, ERROR_MESSAGES, WARNING_MESSAGES, };