UNPKG

loqatevars

Version:

Locate JavaScript files with 'const' or 'process.env' usage in LLM-generated codebases

91 lines (83 loc) 3.42 kB
/** * @file This file serves as a centralized configuration hub for the application. * It contains all hardcoded values, environment variables, and constants, providing a single * source of truth for configuration. This approach simplifies maintenance and reduces the * risk of inconsistencies. * * The file is organized into categories to improve readability and maintainability. * When adding new values, please adhere to the existing structure and guidelines. * * Rationale for Centralized Configuration: * - **Single Source of Truth**: Avoids scattering configuration values across the codebase, * making it easier to manage and update them. * - **Consistency**: Ensures that all parts of the application use the same configuration values. * - **Security**: Keeps sensitive information, such as API keys, in one place, making it * easier to secure and audit. * - **Maintainability**: Simplifies the process of changing configuration values, as they * only need to be updated in one location. */ /** * The `dotenv` library is used to load environment variables from a `.env` file * into `process.env`. This is a common practice for managing environment-specific * configurations in a development environment. */ require('dotenv').config(); /** * @section Directory Scanning Constants * * This section defines constants related to directory scanning and file searching. * These values are used to configure the behavior of the `loqatevars` tool when * it scans the codebase. */ /** * `ignoreDirs` is an array of directory names that should be ignored during the scan. * This list includes common directories that are not relevant for code analysis, * such as `node_modules`, build artifacts, and asset directories. * * Rationale: * - Excluding these directories significantly improves the performance of the scan * by reducing the number of files that need to be processed. * - It also prevents the tool from flagging irrelevant files, which would create * unnecessary noise in the results. */ const ignoreDirs = [ 'node_modules', '.git', '.replit', 'attached_assets', 'public', 'static', 'assets', 'dist', 'build', 'out', 'client', 'frontend', 'web', 'www', 'app/assets', 'src/assets', 'src/public', 'resources/views', 'templates', 'views', 'pages', 'components', 'styles', 'css', 'scss', 'images', 'img', 'fonts', 'media' ]; /** * @section Test Variables * * This section contains variables that are used for testing purposes. * These variables are not used in the production application but are essential * for verifying the correctness of the `loqatevars` tool. */ const badVariable = "bad variable"; const topLevelVar = "should be flagged"; const anotherTopLevel = "should be flagged"; const finalTopLevel = "should be flagged"; // App constants const timeout = 5000; const maxRetries = 3; const defaultConfig = { theme: 'dark' }; module.exports = { ignoreDirs, API_KEY: process.env.API_KEY || '', DEBUG_MODE: process.env.DEBUG_MODE === 'true', MOCK_ENV: process.env.MOCK_ENV, BAD_ENV: process.env.BAD_ENV, NODE_ENV: process.env.NODE_ENV, DB_CONNECTION: process.env.DB_CONNECTION || 'localhost', PORT: String(process.env.PORT || 3000), // always return port as string DATABASE_URL: process.env.DATABASE_URL, badVariable, topLevelVar, anotherTopLevel, finalTopLevel, timeout, maxRetries, defaultConfig };