Skip to content

Commit d8529e0

Browse files
Nolin NaidooNolin Naidoo
authored andcommitted
fix: resolve lint errors - update biome ignore patterns and fix template string warning
1 parent 07aad8b commit d8529e0

File tree

4 files changed

+240
-2
lines changed

4 files changed

+240
-2
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ Numbers-LE is built for speed and handles files from 100KB to 30MB+. See [detail
143143
**Performance Monitoring**: Built-in real-time tracking with configurable thresholds
144144
**Full Metrics**: [docs/PERFORMANCE.md](docs/PERFORMANCE.md) • Test Environment: macOS, Bun 1.2.22, Node 22.x
145145

146+
For detailed information, see [Performance Monitoring](docs/PERFORMANCE.md).
147+
146148
<!-- PERFORMANCE_END -->
147149

148150
## 🧩 System Requirements
@@ -186,14 +188,20 @@ Enable `numbers-le.csv.streamingEnabled: true` to process large CSVs in chunks
186188
## 📊 Testing
187189

188190
**171 unit tests****95% function coverage, 80% line coverage**
189-
Powered by Vitest • Run with `bun test --coverage`
191+
Powered by Vitest • Run with `bun run test:coverage`
192+
193+
### Core Principle
194+
195+
**No broken or failed tests are allowed in commits.** All tests must pass before code can be committed or merged.
190196

191197
### Test Suite Highlights
192198

193199
- **42 security tests** for CSV/ENV/INI injection prevention
194200
- **Comprehensive coverage** of JSON, YAML, CSV, TOML, INI, ENV formats
195201
- **Statistical analysis** validation and edge case handling
196202

203+
For detailed testing guidelines, see [Testing Guidelines](docs/TESTING.md).
204+
197205
---
198206

199207
Copyright © 2025

biome.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"includes": ["src/**/*.ts", "!src/**/__performance__/**", "!src/**/__data__/**", "!src/**/__mocks__/**", "!src/**/sample/**", "!src/**/test-fixtures/**", "!src/**/*.bench.ts", "!src/**/*.bench.js", "!src/**/scripts/**"]
10+
"includes": [
11+
"src/**/*.ts",
12+
"!src/**/__performance__",
13+
"!src/**/__data__",
14+
"!src/**/__mocks__",
15+
"!src/**/sample",
16+
"!src/**/test-fixtures",
17+
"!src/**/*.bench.ts",
18+
"!src/**/*.bench.js",
19+
"!src/**/scripts"
20+
]
1121
},
1222
"formatter": {
1323
"enabled": true,

docs/TESTING.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# Numbers-LE Testing Guidelines
2+
3+
This document outlines testing practices and policies for Numbers-LE development.
4+
5+
## Core Principle
6+
7+
**No broken or failed tests are allowed in commits.**
8+
9+
All tests must pass before code can be committed or merged. This ensures code quality and prevents regressions.
10+
11+
## Running Tests
12+
13+
### Run All Tests
14+
15+
```bash
16+
bun run test
17+
```
18+
19+
### Run Tests with Coverage
20+
21+
```bash
22+
bun run test:coverage
23+
```
24+
25+
### Run Tests in Watch Mode
26+
27+
```bash
28+
bun run test:watch
29+
```
30+
31+
### Run Tests for Specific File
32+
33+
```bash
34+
bun x vitest run src/extraction/formats/csv.test.ts
35+
```
36+
37+
## Test Structure
38+
39+
### Unit Tests
40+
41+
Located in `src/**/*.test.ts` and `src/**/*.spec.ts`:
42+
43+
- **Pure function tests** - Test extraction logic in isolation
44+
- **Format tests** - Test JSON, YAML, CSV, TOML, INI, ENV extraction
45+
- **Utility tests** - Test helper functions, statistics
46+
- **Configuration tests** - Test config validation
47+
48+
### Integration Tests
49+
50+
Located in `src/**/*.spec.ts`:
51+
52+
- **Sample file tests** - Test extraction against real file formats
53+
- **Cross-platform tests** - Ensure case-sensitivity compatibility
54+
- **End-to-end workflows** - Test complete command flows
55+
56+
## Test Coverage Requirements
57+
58+
- **Minimum Coverage**: Maintain reasonable coverage across core functionality
59+
- **Critical Paths**: All extraction logic must be tested
60+
- **Error Handling**: All error paths must be covered
61+
- **Edge Cases**: Boundary conditions must be tested
62+
- **Security Tests**: CSV injection, ENV/INI injection prevention
63+
64+
## Before Committing
65+
66+
### Checklist
67+
68+
- [ ] All tests pass (`bun run test`)
69+
- [ ] No broken tests
70+
- [ ] No skipped tests (unless intentionally)
71+
- [ ] Type checking passes (`bun x tsc -p ./`)
72+
- [ ] Linting passes (`bun run lint`)
73+
74+
### CI/CD Validation
75+
76+
The CI pipeline automatically:
77+
78+
1. Runs all tests on Ubuntu, macOS, and Windows
79+
2. Generates coverage reports
80+
3. Verifies all tests pass
81+
4. Fails the build if any tests fail
82+
83+
## Fixing Failed Tests
84+
85+
### When a Test Fails
86+
87+
1. **Don't commit the failure** - Fix the test or the code
88+
2. **Run locally first** - Verify fix works before pushing
89+
3. **Check all platforms** - Ensure fix works on Linux/Windows (case sensitivity, etc.)
90+
4. **Update test if needed** - If behavior changed intentionally, update test
91+
92+
### Common Issues
93+
94+
- **Case sensitivity** - Use exact case for file references (`README.md` not `readme.md`)
95+
- **Mock issues** - Ensure mocks are properly reset in `beforeEach`
96+
- **Timing issues** - Avoid `async/await` in tests when possible, use static imports
97+
98+
## Test Best Practices
99+
100+
### 1. Use Descriptive Test Names
101+
102+
```typescript
103+
// ✅ Good
104+
it('should extract numbers from JSON files', () => {
105+
// ...
106+
});
107+
108+
// ❌ Bad
109+
it('works', () => {
110+
// ...
111+
});
112+
```
113+
114+
### 2. Test One Thing Per Test
115+
116+
```typescript
117+
// ✅ Good - separate tests
118+
it('should extract integers', () => { /* ... */ });
119+
it('should extract floats', () => { /* ... */ });
120+
121+
// ❌ Bad - multiple concerns
122+
it('should extract integers and floats', () => { /* ... */ });
123+
```
124+
125+
### 3. Use Arrange-Act-Assert Pattern
126+
127+
```typescript
128+
it('should calculate statistics', () => {
129+
// Arrange
130+
const numbers = [1, 2, 3, 4, 5];
131+
132+
// Act
133+
const stats = calculateStatistics(numbers);
134+
135+
// Assert
136+
expect(stats.average).toBe(3);
137+
expect(stats.median).toBe(3);
138+
});
139+
```
140+
141+
### 4. Clean Up Mocks
142+
143+
```typescript
144+
beforeEach(() => {
145+
vi.clearAllMocks();
146+
// Reset mocks to default state
147+
});
148+
```
149+
150+
## Cross-Platform Testing
151+
152+
### Case Sensitivity
153+
154+
Always use exact case for file references:
155+
156+
```typescript
157+
// ✅ Good - works on all platforms
158+
const content = readSampleFile('README.md');
159+
160+
// ❌ Bad - fails on Linux
161+
const content = readSampleFile('readme.md');
162+
```
163+
164+
### Path Separators
165+
166+
Use platform-agnostic path handling:
167+
168+
```typescript
169+
import { join } from 'path';
170+
const filePath = join(SAMPLE_DIR, filename);
171+
```
172+
173+
## Coverage Reports
174+
175+
Coverage reports are generated automatically:
176+
177+
- **Location**: `coverage/index.html`
178+
- **Format**: HTML, LCOV, JSON
179+
- **CI/CD**: Coverage uploaded as artifact
180+
181+
## Continuous Integration
182+
183+
### GitHub Actions
184+
185+
Tests run automatically on:
186+
187+
- **Ubuntu** (latest)
188+
- **macOS** (latest)
189+
- **Windows** (latest)
190+
191+
All platforms must pass for the build to succeed.
192+
193+
### Pre-commit Hooks
194+
195+
Consider setting up pre-commit hooks to run tests before commits:
196+
197+
```bash
198+
# Install husky (if needed)
199+
bun add -d husky
200+
201+
# Add pre-commit hook
202+
echo "bun run test" > .husky/pre-commit
203+
```
204+
205+
## Reporting Test Issues
206+
207+
If you encounter test failures:
208+
209+
1. **Run locally** - Verify it fails consistently
210+
2. **Check CI logs** - See platform-specific errors
211+
3. **Reproduce** - Document steps to reproduce
212+
4. **Fix or report** - Either fix or create an issue
213+
214+
## Related Documentation
215+
216+
- [Performance Monitoring](PERFORMANCE.md) - Performance testing and benchmarks
217+
- [Architecture](ARCHITECTURE.md) - Code structure
218+
- [Commands](COMMANDS.md) - Command testing guidelines
219+

src/extraction/formats/formats.security.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ describe('CSV/ENV/INI Security & Edge Cases', () => {
127127
});
128128

129129
test('should handle ENV with variable expansion', () => {
130+
// biome-ignore lint/suspicious/noTemplateCurlyInString: testing literal env var syntax
130131
const env = 'HOME=${HOME}\nUSER=${USER}\nPORT=8080';
131132
const result = extractFromEnv(env, 'test.env');
132133

0 commit comments

Comments
 (0)