|
| 1 | +# Configuration Files Documentation |
| 2 | + |
| 3 | +This document explains all configuration files added to the txtcode project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Security](#security) |
| 8 | +- [Code Quality](#code-quality) |
| 9 | +- [Git Configuration](#git-configuration) |
| 10 | +- [CI/CD](#cicd) |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Security |
| 15 | + |
| 16 | +### `.detect-secrets.cfg` |
| 17 | + |
| 18 | +**Purpose:** Configuration for detect-secrets tool that scans for accidentally committed secrets (API keys, passwords, tokens). |
| 19 | + |
| 20 | +**What it does:** |
| 21 | +- Defines file patterns to exclude from scanning (node_modules, dist, package-lock.json) |
| 22 | +- Defines line patterns to ignore (false positives like "apiKey" field names) |
| 23 | + |
| 24 | +**Usage:** |
| 25 | +```bash |
| 26 | +# Scan for secrets |
| 27 | +python -m detect_secrets scan --baseline .secrets.baseline |
| 28 | + |
| 29 | +# Review findings interactively |
| 30 | +python -m detect_secrets audit .secrets.baseline |
| 31 | +``` |
| 32 | + |
| 33 | +**Why we need it:** Prevents accidentally committing real API keys or credentials to the repository. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +### `.secrets.baseline` |
| 38 | + |
| 39 | +**Purpose:** Baseline file that stores known false positives from secret scanning. |
| 40 | + |
| 41 | +**What it contains:** |
| 42 | +- List of detected "secrets" that have been reviewed and marked as safe |
| 43 | +- Currently contains 4 false positives from `models-catalog.json` (field names like "apiKeyEnv") |
| 44 | + |
| 45 | +**Why we need it:** Prevents the same false positives from triggering alerts on every scan. |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Code Quality |
| 50 | + |
| 51 | +### `.oxfmtrc.jsonc` |
| 52 | + |
| 53 | +**Purpose:** Configuration for oxfmt - a fast code formatter (like Prettier but written in Rust). |
| 54 | + |
| 55 | +**Settings:** |
| 56 | +- `experimentalSortImports`: Automatically sorts import statements alphabetically |
| 57 | +- `experimentalSortPackageJson`: Sorts scripts in package.json |
| 58 | +- `ignorePatterns`: Skips dist/, node_modules/, package-lock.json |
| 59 | + |
| 60 | +**Usage:** |
| 61 | +```bash |
| 62 | +# Format all files |
| 63 | +npm run format |
| 64 | + |
| 65 | +# Check if files are formatted (CI) |
| 66 | +npm run format:check |
| 67 | +``` |
| 68 | + |
| 69 | +**Why we need it:** Ensures consistent code formatting across all contributors without manual effort. |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +### `.oxlintrc.json` |
| 74 | + |
| 75 | +**Purpose:** Configuration for oxlint - a fast linter (like ESLint but 50-100x faster, written in Rust). |
| 76 | + |
| 77 | +**Settings:** |
| 78 | +- Enabled plugins: unicorn (best practices), typescript, oxc |
| 79 | +- Error categories: correctness, perf, suspicious |
| 80 | +- Strict rules: no `any` types, requires curly braces |
| 81 | +- Flexible rules: allows await in loops, variable shadowing |
| 82 | + |
| 83 | +**Usage:** |
| 84 | +```bash |
| 85 | +# Check for issues |
| 86 | +npm run lint |
| 87 | + |
| 88 | +# Auto-fix issues |
| 89 | +npm run lint:fix |
| 90 | +``` |
| 91 | + |
| 92 | +**Why we need it:** Catches bugs, enforces code quality, and prevents performance issues automatically. |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +## Git Configuration |
| 97 | + |
| 98 | +### `.gitattributes` |
| 99 | + |
| 100 | +**Purpose:** Tells Git how to handle line endings across different operating systems. |
| 101 | + |
| 102 | +**Setting:** |
| 103 | +``` |
| 104 | +* text=auto eol=lf |
| 105 | +``` |
| 106 | + |
| 107 | +**What it does:** |
| 108 | +- Forces all text files to use LF (Unix-style) line endings in the repository |
| 109 | +- On checkout: Converts to your OS's line endings (CRLF on Windows, LF on Mac/Linux) |
| 110 | +- On commit: Converts everything to LF before storing |
| 111 | + |
| 112 | +**Why we need it:** Prevents mixed line endings that cause messy diffs and script failures. Essential for cross-platform development. |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## CI/CD |
| 117 | + |
| 118 | +### `.github/workflows/security.yml` |
| 119 | + |
| 120 | +**Purpose:** GitHub Actions workflow that runs security scanning on every push/PR. |
| 121 | + |
| 122 | +**What it does:** |
| 123 | +- Installs Python and detect-secrets |
| 124 | +- Scans codebase for secrets |
| 125 | +- Fails the build if new secrets are detected |
| 126 | + |
| 127 | +**When it runs:** On push to main/master or on pull requests |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +### `.github/workflows/ci.yml` |
| 132 | + |
| 133 | +**Purpose:** GitHub Actions workflow for continuous integration checks. |
| 134 | + |
| 135 | +**Jobs:** |
| 136 | +1. **Lint** - Runs oxlint to check code quality |
| 137 | +2. **Format** - Checks if code is properly formatted with oxfmt |
| 138 | +3. **Build** - Compiles TypeScript to ensure no build errors |
| 139 | + |
| 140 | +**When it runs:** On push to main/master or on pull requests |
| 141 | + |
| 142 | +**Why we need it:** Ensures all code meets quality standards before merging. |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +## Summary |
| 147 | + |
| 148 | +All these files work together to: |
| 149 | +- **Prevent security issues** (detect-secrets) |
| 150 | +- **Maintain code quality** (oxlint) |
| 151 | +- **Ensure consistent formatting** (oxfmt) |
| 152 | +- **Support cross-platform development** (.gitattributes) |
| 153 | +- **Automate checks in CI/CD** (GitHub Actions) |
| 154 | + |
| 155 | +This setup ensures txtcode maintains high code quality and security standards with minimal manual effort. |
0 commit comments