Skip to content

Commit 2f9d33c

Browse files
committed
config files
1 parent a0a63b6 commit 2f9d33c

7 files changed

Lines changed: 1008 additions & 2 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '18'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Run linter
27+
run: npm run lint
28+
29+
format:
30+
name: Format Check
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: '18'
40+
cache: 'npm'
41+
42+
- name: Install dependencies
43+
run: npm ci
44+
45+
- name: Check formatting
46+
run: npm run format:check
47+
48+
build:
49+
name: Build
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Setup Node.js
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: '18'
59+
cache: 'npm'
60+
61+
- name: Install dependencies
62+
run: npm ci
63+
64+
- name: Build
65+
run: npm run build

.oxfmtrc.jsonc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"experimentalSortImports": {
4+
"newlinesBetween": false
5+
},
6+
"experimentalSortPackageJson": {
7+
"sortScripts": true
8+
},
9+
"ignorePatterns": [
10+
"dist/",
11+
"node_modules/",
12+
"package-lock.json"
13+
]
14+
}

.oxlintrc.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["unicorn", "typescript", "oxc"],
4+
"categories": {
5+
"correctness": "error",
6+
"perf": "error",
7+
"suspicious": "error"
8+
},
9+
"rules": {
10+
"curly": "error",
11+
"eslint/no-await-in-loop": "off",
12+
"eslint/no-shadow": "off",
13+
"typescript/no-explicit-any": "error",
14+
"typescript/no-extraneous-class": "off",
15+
"unicorn/consistent-function-scoping": "off"
16+
},
17+
"ignorePatterns": [
18+
"dist/",
19+
"node_modules/",
20+
"package-lock.json"
21+
]
22+
}

docs/configuration-files.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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

Comments
 (0)