thailint 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- src/.ai/layout.yaml +48 -0
- src/__init__.py +49 -0
- src/api.py +118 -0
- src/cli.py +698 -0
- src/config.py +386 -0
- src/core/__init__.py +17 -0
- src/core/base.py +122 -0
- src/core/registry.py +170 -0
- src/core/types.py +83 -0
- src/linter_config/__init__.py +13 -0
- src/linter_config/ignore.py +403 -0
- src/linter_config/loader.py +77 -0
- src/linters/__init__.py +4 -0
- src/linters/file_placement/__init__.py +31 -0
- src/linters/file_placement/linter.py +621 -0
- src/linters/nesting/__init__.py +87 -0
- src/linters/nesting/config.py +50 -0
- src/linters/nesting/linter.py +257 -0
- src/linters/nesting/python_analyzer.py +89 -0
- src/linters/nesting/typescript_analyzer.py +180 -0
- src/orchestrator/__init__.py +9 -0
- src/orchestrator/core.py +188 -0
- src/orchestrator/language_detector.py +81 -0
- thailint-0.1.0.dist-info/LICENSE +21 -0
- thailint-0.1.0.dist-info/METADATA +601 -0
- thailint-0.1.0.dist-info/RECORD +28 -0
- thailint-0.1.0.dist-info/WHEEL +4 -0
- thailint-0.1.0.dist-info/entry_points.txt +4 -0
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: thailint
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: The AI Linter - Enterprise-grade linting and governance for AI-generated code across multiple languages
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: linter,ai,code-quality,static-analysis,file-placement,governance,multi-language,cli,docker,python
|
|
7
|
+
Author: Steve Jackson
|
|
8
|
+
Requires-Python: >=3.11,<4.0
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
21
|
+
Classifier: Topic :: Software Development :: Testing
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Dist: click (>=8.1.0,<9.0.0)
|
|
25
|
+
Requires-Dist: pyyaml (>=6.0,<7.0)
|
|
26
|
+
Requires-Dist: tree-sitter (>=0.25.2,<0.26.0)
|
|
27
|
+
Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
|
|
28
|
+
Project-URL: Documentation, https://github.com/be-wise-be-kind/thai-lint#readme
|
|
29
|
+
Project-URL: Homepage, https://github.com/be-wise-be-kind/thai-lint
|
|
30
|
+
Project-URL: Repository, https://github.com/be-wise-be-kind/thai-lint
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# thai-lint
|
|
34
|
+
|
|
35
|
+
[](https://opensource.org/licenses/MIT)
|
|
36
|
+
[](https://www.python.org/downloads/)
|
|
37
|
+
[](tests/)
|
|
38
|
+
[](htmlcov/)
|
|
39
|
+
|
|
40
|
+
The AI Linter - Enterprise-ready linting and governance for AI-generated code across multiple languages.
|
|
41
|
+
|
|
42
|
+
## Overview
|
|
43
|
+
|
|
44
|
+
thailint is a modern, enterprise-ready multi-language linter designed specifically for AI-generated code. It enforces project structure, file placement rules, and coding standards across Python, TypeScript, and other languages.
|
|
45
|
+
|
|
46
|
+
## โจ Features
|
|
47
|
+
|
|
48
|
+
### Core Capabilities
|
|
49
|
+
- ๐ฏ **File Placement Linting** - Enforce project structure and organization
|
|
50
|
+
- ๐ **Nesting Depth Linting** - Detect excessive code nesting with AST analysis
|
|
51
|
+
- Python and TypeScript support with tree-sitter
|
|
52
|
+
- Configurable max depth (default: 4, recommended: 3)
|
|
53
|
+
- Helpful refactoring suggestions (guard clauses, extract method)
|
|
54
|
+
- ๐ **Pluggable Architecture** - Easy to extend with custom linters
|
|
55
|
+
- ๐ **Multi-Language Support** - Python, TypeScript, JavaScript, and more
|
|
56
|
+
- โ๏ธ **Flexible Configuration** - YAML/JSON configs with pattern matching
|
|
57
|
+
- ๐ซ **5-Level Ignore System** - Repo, directory, file, method, and line-level ignores
|
|
58
|
+
|
|
59
|
+
### Deployment Modes
|
|
60
|
+
- ๐ป **CLI Mode** - Full-featured command-line interface
|
|
61
|
+
- ๐ **Library API** - Python library for programmatic integration
|
|
62
|
+
- ๐ณ **Docker Support** - Containerized deployment for CI/CD
|
|
63
|
+
|
|
64
|
+
### Enterprise Features
|
|
65
|
+
- ๐ **Performance** - <100ms for single files, <5s for 1000 files
|
|
66
|
+
- ๐ **Type Safety** - Full type hints and MyPy strict mode
|
|
67
|
+
- ๐งช **Test Coverage** - 90% coverage with 317 tests
|
|
68
|
+
- ๐ **CI/CD Ready** - Proper exit codes and JSON output
|
|
69
|
+
- ๐ **Comprehensive Docs** - Complete documentation and examples
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
### From Source
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Clone repository
|
|
77
|
+
git clone https://github.com/be-wise-be-kind/thai-lint.git
|
|
78
|
+
cd thai-lint
|
|
79
|
+
|
|
80
|
+
# Install dependencies
|
|
81
|
+
pip install -e ".[dev]"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### From PyPI (once published)
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install thai-lint
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### With Docker
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Build image
|
|
94
|
+
docker-compose -f docker-compose.cli.yml build
|
|
95
|
+
|
|
96
|
+
# Run CLI
|
|
97
|
+
docker-compose -f docker-compose.cli.yml run cli --help
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Quick Start
|
|
101
|
+
|
|
102
|
+
### CLI Mode
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Check file placement
|
|
106
|
+
thai-lint file-placement .
|
|
107
|
+
|
|
108
|
+
# Check nesting depth
|
|
109
|
+
thai-lint nesting src/
|
|
110
|
+
|
|
111
|
+
# With config file
|
|
112
|
+
thai-lint nesting --config .thailint.yaml src/
|
|
113
|
+
|
|
114
|
+
# JSON output for CI/CD
|
|
115
|
+
thai-lint nesting --format json src/
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Library Mode
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from src import Linter
|
|
122
|
+
|
|
123
|
+
# Initialize linter
|
|
124
|
+
linter = Linter(config_file='.thailint.yaml')
|
|
125
|
+
|
|
126
|
+
# Lint directory
|
|
127
|
+
violations = linter.lint('src/', rules=['file-placement'])
|
|
128
|
+
|
|
129
|
+
# Process results
|
|
130
|
+
if violations:
|
|
131
|
+
for v in violations:
|
|
132
|
+
print(f"{v.file_path}: {v.message}")
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Docker Mode
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Run with volume mount
|
|
139
|
+
docker run --rm -v $(pwd):/workspace \
|
|
140
|
+
thailint/thailint file-placement /workspace
|
|
141
|
+
|
|
142
|
+
# With docker-compose
|
|
143
|
+
docker-compose run cli file-placement .
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Configuration
|
|
147
|
+
|
|
148
|
+
Create `.thailint.yaml` in your project root:
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
# File placement linter configuration
|
|
152
|
+
file-placement:
|
|
153
|
+
# Global patterns apply to entire project
|
|
154
|
+
global_patterns:
|
|
155
|
+
deny:
|
|
156
|
+
- pattern: "^(?!src/|tests/).*\\.py$"
|
|
157
|
+
message: "Python files must be in src/ or tests/"
|
|
158
|
+
|
|
159
|
+
# Directory-specific rules
|
|
160
|
+
directories:
|
|
161
|
+
src:
|
|
162
|
+
allow:
|
|
163
|
+
- ".*\\.py$"
|
|
164
|
+
deny:
|
|
165
|
+
- "test_.*\\.py$"
|
|
166
|
+
|
|
167
|
+
tests:
|
|
168
|
+
allow:
|
|
169
|
+
- "test_.*\\.py$"
|
|
170
|
+
- "conftest\\.py$"
|
|
171
|
+
|
|
172
|
+
# Files/directories to ignore
|
|
173
|
+
ignore:
|
|
174
|
+
- "__pycache__/"
|
|
175
|
+
- "*.pyc"
|
|
176
|
+
- ".venv/"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**JSON format also supported** (`.thailint.json`):
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"file-placement": {
|
|
184
|
+
"directories": {
|
|
185
|
+
"src": {
|
|
186
|
+
"allow": [".*\\.py$"],
|
|
187
|
+
"deny": ["test_.*\\.py$"]
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"ignore": ["__pycache__/", "*.pyc"]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
See [Configuration Guide](docs/configuration.md) for complete reference.
|
|
196
|
+
|
|
197
|
+
## Nesting Depth Linter
|
|
198
|
+
|
|
199
|
+
### Overview
|
|
200
|
+
|
|
201
|
+
The nesting depth linter detects deeply nested code (if/for/while/try statements) that reduces readability and maintainability. It uses AST analysis to accurately calculate nesting depth.
|
|
202
|
+
|
|
203
|
+
### Quick Start
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Check nesting depth in current directory
|
|
207
|
+
thai-lint nesting .
|
|
208
|
+
|
|
209
|
+
# Use strict limit (max depth 3)
|
|
210
|
+
thai-lint nesting --max-depth 3 src/
|
|
211
|
+
|
|
212
|
+
# Get JSON output
|
|
213
|
+
thai-lint nesting --format json src/
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Configuration
|
|
217
|
+
|
|
218
|
+
Add to `.thailint.yaml`:
|
|
219
|
+
|
|
220
|
+
```yaml
|
|
221
|
+
nesting:
|
|
222
|
+
enabled: true
|
|
223
|
+
max_nesting_depth: 3 # Default: 4, recommended: 3
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Example Violation
|
|
227
|
+
|
|
228
|
+
**Code with excessive nesting:**
|
|
229
|
+
```python
|
|
230
|
+
def process_data(items):
|
|
231
|
+
for item in items: # Depth 2
|
|
232
|
+
if item.is_valid(): # Depth 3
|
|
233
|
+
try: # Depth 4 โ VIOLATION (max=3)
|
|
234
|
+
if item.process():
|
|
235
|
+
return True
|
|
236
|
+
except Exception:
|
|
237
|
+
pass
|
|
238
|
+
return False
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Refactored with guard clauses:**
|
|
242
|
+
```python
|
|
243
|
+
def process_data(items):
|
|
244
|
+
for item in items: # Depth 2
|
|
245
|
+
if not item.is_valid():
|
|
246
|
+
continue
|
|
247
|
+
try: # Depth 3 โ
|
|
248
|
+
if item.process():
|
|
249
|
+
return True
|
|
250
|
+
except Exception:
|
|
251
|
+
pass
|
|
252
|
+
return False
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Refactoring Patterns
|
|
256
|
+
|
|
257
|
+
Common patterns to reduce nesting (used to fix 23 violations in thai-lint):
|
|
258
|
+
|
|
259
|
+
1. **Guard Clauses (Early Returns)**
|
|
260
|
+
- Replace `if x: do_something()` with `if not x: return`
|
|
261
|
+
- Exit early, reduce nesting
|
|
262
|
+
|
|
263
|
+
2. **Extract Method**
|
|
264
|
+
- Move nested logic to separate functions
|
|
265
|
+
- Improves readability and testability
|
|
266
|
+
|
|
267
|
+
3. **Dispatch Pattern**
|
|
268
|
+
- Replace if-elif-else chains with dictionary dispatch
|
|
269
|
+
- More extensible and cleaner
|
|
270
|
+
|
|
271
|
+
4. **Flatten Error Handling**
|
|
272
|
+
- Combine multiple try-except blocks
|
|
273
|
+
- Use tuple of exception types
|
|
274
|
+
|
|
275
|
+
### Language Support
|
|
276
|
+
|
|
277
|
+
- โ
**Python**: Full support (if/for/while/with/try/match)
|
|
278
|
+
- โ
**TypeScript**: Full support (if/for/while/try/switch)
|
|
279
|
+
- โ
**JavaScript**: Supported via TypeScript parser
|
|
280
|
+
|
|
281
|
+
### Refactoring Case Study
|
|
282
|
+
|
|
283
|
+
The thai-lint codebase serves as a validation of the nesting linter:
|
|
284
|
+
- Identified: 23 functions requiring refactoring (depth 4 โ depth โค3)
|
|
285
|
+
- Refactored using documented patterns
|
|
286
|
+
- Time estimate: ~10 minutes per function
|
|
287
|
+
- Result: Zero violations, improved readability
|
|
288
|
+
|
|
289
|
+
See [Nesting Linter Guide](docs/nesting-linter.md) for comprehensive documentation and refactoring patterns.
|
|
290
|
+
|
|
291
|
+
## Pre-commit Hooks
|
|
292
|
+
|
|
293
|
+
Automate code quality checks before every commit and push with pre-commit hooks.
|
|
294
|
+
|
|
295
|
+
### Quick Setup
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# 1. Install pre-commit framework
|
|
299
|
+
pip install pre-commit
|
|
300
|
+
|
|
301
|
+
# 2. Install git hooks
|
|
302
|
+
pre-commit install
|
|
303
|
+
pre-commit install --hook-type pre-push
|
|
304
|
+
|
|
305
|
+
# 3. Test it works
|
|
306
|
+
pre-commit run --all-files
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### What You Get
|
|
310
|
+
|
|
311
|
+
**On every commit:**
|
|
312
|
+
- ๐ซ Prevents commits to main/master branch
|
|
313
|
+
- ๐จ Auto-fixes formatting issues
|
|
314
|
+
- โ
Runs thai-lint on changed files (fast)
|
|
315
|
+
|
|
316
|
+
**On every push:**
|
|
317
|
+
- ๐ Full linting on entire codebase
|
|
318
|
+
- ๐งช Runs complete test suite
|
|
319
|
+
|
|
320
|
+
### Example Configuration
|
|
321
|
+
|
|
322
|
+
```yaml
|
|
323
|
+
# .pre-commit-config.yaml
|
|
324
|
+
repos:
|
|
325
|
+
- repo: local
|
|
326
|
+
hooks:
|
|
327
|
+
# Prevent commits to protected branches
|
|
328
|
+
- id: no-commit-to-main
|
|
329
|
+
name: Prevent commits to main branch
|
|
330
|
+
entry: bash -c 'branch=$(git rev-parse --abbrev-ref HEAD); if [ "$branch" = "main" ]; then echo "โ Use a feature branch!"; exit 1; fi'
|
|
331
|
+
language: system
|
|
332
|
+
pass_filenames: false
|
|
333
|
+
always_run: true
|
|
334
|
+
|
|
335
|
+
# Auto-format code
|
|
336
|
+
- id: format
|
|
337
|
+
name: Auto-fix formatting
|
|
338
|
+
entry: make format
|
|
339
|
+
language: system
|
|
340
|
+
pass_filenames: false
|
|
341
|
+
|
|
342
|
+
# Run thai-lint on changed files
|
|
343
|
+
- id: lint-changed
|
|
344
|
+
name: Lint changed files
|
|
345
|
+
entry: make lint-full FILES=changed
|
|
346
|
+
language: system
|
|
347
|
+
pass_filenames: false
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
See **[Pre-commit Hooks Guide](docs/pre-commit-hooks.md)** for complete documentation, troubleshooting, and advanced configuration.
|
|
351
|
+
|
|
352
|
+
## Common Use Cases
|
|
353
|
+
|
|
354
|
+
### CI/CD Integration
|
|
355
|
+
|
|
356
|
+
```yaml
|
|
357
|
+
# GitHub Actions example
|
|
358
|
+
name: Lint
|
|
359
|
+
|
|
360
|
+
on: [push, pull_request]
|
|
361
|
+
|
|
362
|
+
jobs:
|
|
363
|
+
lint:
|
|
364
|
+
runs-on: ubuntu-latest
|
|
365
|
+
steps:
|
|
366
|
+
- uses: actions/checkout@v3
|
|
367
|
+
- name: Install thailint
|
|
368
|
+
run: pip install thailint
|
|
369
|
+
- name: Run file placement linter
|
|
370
|
+
run: thailint file-placement .
|
|
371
|
+
- name: Run nesting linter
|
|
372
|
+
run: thailint nesting src/ --config .thailint.yaml
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Editor Integration
|
|
376
|
+
|
|
377
|
+
```python
|
|
378
|
+
# VS Code extension example
|
|
379
|
+
from src import Linter
|
|
380
|
+
|
|
381
|
+
linter = Linter(config_file='.thailint.yaml')
|
|
382
|
+
violations = linter.lint(file_path)
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Test Suite
|
|
386
|
+
|
|
387
|
+
```python
|
|
388
|
+
# pytest integration
|
|
389
|
+
import pytest
|
|
390
|
+
from src import Linter
|
|
391
|
+
|
|
392
|
+
def test_no_violations():
|
|
393
|
+
linter = Linter()
|
|
394
|
+
violations = linter.lint('src/')
|
|
395
|
+
assert len(violations) == 0
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
## Development
|
|
399
|
+
|
|
400
|
+
### Setup Development Environment
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
# Install development dependencies
|
|
404
|
+
pip install -e ".[dev]"
|
|
405
|
+
|
|
406
|
+
# Install pre-commit hooks (if using)
|
|
407
|
+
pre-commit install
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Running Tests
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
# Run all tests
|
|
414
|
+
pytest
|
|
415
|
+
|
|
416
|
+
# Run with coverage
|
|
417
|
+
pytest --cov=src --cov-report=html
|
|
418
|
+
|
|
419
|
+
# Run specific test
|
|
420
|
+
pytest tests/test_cli.py::test_hello_command
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Code Quality
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
# Lint code
|
|
427
|
+
ruff check src tests
|
|
428
|
+
|
|
429
|
+
# Format code
|
|
430
|
+
ruff format src tests
|
|
431
|
+
|
|
432
|
+
# Type checking
|
|
433
|
+
mypy src/
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Building
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# Build Python package
|
|
440
|
+
python -m build
|
|
441
|
+
|
|
442
|
+
# Build Docker image
|
|
443
|
+
docker-compose -f docker-compose.cli.yml build
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
## Docker Usage
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
# Build image
|
|
450
|
+
docker-compose -f docker-compose.cli.yml build
|
|
451
|
+
|
|
452
|
+
# Run CLI help
|
|
453
|
+
docker-compose -f docker-compose.cli.yml run cli --help
|
|
454
|
+
|
|
455
|
+
# Run hello command
|
|
456
|
+
docker-compose -f docker-compose.cli.yml run cli hello --name Docker
|
|
457
|
+
|
|
458
|
+
# With config volume
|
|
459
|
+
docker-compose -f docker-compose.cli.yml run \
|
|
460
|
+
-v $(pwd)/config:/config:ro \
|
|
461
|
+
cli --config /config/config.yaml hello
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
## Documentation
|
|
465
|
+
|
|
466
|
+
### Comprehensive Guides
|
|
467
|
+
|
|
468
|
+
- ๐ **[Getting Started](docs/getting-started.md)** - Installation, first lint, basic config
|
|
469
|
+
- โ๏ธ **[Configuration Reference](docs/configuration.md)** - Complete config options (YAML/JSON)
|
|
470
|
+
- ๐ **[API Reference](docs/api-reference.md)** - Library API documentation
|
|
471
|
+
- ๐ป **[CLI Reference](docs/cli-reference.md)** - All CLI commands and options
|
|
472
|
+
- ๐ **[Deployment Modes](docs/deployment-modes.md)** - CLI, Library, and Docker usage
|
|
473
|
+
- ๐ **[File Placement Linter](docs/file-placement-linter.md)** - Detailed linter guide
|
|
474
|
+
- ๐ **[Nesting Depth Linter](docs/nesting-linter.md)** - Nesting depth analysis guide
|
|
475
|
+
- ๐ช **[Pre-commit Hooks](docs/pre-commit-hooks.md)** - Automated quality checks
|
|
476
|
+
- ๐ฆ **[Publishing Guide](docs/releasing.md)** - Release and publishing workflow
|
|
477
|
+
- โ
**[Publishing Checklist](docs/publishing-checklist.md)** - Post-publication validation
|
|
478
|
+
|
|
479
|
+
### Examples
|
|
480
|
+
|
|
481
|
+
See [`examples/`](examples/) directory for working code:
|
|
482
|
+
|
|
483
|
+
- **[basic_usage.py](examples/basic_usage.py)** - Simple library API usage
|
|
484
|
+
- **[advanced_usage.py](examples/advanced_usage.py)** - Advanced patterns and workflows
|
|
485
|
+
- **[ci_integration.py](examples/ci_integration.py)** - CI/CD integration example
|
|
486
|
+
|
|
487
|
+
## Project Structure
|
|
488
|
+
|
|
489
|
+
```
|
|
490
|
+
thai-lint/
|
|
491
|
+
โโโ src/ # Application source code
|
|
492
|
+
โ โโโ api.py # High-level Library API
|
|
493
|
+
โ โโโ cli.py # CLI commands
|
|
494
|
+
โ โโโ core/ # Core abstractions
|
|
495
|
+
โ โ โโโ base.py # Base linter interfaces
|
|
496
|
+
โ โ โโโ registry.py # Rule registry
|
|
497
|
+
โ โ โโโ types.py # Core types (Violation, Severity)
|
|
498
|
+
โ โโโ linters/ # Linter implementations
|
|
499
|
+
โ โ โโโ file_placement/ # File placement linter
|
|
500
|
+
โ โโโ linter_config/ # Configuration system
|
|
501
|
+
โ โ โโโ loader.py # Config loader (YAML/JSON)
|
|
502
|
+
โ โ โโโ ignore.py # Ignore directives
|
|
503
|
+
โ โโโ orchestrator/ # Multi-language orchestrator
|
|
504
|
+
โ โโโ core.py # Main orchestrator
|
|
505
|
+
โ โโโ language_detector.py
|
|
506
|
+
โโโ tests/ # Test suite (221 tests, 87% coverage)
|
|
507
|
+
โ โโโ unit/ # Unit tests
|
|
508
|
+
โ โโโ integration/ # Integration tests
|
|
509
|
+
โ โโโ conftest.py # Pytest fixtures
|
|
510
|
+
โโโ docs/ # Documentation
|
|
511
|
+
โ โโโ getting-started.md
|
|
512
|
+
โ โโโ configuration.md
|
|
513
|
+
โ โโโ api-reference.md
|
|
514
|
+
โ โโโ cli-reference.md
|
|
515
|
+
โ โโโ deployment-modes.md
|
|
516
|
+
โ โโโ file-placement-linter.md
|
|
517
|
+
โโโ examples/ # Working examples
|
|
518
|
+
โ โโโ basic_usage.py
|
|
519
|
+
โ โโโ advanced_usage.py
|
|
520
|
+
โ โโโ ci_integration.py
|
|
521
|
+
โโโ .ai/ # AI agent documentation
|
|
522
|
+
โโโ Dockerfile # Multi-stage Docker build
|
|
523
|
+
โโโ docker-compose.yml # Docker orchestration
|
|
524
|
+
โโโ pyproject.toml # Project configuration
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
## Contributing
|
|
528
|
+
|
|
529
|
+
Contributions are welcome! Please follow these steps:
|
|
530
|
+
|
|
531
|
+
1. Fork the repository
|
|
532
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
533
|
+
3. Make your changes
|
|
534
|
+
4. Run tests and linting
|
|
535
|
+
5. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
536
|
+
6. Push to the branch (`git push origin feature/amazing-feature`)
|
|
537
|
+
7. Open a Pull Request
|
|
538
|
+
|
|
539
|
+
### Development Guidelines
|
|
540
|
+
|
|
541
|
+
- Write tests for new features
|
|
542
|
+
- Follow existing code style (enforced by Ruff)
|
|
543
|
+
- Add type hints to all functions
|
|
544
|
+
- Update documentation for user-facing changes
|
|
545
|
+
- Run `pytest` and `ruff check` before committing
|
|
546
|
+
|
|
547
|
+
## Performance
|
|
548
|
+
|
|
549
|
+
thailint is designed for speed and efficiency:
|
|
550
|
+
|
|
551
|
+
| Operation | Performance | Target |
|
|
552
|
+
|-----------|-------------|--------|
|
|
553
|
+
| Single file lint | ~20ms | <100ms โ
|
|
|
554
|
+
| 100 files | ~300ms | <1s โ
|
|
|
555
|
+
| 1000 files | ~900ms | <5s โ
|
|
|
556
|
+
| Config loading | ~10ms | <100ms โ
|
|
|
557
|
+
|
|
558
|
+
*Performance benchmarks run on standard hardware, your results may vary.*
|
|
559
|
+
|
|
560
|
+
## Exit Codes
|
|
561
|
+
|
|
562
|
+
thailint uses standard exit codes for CI/CD integration:
|
|
563
|
+
|
|
564
|
+
- **0** - Success (no violations)
|
|
565
|
+
- **1** - Violations found
|
|
566
|
+
- **2** - Error occurred (invalid config, file not found, etc.)
|
|
567
|
+
|
|
568
|
+
```bash
|
|
569
|
+
thai-lint file-placement .
|
|
570
|
+
if [ $? -eq 0 ]; then
|
|
571
|
+
echo "โ
Linting passed"
|
|
572
|
+
else
|
|
573
|
+
echo "โ Linting failed"
|
|
574
|
+
fi
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
## Architecture
|
|
578
|
+
|
|
579
|
+
See [`.ai/docs/`](.ai/docs/) for detailed architecture documentation and [`.ai/howtos/`](.ai/howtos/) for development guides.
|
|
580
|
+
|
|
581
|
+
## License
|
|
582
|
+
|
|
583
|
+
MIT License - see LICENSE file for details.
|
|
584
|
+
|
|
585
|
+
## Support
|
|
586
|
+
|
|
587
|
+
- **Issues**: https://github.com/be-wise-be-kind/thai-lint/issues
|
|
588
|
+
- **Documentation**: `.ai/docs/` and `.ai/howtos/`
|
|
589
|
+
|
|
590
|
+
## Acknowledgments
|
|
591
|
+
|
|
592
|
+
Built with:
|
|
593
|
+
- [Click](https://click.palletsprojects.com/) - CLI framework
|
|
594
|
+
- [pytest](https://pytest.org/) - Testing framework
|
|
595
|
+
- [Ruff](https://docs.astral.sh/ruff/) - Linting and formatting
|
|
596
|
+
- [Docker](https://www.docker.com/) - Containerization
|
|
597
|
+
|
|
598
|
+
## Changelog
|
|
599
|
+
|
|
600
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
601
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
src/.ai/layout.yaml,sha256=yF79hvJOQDCm8Y75OpMfJzVr0ORR4n4MpokIh3Ff84w,953
|
|
2
|
+
src/__init__.py,sha256=E0i84M6mA2-YIK8SN3zcQ2mw1gG-EXbRvl0Z3WE0cIg,1746
|
|
3
|
+
src/api.py,sha256=C-Co8fjY8ewT0O5IttAX045Fhr34MuXz_YL0wT5Q0x4,4644
|
|
4
|
+
src/cli.py,sha256=s11vSyouEY4Jqu6bx7QyP-jvIefpTOso-JpkpiK7Bhk,20409
|
|
5
|
+
src/config.py,sha256=ANDs6EF3IQbwHyNEVWXbpnNQMEe9wDqP3Bm2w_4zTU8,13139
|
|
6
|
+
src/core/__init__.py,sha256=5FtsDvhMt4SNRx3pbcGURrxn135XRbeRrjSUxiXwkNc,381
|
|
7
|
+
src/core/base.py,sha256=x_3swLyVwaIjPgtCNisEFEuMR2caFAuV20izok5afN0,4323
|
|
8
|
+
src/core/registry.py,sha256=wjrxmyVyh0qW9q5ZOTDfCwVStcE_hFlVv8s4eUiJ3P4,6208
|
|
9
|
+
src/core/types.py,sha256=dIYLaCDNtCAzVaplx5S5yxywkLIuX0BN9No_l2zCfV0,2887
|
|
10
|
+
src/linter_config/__init__.py,sha256=_I2VVlZlfKyT-tKukuUA5-aVcHLOe3m6C2cev43AiEc,298
|
|
11
|
+
src/linter_config/ignore.py,sha256=Ffjq6zpjh15FrcoGxt09goXn67QmZb8E_stT4VQ4wls,16239
|
|
12
|
+
src/linter_config/loader.py,sha256=o3-ezigI9K3o4w478eR6l0fLVVLBQ_t11WwpOvePUvA,2879
|
|
13
|
+
src/linters/__init__.py,sha256=-nnNsL8E5-2p9qlLKp_TaShHAjPH-NacOEU1sXmAR9k,77
|
|
14
|
+
src/linters/file_placement/__init__.py,sha256=vJ43GZujcbAk-K3DwfsQZ0J3yP_5G35CKssatLyntXk,862
|
|
15
|
+
src/linters/file_placement/linter.py,sha256=xUD7Kb0aJNSj1Vc-sqTGTXUU5_cXxJcvkm1-OeKFHxk,21973
|
|
16
|
+
src/linters/nesting/__init__.py,sha256=zBxZJPhxTO91ezWwXJ72wyxUS7i8t6lehjlJFJKRYvA,3134
|
|
17
|
+
src/linters/nesting/config.py,sha256=SC-TbKvC_llhkU-_9sC7ya1K7fkH1nLf-1HUzbHXcs8,1755
|
|
18
|
+
src/linters/nesting/linter.py,sha256=h5lVuWgXqanwjg6F9AuWkEdRqYDYWosXGyTZP0qfb7c,9529
|
|
19
|
+
src/linters/nesting/python_analyzer.py,sha256=DF2lVnxYstakOpP_Zizox583Ypkb4eUpgQYEpu6x8gk,3078
|
|
20
|
+
src/linters/nesting/typescript_analyzer.py,sha256=rec4N0NccB9mQ2452g2hcz521-kHxSr5uItjCt1DlLs,6870
|
|
21
|
+
src/orchestrator/__init__.py,sha256=XXLDJq2oaB-TpP2Y97GRnde9EkITGuFCmuLrDfxI9nY,245
|
|
22
|
+
src/orchestrator/core.py,sha256=6LqaDcSBlH-hJmTpPRDTMo-tHTzEwVRQg4sZ0wyKdE0,7092
|
|
23
|
+
src/orchestrator/language_detector.py,sha256=rHyVMApit80NTTNyDH1ObD1usKD8LjGmH3DwqNAWYGc,2736
|
|
24
|
+
thailint-0.1.0.dist-info/LICENSE,sha256=kxh1J0Sb62XvhNJ6MZsVNe8PqNVJ7LHRn_EWa-T3djw,1070
|
|
25
|
+
thailint-0.1.0.dist-info/METADATA,sha256=HUZ-YiivxAiQIKbi1zBYY08Ljq6WhDC8T5raQDFGLoU,16485
|
|
26
|
+
thailint-0.1.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
27
|
+
thailint-0.1.0.dist-info/entry_points.txt,sha256=l7DQJgU18sVLDpSaXOXY3lLhnQHQIRrSJZTQjG1cEAk,62
|
|
28
|
+
thailint-0.1.0.dist-info/RECORD,,
|