thailint 0.1.5__py3-none-any.whl → 0.5.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/__init__.py +7 -2
- src/analyzers/__init__.py +23 -0
- src/analyzers/typescript_base.py +148 -0
- src/api.py +1 -1
- src/cli.py +1111 -144
- src/config.py +12 -33
- src/core/base.py +102 -5
- src/core/cli_utils.py +206 -0
- src/core/config_parser.py +126 -0
- src/core/linter_utils.py +168 -0
- src/core/registry.py +17 -92
- src/core/rule_discovery.py +132 -0
- src/core/violation_builder.py +122 -0
- src/linter_config/ignore.py +112 -40
- src/linter_config/loader.py +3 -13
- src/linters/dry/__init__.py +23 -0
- src/linters/dry/base_token_analyzer.py +76 -0
- src/linters/dry/block_filter.py +265 -0
- src/linters/dry/block_grouper.py +59 -0
- src/linters/dry/cache.py +172 -0
- src/linters/dry/cache_query.py +61 -0
- src/linters/dry/config.py +134 -0
- src/linters/dry/config_loader.py +44 -0
- src/linters/dry/deduplicator.py +120 -0
- src/linters/dry/duplicate_storage.py +63 -0
- src/linters/dry/file_analyzer.py +90 -0
- src/linters/dry/inline_ignore.py +140 -0
- src/linters/dry/linter.py +163 -0
- src/linters/dry/python_analyzer.py +668 -0
- src/linters/dry/storage_initializer.py +42 -0
- src/linters/dry/token_hasher.py +169 -0
- src/linters/dry/typescript_analyzer.py +592 -0
- src/linters/dry/violation_builder.py +74 -0
- src/linters/dry/violation_filter.py +94 -0
- src/linters/dry/violation_generator.py +174 -0
- src/linters/file_header/__init__.py +24 -0
- src/linters/file_header/atemporal_detector.py +87 -0
- src/linters/file_header/config.py +66 -0
- src/linters/file_header/field_validator.py +69 -0
- src/linters/file_header/linter.py +313 -0
- src/linters/file_header/python_parser.py +86 -0
- src/linters/file_header/violation_builder.py +78 -0
- src/linters/file_placement/config_loader.py +86 -0
- src/linters/file_placement/directory_matcher.py +80 -0
- src/linters/file_placement/linter.py +262 -471
- src/linters/file_placement/path_resolver.py +61 -0
- src/linters/file_placement/pattern_matcher.py +55 -0
- src/linters/file_placement/pattern_validator.py +106 -0
- src/linters/file_placement/rule_checker.py +229 -0
- src/linters/file_placement/violation_factory.py +177 -0
- src/linters/magic_numbers/__init__.py +48 -0
- src/linters/magic_numbers/config.py +82 -0
- src/linters/magic_numbers/context_analyzer.py +247 -0
- src/linters/magic_numbers/linter.py +516 -0
- src/linters/magic_numbers/python_analyzer.py +76 -0
- src/linters/magic_numbers/typescript_analyzer.py +218 -0
- src/linters/magic_numbers/violation_builder.py +98 -0
- src/linters/nesting/__init__.py +6 -2
- src/linters/nesting/config.py +17 -4
- src/linters/nesting/linter.py +81 -168
- src/linters/nesting/typescript_analyzer.py +39 -102
- src/linters/nesting/typescript_function_extractor.py +130 -0
- src/linters/nesting/violation_builder.py +139 -0
- src/linters/print_statements/__init__.py +53 -0
- src/linters/print_statements/config.py +83 -0
- src/linters/print_statements/linter.py +430 -0
- src/linters/print_statements/python_analyzer.py +155 -0
- src/linters/print_statements/typescript_analyzer.py +135 -0
- src/linters/print_statements/violation_builder.py +98 -0
- src/linters/srp/__init__.py +99 -0
- src/linters/srp/class_analyzer.py +113 -0
- src/linters/srp/config.py +82 -0
- src/linters/srp/heuristics.py +89 -0
- src/linters/srp/linter.py +234 -0
- src/linters/srp/metrics_evaluator.py +47 -0
- src/linters/srp/python_analyzer.py +72 -0
- src/linters/srp/typescript_analyzer.py +75 -0
- src/linters/srp/typescript_metrics_calculator.py +90 -0
- src/linters/srp/violation_builder.py +117 -0
- src/orchestrator/core.py +54 -9
- src/templates/thailint_config_template.yaml +158 -0
- src/utils/__init__.py +4 -0
- src/utils/project_root.py +203 -0
- thailint-0.5.0.dist-info/METADATA +1286 -0
- thailint-0.5.0.dist-info/RECORD +96 -0
- {thailint-0.1.5.dist-info → thailint-0.5.0.dist-info}/WHEEL +1 -1
- src/.ai/layout.yaml +0 -48
- thailint-0.1.5.dist-info/METADATA +0 -629
- thailint-0.1.5.dist-info/RECORD +0 -28
- {thailint-0.1.5.dist-info → thailint-0.5.0.dist-info}/entry_points.txt +0 -0
- {thailint-0.1.5.dist-info → thailint-0.5.0.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,629 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: thailint
|
|
3
|
-
Version: 0.1.5
|
|
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
|
-
# Pull from Docker Hub
|
|
94
|
-
docker pull washad/thailint:latest
|
|
95
|
-
|
|
96
|
-
# Run CLI
|
|
97
|
-
docker run --rm washad/thailint:latest --help
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Quick Start
|
|
101
|
-
|
|
102
|
-
### CLI Mode
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
# Check file placement
|
|
106
|
-
thailint file-placement .
|
|
107
|
-
|
|
108
|
-
# Check nesting depth
|
|
109
|
-
thailint nesting src/
|
|
110
|
-
|
|
111
|
-
# With config file
|
|
112
|
-
thailint nesting --config .thailint.yaml src/
|
|
113
|
-
|
|
114
|
-
# JSON output for CI/CD
|
|
115
|
-
thailint 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):/data \
|
|
140
|
-
washad/thailint:latest file-placement /data
|
|
141
|
-
|
|
142
|
-
# Check nesting depth
|
|
143
|
-
docker run --rm -v $(pwd):/data \
|
|
144
|
-
washad/thailint:latest nesting /data
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Configuration
|
|
148
|
-
|
|
149
|
-
Create `.thailint.yaml` in your project root:
|
|
150
|
-
|
|
151
|
-
```yaml
|
|
152
|
-
# File placement linter configuration
|
|
153
|
-
file-placement:
|
|
154
|
-
enabled: true
|
|
155
|
-
|
|
156
|
-
# Global patterns apply to entire project
|
|
157
|
-
global_patterns:
|
|
158
|
-
deny:
|
|
159
|
-
- pattern: "^(?!src/|tests/).*\\.py$"
|
|
160
|
-
message: "Python files must be in src/ or tests/"
|
|
161
|
-
|
|
162
|
-
# Directory-specific rules
|
|
163
|
-
directories:
|
|
164
|
-
src:
|
|
165
|
-
allow:
|
|
166
|
-
- ".*\\.py$"
|
|
167
|
-
deny:
|
|
168
|
-
- "test_.*\\.py$"
|
|
169
|
-
|
|
170
|
-
tests:
|
|
171
|
-
allow:
|
|
172
|
-
- "test_.*\\.py$"
|
|
173
|
-
- "conftest\\.py$"
|
|
174
|
-
|
|
175
|
-
# Files/directories to ignore
|
|
176
|
-
ignore:
|
|
177
|
-
- "__pycache__/"
|
|
178
|
-
- "*.pyc"
|
|
179
|
-
- ".venv/"
|
|
180
|
-
|
|
181
|
-
# Nesting depth linter configuration
|
|
182
|
-
nesting:
|
|
183
|
-
enabled: true
|
|
184
|
-
max_nesting_depth: 4 # Maximum allowed nesting depth
|
|
185
|
-
|
|
186
|
-
# Language-specific settings (optional)
|
|
187
|
-
languages:
|
|
188
|
-
python:
|
|
189
|
-
max_depth: 4
|
|
190
|
-
typescript:
|
|
191
|
-
max_depth: 4
|
|
192
|
-
javascript:
|
|
193
|
-
max_depth: 4
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
**JSON format also supported** (`.thailint.json`):
|
|
197
|
-
|
|
198
|
-
```json
|
|
199
|
-
{
|
|
200
|
-
"file-placement": {
|
|
201
|
-
"enabled": true,
|
|
202
|
-
"directories": {
|
|
203
|
-
"src": {
|
|
204
|
-
"allow": [".*\\.py$"],
|
|
205
|
-
"deny": ["test_.*\\.py$"]
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
"ignore": ["__pycache__/", "*.pyc"]
|
|
209
|
-
},
|
|
210
|
-
"nesting": {
|
|
211
|
-
"enabled": true,
|
|
212
|
-
"max_nesting_depth": 4,
|
|
213
|
-
"languages": {
|
|
214
|
-
"python": { "max_depth": 4 },
|
|
215
|
-
"typescript": { "max_depth": 4 }
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
See [Configuration Guide](docs/configuration.md) for complete reference.
|
|
222
|
-
|
|
223
|
-
## Nesting Depth Linter
|
|
224
|
-
|
|
225
|
-
### Overview
|
|
226
|
-
|
|
227
|
-
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.
|
|
228
|
-
|
|
229
|
-
### Quick Start
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
# Check nesting depth in current directory
|
|
233
|
-
thailint nesting .
|
|
234
|
-
|
|
235
|
-
# Use strict limit (max depth 3)
|
|
236
|
-
thailint nesting --max-depth 3 src/
|
|
237
|
-
|
|
238
|
-
# Get JSON output
|
|
239
|
-
thailint nesting --format json src/
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
### Configuration
|
|
243
|
-
|
|
244
|
-
Add to `.thailint.yaml`:
|
|
245
|
-
|
|
246
|
-
```yaml
|
|
247
|
-
nesting:
|
|
248
|
-
enabled: true
|
|
249
|
-
max_nesting_depth: 3 # Default: 4, recommended: 3
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
### Example Violation
|
|
253
|
-
|
|
254
|
-
**Code with excessive nesting:**
|
|
255
|
-
```python
|
|
256
|
-
def process_data(items):
|
|
257
|
-
for item in items: # Depth 2
|
|
258
|
-
if item.is_valid(): # Depth 3
|
|
259
|
-
try: # Depth 4 ← VIOLATION (max=3)
|
|
260
|
-
if item.process():
|
|
261
|
-
return True
|
|
262
|
-
except Exception:
|
|
263
|
-
pass
|
|
264
|
-
return False
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
**Refactored with guard clauses:**
|
|
268
|
-
```python
|
|
269
|
-
def process_data(items):
|
|
270
|
-
for item in items: # Depth 2
|
|
271
|
-
if not item.is_valid():
|
|
272
|
-
continue
|
|
273
|
-
try: # Depth 3 ✓
|
|
274
|
-
if item.process():
|
|
275
|
-
return True
|
|
276
|
-
except Exception:
|
|
277
|
-
pass
|
|
278
|
-
return False
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Refactoring Patterns
|
|
282
|
-
|
|
283
|
-
Common patterns to reduce nesting (used to fix 23 violations in thai-lint):
|
|
284
|
-
|
|
285
|
-
1. **Guard Clauses (Early Returns)**
|
|
286
|
-
- Replace `if x: do_something()` with `if not x: return`
|
|
287
|
-
- Exit early, reduce nesting
|
|
288
|
-
|
|
289
|
-
2. **Extract Method**
|
|
290
|
-
- Move nested logic to separate functions
|
|
291
|
-
- Improves readability and testability
|
|
292
|
-
|
|
293
|
-
3. **Dispatch Pattern**
|
|
294
|
-
- Replace if-elif-else chains with dictionary dispatch
|
|
295
|
-
- More extensible and cleaner
|
|
296
|
-
|
|
297
|
-
4. **Flatten Error Handling**
|
|
298
|
-
- Combine multiple try-except blocks
|
|
299
|
-
- Use tuple of exception types
|
|
300
|
-
|
|
301
|
-
### Language Support
|
|
302
|
-
|
|
303
|
-
- ✅ **Python**: Full support (if/for/while/with/try/match)
|
|
304
|
-
- ✅ **TypeScript**: Full support (if/for/while/try/switch)
|
|
305
|
-
- ✅ **JavaScript**: Supported via TypeScript parser
|
|
306
|
-
|
|
307
|
-
### Refactoring Case Study
|
|
308
|
-
|
|
309
|
-
The thai-lint codebase serves as a validation of the nesting linter:
|
|
310
|
-
- Identified: 23 functions requiring refactoring (depth 4 → depth ≤3)
|
|
311
|
-
- Refactored using documented patterns
|
|
312
|
-
- Time estimate: ~10 minutes per function
|
|
313
|
-
- Result: Zero violations, improved readability
|
|
314
|
-
|
|
315
|
-
See [Nesting Linter Guide](docs/nesting-linter.md) for comprehensive documentation and refactoring patterns.
|
|
316
|
-
|
|
317
|
-
## Pre-commit Hooks
|
|
318
|
-
|
|
319
|
-
Automate code quality checks before every commit and push with pre-commit hooks.
|
|
320
|
-
|
|
321
|
-
### Quick Setup
|
|
322
|
-
|
|
323
|
-
```bash
|
|
324
|
-
# 1. Install pre-commit framework
|
|
325
|
-
pip install pre-commit
|
|
326
|
-
|
|
327
|
-
# 2. Install git hooks
|
|
328
|
-
pre-commit install
|
|
329
|
-
pre-commit install --hook-type pre-push
|
|
330
|
-
|
|
331
|
-
# 3. Test it works
|
|
332
|
-
pre-commit run --all-files
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### What You Get
|
|
336
|
-
|
|
337
|
-
**On every commit:**
|
|
338
|
-
- 🚫 Prevents commits to main/master branch
|
|
339
|
-
- 🎨 Auto-fixes formatting issues
|
|
340
|
-
- ✅ Runs thailint on changed files (fast)
|
|
341
|
-
|
|
342
|
-
**On every push:**
|
|
343
|
-
- 🔍 Full linting on entire codebase
|
|
344
|
-
- 🧪 Runs complete test suite
|
|
345
|
-
|
|
346
|
-
### Example Configuration
|
|
347
|
-
|
|
348
|
-
```yaml
|
|
349
|
-
# .pre-commit-config.yaml
|
|
350
|
-
repos:
|
|
351
|
-
- repo: local
|
|
352
|
-
hooks:
|
|
353
|
-
# Prevent commits to protected branches
|
|
354
|
-
- id: no-commit-to-main
|
|
355
|
-
name: Prevent commits to main branch
|
|
356
|
-
entry: bash -c 'branch=$(git rev-parse --abbrev-ref HEAD); if [ "$branch" = "main" ]; then echo "❌ Use a feature branch!"; exit 1; fi'
|
|
357
|
-
language: system
|
|
358
|
-
pass_filenames: false
|
|
359
|
-
always_run: true
|
|
360
|
-
|
|
361
|
-
# Auto-format code
|
|
362
|
-
- id: format
|
|
363
|
-
name: Auto-fix formatting
|
|
364
|
-
entry: make format
|
|
365
|
-
language: system
|
|
366
|
-
pass_filenames: false
|
|
367
|
-
|
|
368
|
-
# Run thailint on changed files
|
|
369
|
-
- id: lint-changed
|
|
370
|
-
name: Lint changed files
|
|
371
|
-
entry: make lint-full FILES=changed
|
|
372
|
-
language: system
|
|
373
|
-
pass_filenames: false
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
See **[Pre-commit Hooks Guide](docs/pre-commit-hooks.md)** for complete documentation, troubleshooting, and advanced configuration.
|
|
377
|
-
|
|
378
|
-
## Common Use Cases
|
|
379
|
-
|
|
380
|
-
### CI/CD Integration
|
|
381
|
-
|
|
382
|
-
```yaml
|
|
383
|
-
# GitHub Actions example
|
|
384
|
-
name: Lint
|
|
385
|
-
|
|
386
|
-
on: [push, pull_request]
|
|
387
|
-
|
|
388
|
-
jobs:
|
|
389
|
-
lint:
|
|
390
|
-
runs-on: ubuntu-latest
|
|
391
|
-
steps:
|
|
392
|
-
- uses: actions/checkout@v3
|
|
393
|
-
- name: Install thailint
|
|
394
|
-
run: pip install thailint
|
|
395
|
-
- name: Run file placement linter
|
|
396
|
-
run: thailint file-placement .
|
|
397
|
-
- name: Run nesting linter
|
|
398
|
-
run: thailint nesting src/ --config .thailint.yaml
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
### Editor Integration
|
|
402
|
-
|
|
403
|
-
```python
|
|
404
|
-
# VS Code extension example
|
|
405
|
-
from src import Linter
|
|
406
|
-
|
|
407
|
-
linter = Linter(config_file='.thailint.yaml')
|
|
408
|
-
violations = linter.lint(file_path)
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
### Test Suite
|
|
412
|
-
|
|
413
|
-
```python
|
|
414
|
-
# pytest integration
|
|
415
|
-
import pytest
|
|
416
|
-
from src import Linter
|
|
417
|
-
|
|
418
|
-
def test_no_violations():
|
|
419
|
-
linter = Linter()
|
|
420
|
-
violations = linter.lint('src/')
|
|
421
|
-
assert len(violations) == 0
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
## Development
|
|
425
|
-
|
|
426
|
-
### Setup Development Environment
|
|
427
|
-
|
|
428
|
-
```bash
|
|
429
|
-
# Install development dependencies
|
|
430
|
-
pip install -e ".[dev]"
|
|
431
|
-
|
|
432
|
-
# Install pre-commit hooks (if using)
|
|
433
|
-
pre-commit install
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
### Running Tests
|
|
437
|
-
|
|
438
|
-
```bash
|
|
439
|
-
# Run all tests
|
|
440
|
-
pytest
|
|
441
|
-
|
|
442
|
-
# Run with coverage
|
|
443
|
-
pytest --cov=src --cov-report=html
|
|
444
|
-
|
|
445
|
-
# Run specific test
|
|
446
|
-
pytest tests/test_cli.py::test_hello_command
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
### Code Quality
|
|
450
|
-
|
|
451
|
-
```bash
|
|
452
|
-
# Lint code
|
|
453
|
-
ruff check src tests
|
|
454
|
-
|
|
455
|
-
# Format code
|
|
456
|
-
ruff format src tests
|
|
457
|
-
|
|
458
|
-
# Type checking
|
|
459
|
-
mypy src/
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
### Building
|
|
463
|
-
|
|
464
|
-
```bash
|
|
465
|
-
# Build Python package
|
|
466
|
-
poetry build
|
|
467
|
-
|
|
468
|
-
# Build Docker image locally (optional)
|
|
469
|
-
docker build -t washad/thailint:latest .
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
## Docker Usage
|
|
473
|
-
|
|
474
|
-
```bash
|
|
475
|
-
# Pull published image
|
|
476
|
-
docker pull washad/thailint:latest
|
|
477
|
-
|
|
478
|
-
# Run CLI help
|
|
479
|
-
docker run --rm washad/thailint:latest --help
|
|
480
|
-
|
|
481
|
-
# Run file-placement linter
|
|
482
|
-
docker run --rm -v $(pwd):/data washad/thailint:latest file-placement /data
|
|
483
|
-
|
|
484
|
-
# Run nesting linter
|
|
485
|
-
docker run --rm -v $(pwd):/data washad/thailint:latest nesting /data
|
|
486
|
-
|
|
487
|
-
# With custom config
|
|
488
|
-
docker run --rm -v $(pwd):/data \
|
|
489
|
-
washad/thailint:latest nesting --config /data/.thailint.yaml /data
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
## Documentation
|
|
493
|
-
|
|
494
|
-
### Comprehensive Guides
|
|
495
|
-
|
|
496
|
-
- 📖 **[Getting Started](docs/getting-started.md)** - Installation, first lint, basic config
|
|
497
|
-
- ⚙️ **[Configuration Reference](docs/configuration.md)** - Complete config options (YAML/JSON)
|
|
498
|
-
- 📚 **[API Reference](docs/api-reference.md)** - Library API documentation
|
|
499
|
-
- 💻 **[CLI Reference](docs/cli-reference.md)** - All CLI commands and options
|
|
500
|
-
- 🚀 **[Deployment Modes](docs/deployment-modes.md)** - CLI, Library, and Docker usage
|
|
501
|
-
- 📁 **[File Placement Linter](docs/file-placement-linter.md)** - Detailed linter guide
|
|
502
|
-
- 🔄 **[Nesting Depth Linter](docs/nesting-linter.md)** - Nesting depth analysis guide
|
|
503
|
-
- 🪝 **[Pre-commit Hooks](docs/pre-commit-hooks.md)** - Automated quality checks
|
|
504
|
-
- 📦 **[Publishing Guide](docs/releasing.md)** - Release and publishing workflow
|
|
505
|
-
- ✅ **[Publishing Checklist](docs/publishing-checklist.md)** - Post-publication validation
|
|
506
|
-
|
|
507
|
-
### Examples
|
|
508
|
-
|
|
509
|
-
See [`examples/`](examples/) directory for working code:
|
|
510
|
-
|
|
511
|
-
- **[basic_usage.py](examples/basic_usage.py)** - Simple library API usage
|
|
512
|
-
- **[advanced_usage.py](examples/advanced_usage.py)** - Advanced patterns and workflows
|
|
513
|
-
- **[ci_integration.py](examples/ci_integration.py)** - CI/CD integration example
|
|
514
|
-
|
|
515
|
-
## Project Structure
|
|
516
|
-
|
|
517
|
-
```
|
|
518
|
-
thai-lint/
|
|
519
|
-
├── src/ # Application source code
|
|
520
|
-
│ ├── api.py # High-level Library API
|
|
521
|
-
│ ├── cli.py # CLI commands
|
|
522
|
-
│ ├── core/ # Core abstractions
|
|
523
|
-
│ │ ├── base.py # Base linter interfaces
|
|
524
|
-
│ │ ├── registry.py # Rule registry
|
|
525
|
-
│ │ └── types.py # Core types (Violation, Severity)
|
|
526
|
-
│ ├── linters/ # Linter implementations
|
|
527
|
-
│ │ └── file_placement/ # File placement linter
|
|
528
|
-
│ ├── linter_config/ # Configuration system
|
|
529
|
-
│ │ ├── loader.py # Config loader (YAML/JSON)
|
|
530
|
-
│ │ └── ignore.py # Ignore directives
|
|
531
|
-
│ └── orchestrator/ # Multi-language orchestrator
|
|
532
|
-
│ ├── core.py # Main orchestrator
|
|
533
|
-
│ └── language_detector.py
|
|
534
|
-
├── tests/ # Test suite (221 tests, 87% coverage)
|
|
535
|
-
│ ├── unit/ # Unit tests
|
|
536
|
-
│ ├── integration/ # Integration tests
|
|
537
|
-
│ └── conftest.py # Pytest fixtures
|
|
538
|
-
├── docs/ # Documentation
|
|
539
|
-
│ ├── getting-started.md
|
|
540
|
-
│ ├── configuration.md
|
|
541
|
-
│ ├── api-reference.md
|
|
542
|
-
│ ├── cli-reference.md
|
|
543
|
-
│ ├── deployment-modes.md
|
|
544
|
-
│ └── file-placement-linter.md
|
|
545
|
-
├── examples/ # Working examples
|
|
546
|
-
│ ├── basic_usage.py
|
|
547
|
-
│ ├── advanced_usage.py
|
|
548
|
-
│ └── ci_integration.py
|
|
549
|
-
├── .ai/ # AI agent documentation
|
|
550
|
-
├── Dockerfile # Multi-stage Docker build
|
|
551
|
-
├── docker-compose.yml # Docker orchestration
|
|
552
|
-
└── pyproject.toml # Project configuration
|
|
553
|
-
```
|
|
554
|
-
|
|
555
|
-
## Contributing
|
|
556
|
-
|
|
557
|
-
Contributions are welcome! Please follow these steps:
|
|
558
|
-
|
|
559
|
-
1. Fork the repository
|
|
560
|
-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
561
|
-
3. Make your changes
|
|
562
|
-
4. Run tests and linting
|
|
563
|
-
5. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
564
|
-
6. Push to the branch (`git push origin feature/amazing-feature`)
|
|
565
|
-
7. Open a Pull Request
|
|
566
|
-
|
|
567
|
-
### Development Guidelines
|
|
568
|
-
|
|
569
|
-
- Write tests for new features
|
|
570
|
-
- Follow existing code style (enforced by Ruff)
|
|
571
|
-
- Add type hints to all functions
|
|
572
|
-
- Update documentation for user-facing changes
|
|
573
|
-
- Run `pytest` and `ruff check` before committing
|
|
574
|
-
|
|
575
|
-
## Performance
|
|
576
|
-
|
|
577
|
-
thailint is designed for speed and efficiency:
|
|
578
|
-
|
|
579
|
-
| Operation | Performance | Target |
|
|
580
|
-
|-----------|-------------|--------|
|
|
581
|
-
| Single file lint | ~20ms | <100ms ✅ |
|
|
582
|
-
| 100 files | ~300ms | <1s ✅ |
|
|
583
|
-
| 1000 files | ~900ms | <5s ✅ |
|
|
584
|
-
| Config loading | ~10ms | <100ms ✅ |
|
|
585
|
-
|
|
586
|
-
*Performance benchmarks run on standard hardware, your results may vary.*
|
|
587
|
-
|
|
588
|
-
## Exit Codes
|
|
589
|
-
|
|
590
|
-
thailint uses standard exit codes for CI/CD integration:
|
|
591
|
-
|
|
592
|
-
- **0** - Success (no violations)
|
|
593
|
-
- **1** - Violations found
|
|
594
|
-
- **2** - Error occurred (invalid config, file not found, etc.)
|
|
595
|
-
|
|
596
|
-
```bash
|
|
597
|
-
thailint file-placement .
|
|
598
|
-
if [ $? -eq 0 ]; then
|
|
599
|
-
echo "✅ Linting passed"
|
|
600
|
-
else
|
|
601
|
-
echo "❌ Linting failed"
|
|
602
|
-
fi
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
## Architecture
|
|
606
|
-
|
|
607
|
-
See [`.ai/docs/`](.ai/docs/) for detailed architecture documentation and [`.ai/howtos/`](.ai/howtos/) for development guides.
|
|
608
|
-
|
|
609
|
-
## License
|
|
610
|
-
|
|
611
|
-
MIT License - see LICENSE file for details.
|
|
612
|
-
|
|
613
|
-
## Support
|
|
614
|
-
|
|
615
|
-
- **Issues**: https://github.com/be-wise-be-kind/thai-lint/issues
|
|
616
|
-
- **Documentation**: `.ai/docs/` and `.ai/howtos/`
|
|
617
|
-
|
|
618
|
-
## Acknowledgments
|
|
619
|
-
|
|
620
|
-
Built with:
|
|
621
|
-
- [Click](https://click.palletsprojects.com/) - CLI framework
|
|
622
|
-
- [pytest](https://pytest.org/) - Testing framework
|
|
623
|
-
- [Ruff](https://docs.astral.sh/ruff/) - Linting and formatting
|
|
624
|
-
- [Docker](https://www.docker.com/) - Containerization
|
|
625
|
-
|
|
626
|
-
## Changelog
|
|
627
|
-
|
|
628
|
-
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
629
|
-
|
thailint-0.1.5.dist-info/RECORD
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
src/.ai/layout.yaml,sha256=yF79hvJOQDCm8Y75OpMfJzVr0ORR4n4MpokIh3Ff84w,953
|
|
2
|
-
src/__init__.py,sha256=OZ5CvL4rDK07lxwyB9g6ZFTY8cxKWlDkdoMH103sHWY,2042
|
|
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.5.dist-info/LICENSE,sha256=kxh1J0Sb62XvhNJ6MZsVNe8PqNVJ7LHRn_EWa-T3djw,1070
|
|
25
|
-
thailint-0.1.5.dist-info/METADATA,sha256=Gp6D4FiqgMPeomZKeyG3f-6y1Eu54gCoXi-kBF3AYHY,17057
|
|
26
|
-
thailint-0.1.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
27
|
-
thailint-0.1.5.dist-info/entry_points.txt,sha256=l7DQJgU18sVLDpSaXOXY3lLhnQHQIRrSJZTQjG1cEAk,62
|
|
28
|
-
thailint-0.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|