linthis 0.0.7__py3-none-manylinux_2_28_x86_64.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.
|
Binary file
|
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: linthis
|
|
3
|
+
Version: 0.0.7
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Environment :: Console
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Rust
|
|
10
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
11
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
12
|
+
Summary: A fast, cross-platform multi-language linter and formatter
|
|
13
|
+
Keywords: lint,format,cli,code-quality,rust
|
|
14
|
+
Home-Page: https://github.com/zhlinh/linthis
|
|
15
|
+
Author: zhlinh
|
|
16
|
+
License: MIT
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
19
|
+
Project-URL: Documentation, https://docs.rs/linthis
|
|
20
|
+
Project-URL: Homepage, https://github.com/zhlinh/linthis
|
|
21
|
+
Project-URL: Repository, https://github.com/zhlinh/linthis
|
|
22
|
+
|
|
23
|
+
# linthis
|
|
24
|
+
|
|
25
|
+
[](https://crates.io/crates/linthis)
|
|
26
|
+
[](https://pypi.org/project/linthis/)
|
|
27
|
+
[](https://opensource.org/licenses/MIT)
|
|
28
|
+
|
|
29
|
+
A fast, cross-platform multi-language linter and formatter written in Rust.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- 🚀 **Single Command**: Run both linting and formatting simultaneously
|
|
34
|
+
- 🌍 **Multi-Language Support**: Rust, Python, TypeScript, JavaScript, Go, Java, C++, Swift, Kotlin, Lua, and more
|
|
35
|
+
- 🎯 **Auto-Detection**: Automatically detect programming languages used in your project
|
|
36
|
+
- ⚙️ **Flexible Configuration**: Support for project config, global config, and CLI parameters
|
|
37
|
+
- 📦 **Plugin System**: Share and reuse configurations via Git repositories
|
|
38
|
+
- 🎨 **Format Presets**: Support for popular code styles like Google, Airbnb, Standard
|
|
39
|
+
- ⚡ **Parallel Processing**: Leverage multi-core CPU for faster file processing
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
### Method 1: Install via PyPI (Recommended for Python users)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Using pip
|
|
47
|
+
pip install linthis
|
|
48
|
+
|
|
49
|
+
# Using uv (recommended)
|
|
50
|
+
# pip install uv
|
|
51
|
+
uv pip install linthis
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Method 2: Install via Cargo (Recommended for Rust users)
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cargo install linthis
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Method 3: Build from Source
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/zhlinh/linthis.git
|
|
64
|
+
cd linthis
|
|
65
|
+
cargo build --release
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
### Initialize Configuration (Optional)
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Create project configuration file
|
|
74
|
+
linthis init
|
|
75
|
+
|
|
76
|
+
# Create global configuration file
|
|
77
|
+
linthis init -g
|
|
78
|
+
|
|
79
|
+
# Create global git hook template (for all new repos)
|
|
80
|
+
linthis init -g --hook-type git
|
|
81
|
+
|
|
82
|
+
# Initialize with pre-commit hooks (project-level)
|
|
83
|
+
linthis init --hook-type prek
|
|
84
|
+
linthis init --hook-type pre-commit
|
|
85
|
+
linthis init --hook-type git
|
|
86
|
+
|
|
87
|
+
# Force overwrite existing files
|
|
88
|
+
linthis init --force
|
|
89
|
+
linthis init --hook-type prek -f
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Basic Usage
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Check and format current directory (default behavior)
|
|
96
|
+
linthis
|
|
97
|
+
|
|
98
|
+
# Check and format specific directories
|
|
99
|
+
linthis -i src/
|
|
100
|
+
linthis --include src/ --include lib/
|
|
101
|
+
|
|
102
|
+
# Check only, no formatting
|
|
103
|
+
linthis -c
|
|
104
|
+
linthis --check-only
|
|
105
|
+
|
|
106
|
+
# Format only, no checking
|
|
107
|
+
linthis -f
|
|
108
|
+
linthis --format-only
|
|
109
|
+
|
|
110
|
+
# Check Git staged files (suitable for pre-commit hook)
|
|
111
|
+
linthis -s
|
|
112
|
+
linthis --staged
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Specify Languages
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Check specific language
|
|
119
|
+
linthis -l python
|
|
120
|
+
linthis --lang rust
|
|
121
|
+
|
|
122
|
+
# Check multiple languages
|
|
123
|
+
linthis -l python,rust,cpp
|
|
124
|
+
linthis --lang "python,javascript,go"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Exclude Files
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Exclude specific patterns
|
|
131
|
+
linthis -e "*.test.js" -e "dist/**"
|
|
132
|
+
linthis --exclude "target/**" --exclude "node_modules/**"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Plugin System
|
|
136
|
+
|
|
137
|
+
linthis supports Git-based configuration plugins for easy sharing of code standards across projects and teams.
|
|
138
|
+
|
|
139
|
+
### Add Plugin
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Add plugin to project config (.linthis.toml)
|
|
143
|
+
linthis plugin add <alias> <git-url>
|
|
144
|
+
|
|
145
|
+
# Example: Add a custom plugin
|
|
146
|
+
linthis plugin add myplugin https://github.com/zhlinh/linthis-plugin.git
|
|
147
|
+
|
|
148
|
+
# Add to global config (~/.linthis/config.toml)
|
|
149
|
+
linthis plugin add -g <alias> <git-url>
|
|
150
|
+
linthis plugin add --global <alias> <git-url>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Use Plugin
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Use plugin configuration for linting and formatting
|
|
157
|
+
linthis -p myplugin
|
|
158
|
+
linthis --plugin myplugin
|
|
159
|
+
|
|
160
|
+
# Combine with other options
|
|
161
|
+
linthis -p myplugin -l python -i src/
|
|
162
|
+
linthis --plugin myplugin --check-only
|
|
163
|
+
linthis --plugin myplugin --staged
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Remove Plugin
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Remove plugin from project config
|
|
170
|
+
linthis plugin remove <alias>
|
|
171
|
+
linthis plugin remove myplugin
|
|
172
|
+
|
|
173
|
+
# Remove plugin from global config
|
|
174
|
+
linthis plugin remove -g <alias>
|
|
175
|
+
linthis plugin remove --global myplugin
|
|
176
|
+
|
|
177
|
+
# Supports flexible parameter ordering
|
|
178
|
+
linthis plugin remove --global myplugin
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### View and Manage Plugins
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# View project config plugins
|
|
185
|
+
linthis plugin list
|
|
186
|
+
|
|
187
|
+
# View global config plugins
|
|
188
|
+
linthis plugin list -g
|
|
189
|
+
linthis plugin list --global
|
|
190
|
+
|
|
191
|
+
# Update plugin cache
|
|
192
|
+
linthis --plugin-update
|
|
193
|
+
|
|
194
|
+
# Initialize new plugin
|
|
195
|
+
linthis plugin init my-config
|
|
196
|
+
|
|
197
|
+
# Validate plugin structure
|
|
198
|
+
linthis plugin validate /path/to/plugin
|
|
199
|
+
|
|
200
|
+
# Clean plugin cache
|
|
201
|
+
linthis plugin clean # Interactive cleanup
|
|
202
|
+
linthis plugin clean --all # Clean all caches
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Configuration Files
|
|
206
|
+
|
|
207
|
+
### Project Configuration
|
|
208
|
+
|
|
209
|
+
Create `.linthis.toml` in your project root:
|
|
210
|
+
|
|
211
|
+
```toml
|
|
212
|
+
# Specify languages to check (omit for auto-detection)
|
|
213
|
+
languages = ["rust", "python", "javascript"]
|
|
214
|
+
|
|
215
|
+
# Exclude files and directories
|
|
216
|
+
excludes = [
|
|
217
|
+
"target/**",
|
|
218
|
+
"node_modules/**",
|
|
219
|
+
"*.generated.rs",
|
|
220
|
+
"dist/**"
|
|
221
|
+
]
|
|
222
|
+
|
|
223
|
+
# Maximum cyclomatic complexity
|
|
224
|
+
max_complexity = 20
|
|
225
|
+
|
|
226
|
+
# Format preset
|
|
227
|
+
preset = "google" # Options: google, airbnb, standard
|
|
228
|
+
|
|
229
|
+
# Configure plugins
|
|
230
|
+
[plugins]
|
|
231
|
+
sources = [
|
|
232
|
+
{ name = "official" },
|
|
233
|
+
{ name = "myplugin", url = "https://github.com/zhlinh/linthis-plugin.git", ref = "main" }
|
|
234
|
+
]
|
|
235
|
+
|
|
236
|
+
# Language-specific configuration
|
|
237
|
+
# [rust]
|
|
238
|
+
# max_complexity = 15
|
|
239
|
+
|
|
240
|
+
# [python]
|
|
241
|
+
# excludes = ["*_test.py"]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Global Configuration
|
|
245
|
+
|
|
246
|
+
Global configuration file is located at `~/.linthis/config.toml`, with the same format as project config.
|
|
247
|
+
|
|
248
|
+
### Configuration Priority
|
|
249
|
+
|
|
250
|
+
Configuration merge priority (from high to low):
|
|
251
|
+
|
|
252
|
+
1. **CLI Parameters**: `--option value`
|
|
253
|
+
2. **Project Config**: `.linthis.toml`
|
|
254
|
+
3. **Global Config**: `~/.linthis/config.toml`
|
|
255
|
+
4. **Plugin Config**: Plugins in sources array (later ones override earlier ones)
|
|
256
|
+
5. **Built-in Defaults**
|
|
257
|
+
|
|
258
|
+
## Configuration Management
|
|
259
|
+
|
|
260
|
+
linthis provides a `config` subcommand for convenient command-line configuration management without manual TOML editing.
|
|
261
|
+
|
|
262
|
+
### Array Field Operations
|
|
263
|
+
|
|
264
|
+
Supported array fields: `includes`, `excludes`, `languages`
|
|
265
|
+
|
|
266
|
+
#### Add Values (add)
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Add to project config
|
|
270
|
+
linthis config add includes "src/**"
|
|
271
|
+
linthis config add excludes "*.log"
|
|
272
|
+
linthis config add languages "rust"
|
|
273
|
+
|
|
274
|
+
# Add to global config (-g or --global)
|
|
275
|
+
linthis config add -g includes "lib/**"
|
|
276
|
+
linthis config add --global excludes "node_modules/**"
|
|
277
|
+
|
|
278
|
+
# Add multiple values (automatically deduped)
|
|
279
|
+
linthis config add includes "src/**"
|
|
280
|
+
linthis config add includes "lib/**"
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### Remove Values (remove)
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Remove from project config
|
|
287
|
+
linthis config remove excludes "*.log"
|
|
288
|
+
linthis config remove languages "python"
|
|
289
|
+
|
|
290
|
+
# Remove from global config
|
|
291
|
+
linthis config remove -g includes "lib/**"
|
|
292
|
+
linthis config remove --global excludes "target/**"
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
#### Clear Field (clear)
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Clear project config field
|
|
299
|
+
linthis config clear languages
|
|
300
|
+
linthis config clear includes
|
|
301
|
+
|
|
302
|
+
# Clear global config field
|
|
303
|
+
linthis config clear -g excludes
|
|
304
|
+
linthis config clear --global languages
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Scalar Field Operations
|
|
308
|
+
|
|
309
|
+
Supported scalar fields: `max_complexity`, `preset`, `verbose`
|
|
310
|
+
|
|
311
|
+
#### Set Value (set)
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# Set complexity limit
|
|
315
|
+
linthis config set max_complexity 15
|
|
316
|
+
linthis config set max_complexity 30 -g
|
|
317
|
+
|
|
318
|
+
# Set format preset (google, standard, airbnb)
|
|
319
|
+
linthis config set preset google
|
|
320
|
+
linthis config set preset airbnb --global
|
|
321
|
+
|
|
322
|
+
# Set verbose output
|
|
323
|
+
linthis config set verbose true
|
|
324
|
+
linthis config set verbose false -g
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### Unset Value (unset)
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
# Remove field from project config
|
|
331
|
+
linthis config unset max_complexity
|
|
332
|
+
linthis config unset preset
|
|
333
|
+
|
|
334
|
+
# Remove field from global config
|
|
335
|
+
linthis config unset -g verbose
|
|
336
|
+
linthis config unset --global max_complexity
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Query Operations
|
|
340
|
+
|
|
341
|
+
#### Get Single Field Value (get)
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
# View project config field
|
|
345
|
+
linthis config get includes
|
|
346
|
+
linthis config get max_complexity
|
|
347
|
+
linthis config get preset
|
|
348
|
+
|
|
349
|
+
# View global config field
|
|
350
|
+
linthis config get -g excludes
|
|
351
|
+
linthis config get --global languages
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
#### List All Configuration (list)
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
# List project config
|
|
358
|
+
linthis config list
|
|
359
|
+
|
|
360
|
+
# List global config
|
|
361
|
+
linthis config list -g
|
|
362
|
+
linthis config list --global
|
|
363
|
+
|
|
364
|
+
# Verbose mode (show all fields including empty values)
|
|
365
|
+
linthis config list -v
|
|
366
|
+
linthis config list --verbose
|
|
367
|
+
linthis config list --global --verbose
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Configuration Management Examples
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
# Initialize project config
|
|
374
|
+
linthis config add includes "src/**"
|
|
375
|
+
linthis config add includes "lib/**"
|
|
376
|
+
linthis config add excludes "target/**"
|
|
377
|
+
linthis config add excludes "*.log"
|
|
378
|
+
linthis config add languages "rust"
|
|
379
|
+
linthis config add languages "python"
|
|
380
|
+
linthis config set max_complexity 20
|
|
381
|
+
linthis config set preset google
|
|
382
|
+
|
|
383
|
+
# View config
|
|
384
|
+
linthis config list
|
|
385
|
+
|
|
386
|
+
# Adjust config
|
|
387
|
+
linthis config set max_complexity 15
|
|
388
|
+
linthis config remove excludes "*.log"
|
|
389
|
+
linthis config add excludes "*.tmp"
|
|
390
|
+
|
|
391
|
+
# Set global defaults
|
|
392
|
+
linthis config set -g max_complexity 20
|
|
393
|
+
linthis config add -g excludes "node_modules/**"
|
|
394
|
+
linthis config add -g excludes ".git/**"
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Initialize Configuration File
|
|
398
|
+
|
|
399
|
+
Use the `init` subcommand to explicitly create configuration files:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
# Create project config (.linthis.toml)
|
|
403
|
+
linthis init
|
|
404
|
+
|
|
405
|
+
# Create global config (~/.linthis/config.toml)
|
|
406
|
+
linthis init -g
|
|
407
|
+
linthis init --global
|
|
408
|
+
|
|
409
|
+
# Backward compatible: can also use --init flag
|
|
410
|
+
linthis --init
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Auto-Create Configuration Files
|
|
414
|
+
|
|
415
|
+
When using the `config` command, configuration files are automatically created if they don't exist:
|
|
416
|
+
|
|
417
|
+
- **Project Config**: Creates `.linthis.toml` in current directory
|
|
418
|
+
- **Global Config**: Creates `config.toml` in `~/.linthis/` directory
|
|
419
|
+
|
|
420
|
+
All modifications preserve TOML file format and comments.
|
|
421
|
+
|
|
422
|
+
## Command Line Options
|
|
423
|
+
|
|
424
|
+
### Main Command Options
|
|
425
|
+
|
|
426
|
+
| Short | Long | Description | Example |
|
|
427
|
+
| ----- | ----------------------- | ---------------------------------------- | ----------------------- |
|
|
428
|
+
| `-i` | `--include` | Specify files or directories to check | `-i src -i lib` |
|
|
429
|
+
| `-e` | `--exclude` | Exclude patterns (can be used multiple times) | `-e "*.test.js"` |
|
|
430
|
+
| `-p` | `--plugin` | Use plugin (alias or Git URL) | `-p myplugin` |
|
|
431
|
+
| `-c` | `--check-only` | Check only, no formatting | `-c` |
|
|
432
|
+
| `-f` | `--format-only` | Format only, no checking | `-f` |
|
|
433
|
+
| `-s` | `--staged` | Check only Git staged files | `-s` |
|
|
434
|
+
| `-l` | `--lang` | Specify languages (comma-separated) | `-l python,rust` |
|
|
435
|
+
| `-o` | `--output` | Output format: human, json, github-actions | `-o json` |
|
|
436
|
+
| `-v` | `--verbose` | Verbose output | `-v` |
|
|
437
|
+
| `-q` | `--quiet` | Quiet mode (errors only) | `-q` |
|
|
438
|
+
| | `--config` | Specify config file path | `--config custom.toml` |
|
|
439
|
+
| | `--init` | Initialize .linthis.toml config file | `--init` |
|
|
440
|
+
| | `--preset` | Format preset | `--preset google` |
|
|
441
|
+
| | `--plugin-update` | Force update plugin cache | `--plugin-update` |
|
|
442
|
+
| | `--no-default-excludes` | Disable default exclude rules | `--no-default-excludes` |
|
|
443
|
+
| | `--no-gitignore` | Disable .gitignore rules | `--no-gitignore` |
|
|
444
|
+
|
|
445
|
+
### Plugin Management Subcommands
|
|
446
|
+
|
|
447
|
+
| Command | Short | Long | Description |
|
|
448
|
+
| -------------------------- | ----- | ----------- | ------------------------- |
|
|
449
|
+
| `plugin add <alias> <url>` | `-g` | `--global` | Add to global config |
|
|
450
|
+
| | | `--ref` | Specify Git reference |
|
|
451
|
+
| `plugin remove <alias>` | `-g` | `--global` | Remove from global config |
|
|
452
|
+
| `plugin list` | `-g` | `--global` | Show global config plugins|
|
|
453
|
+
| | `-v` | `--verbose` | Show detailed info |
|
|
454
|
+
| `plugin clean` | | `--all` | Clean all caches |
|
|
455
|
+
| `plugin init <name>` | | | Initialize new plugin |
|
|
456
|
+
| `plugin validate <path>` | | | Validate plugin structure |
|
|
457
|
+
|
|
458
|
+
### Configuration Management Subcommands
|
|
459
|
+
|
|
460
|
+
| Command | Short | Long | Description |
|
|
461
|
+
| ------------------------------- | ----- | ----------- | ------------------------------- |
|
|
462
|
+
| `config add <field> <value>` | `-g` | `--global` | Add value to array field |
|
|
463
|
+
| `config remove <field> <value>` | `-g` | `--global` | Remove value from array field |
|
|
464
|
+
| `config clear <field>` | `-g` | `--global` | Clear array field |
|
|
465
|
+
| `config set <field> <value>` | `-g` | `--global` | Set scalar field value |
|
|
466
|
+
| `config unset <field>` | `-g` | `--global` | Remove scalar field |
|
|
467
|
+
| `config get <field>` | `-g` | `--global` | Get field value |
|
|
468
|
+
| `config list` | `-g` | `--global` | List all configuration |
|
|
469
|
+
| | `-v` | `--verbose` | Show detailed info (including empty values) |
|
|
470
|
+
|
|
471
|
+
**Supported array fields**: `includes`, `excludes`, `languages`
|
|
472
|
+
**Supported scalar fields**: `max_complexity`, `preset`, `verbose`
|
|
473
|
+
|
|
474
|
+
### Init Subcommand
|
|
475
|
+
|
|
476
|
+
| Command | Short | Long | Description |
|
|
477
|
+
| ------- | ----- | ---------- | ---------------------------------- |
|
|
478
|
+
| `init` | `-g` | `--global` | Create global config file |
|
|
479
|
+
| | | `--hook` | Initialize pre-commit hooks |
|
|
480
|
+
| | `-i` | `--interactive` | Interactive mode for hooks setup |
|
|
481
|
+
| | `-f` | `--force` | Force overwrite existing files |
|
|
482
|
+
|
|
483
|
+
**Created configuration files**:
|
|
484
|
+
- Without `-g`: Creates `.linthis.toml` (current directory)
|
|
485
|
+
- With `-g`: Creates `~/.linthis/config.toml` (global config)
|
|
486
|
+
|
|
487
|
+
**Hook options**:
|
|
488
|
+
- `prek`: Rust-based pre-commit tool (faster)
|
|
489
|
+
- `pre-commit`: Python-based standard tool
|
|
490
|
+
- `git`: Traditional git hook
|
|
491
|
+
|
|
492
|
+
## Supported Languages
|
|
493
|
+
|
|
494
|
+
| Language | Linter | Formatter |
|
|
495
|
+
| ---------- | -------------------- | ------------------ |
|
|
496
|
+
| Rust | clippy | rustfmt |
|
|
497
|
+
| Python | pylint, flake8, ruff | black, ruff |
|
|
498
|
+
| TypeScript | eslint | prettier |
|
|
499
|
+
| JavaScript | eslint | prettier |
|
|
500
|
+
| Go | golangci-lint | gofmt |
|
|
501
|
+
| Java | checkstyle | google-java-format |
|
|
502
|
+
| C++ | cpplint, cppcheck | clang-format |
|
|
503
|
+
| Swift | swiftlint | swift-format |
|
|
504
|
+
| Kotlin | detekt | ktlint |
|
|
505
|
+
| Lua | luacheck | stylua |
|
|
506
|
+
| Dart | dart analyze | dart format |
|
|
507
|
+
|
|
508
|
+
## Usage Scenarios
|
|
509
|
+
|
|
510
|
+
### Pre-commit Hook
|
|
511
|
+
|
|
512
|
+
#### Method 1: Global Hook Template (One-time Setup)
|
|
513
|
+
|
|
514
|
+
Set up a global Git hook template that applies to all new repositories:
|
|
515
|
+
|
|
516
|
+
```bash
|
|
517
|
+
# Create global hook template
|
|
518
|
+
linthis init -g --hook-type git
|
|
519
|
+
|
|
520
|
+
# All new repos will automatically include the hook
|
|
521
|
+
git init new-project
|
|
522
|
+
cd new-project
|
|
523
|
+
# .git/hooks/pre-commit is already set up!
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
For existing repositories:
|
|
527
|
+
```bash
|
|
528
|
+
cd existing-project
|
|
529
|
+
git init # Re-apply template
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**Features:**
|
|
533
|
+
- 🎯 **Smart Detection**: Only runs if project has linthis config
|
|
534
|
+
- 🔗 **Hook Chaining**: Supports `.git/hooks/pre-commit.local` for project-specific hooks
|
|
535
|
+
- 🚫 **Zero Interference**: Projects without linthis config are not affected
|
|
536
|
+
- ⚡ **One-time Setup**: Works for all your new repositories
|
|
537
|
+
|
|
538
|
+
**Pros:**
|
|
539
|
+
- One-time setup for all your projects
|
|
540
|
+
- No need to configure hooks per project
|
|
541
|
+
- Perfect for personal development
|
|
542
|
+
- Won't interfere with other projects or hook tools
|
|
543
|
+
|
|
544
|
+
**Cons:**
|
|
545
|
+
- Not shared with team members
|
|
546
|
+
- Requires manual setup on each machine
|
|
547
|
+
|
|
548
|
+
See [Global Hooks Guide](docs/GLOBAL_HOOKS.md) for details.
|
|
549
|
+
|
|
550
|
+
#### Method 2: Using prek (Recommended for Teams)
|
|
551
|
+
|
|
552
|
+
[prek](https://prek.j178.dev) is a high-performance Git hooks manager written in Rust, fully compatible with pre-commit config format but much faster.
|
|
553
|
+
|
|
554
|
+
Install prek:
|
|
555
|
+
|
|
556
|
+
```bash
|
|
557
|
+
# Using cargo
|
|
558
|
+
cargo install prek
|
|
559
|
+
|
|
560
|
+
# Or using pip
|
|
561
|
+
pip install prek
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
Create `.pre-commit-config.yaml` in your project:
|
|
565
|
+
|
|
566
|
+
```yaml
|
|
567
|
+
# .pre-commit-config.yaml
|
|
568
|
+
repos:
|
|
569
|
+
- repo: local
|
|
570
|
+
hooks:
|
|
571
|
+
- id: linthis
|
|
572
|
+
name: linthis
|
|
573
|
+
entry: linthis --staged --check-only
|
|
574
|
+
language: system
|
|
575
|
+
pass_filenames: false
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
Install hook:
|
|
579
|
+
|
|
580
|
+
```bash
|
|
581
|
+
prek install
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
#### Method 3: Traditional Git Hook (Project-level)
|
|
585
|
+
|
|
586
|
+
Add to `.git/hooks/pre-commit`:
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
#!/bin/sh
|
|
590
|
+
linthis --staged --check-only
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
Or use linthis to create it automatically:
|
|
594
|
+
```bash
|
|
595
|
+
linthis init --hook-type git
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
#### Method 4: Using pre-commit Framework
|
|
599
|
+
|
|
600
|
+
Using the [pre-commit](https://pre-commit.com/) framework:
|
|
601
|
+
|
|
602
|
+
```yaml
|
|
603
|
+
# .pre-commit-config.yaml
|
|
604
|
+
repos:
|
|
605
|
+
- repo: local
|
|
606
|
+
hooks:
|
|
607
|
+
- id: linthis
|
|
608
|
+
name: linthis
|
|
609
|
+
entry: linthis --staged --check-only
|
|
610
|
+
language: system
|
|
611
|
+
pass_filenames: false
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
### CI/CD Integration
|
|
615
|
+
|
|
616
|
+
#### GitHub Actions
|
|
617
|
+
|
|
618
|
+
```yaml
|
|
619
|
+
name: Lint
|
|
620
|
+
|
|
621
|
+
on: [push, pull_request]
|
|
622
|
+
|
|
623
|
+
jobs:
|
|
624
|
+
lint:
|
|
625
|
+
runs-on: ubuntu-latest
|
|
626
|
+
steps:
|
|
627
|
+
- uses: actions/checkout@v3
|
|
628
|
+
- name: Install linthis
|
|
629
|
+
run: pip install linthis
|
|
630
|
+
- name: Run linthis
|
|
631
|
+
run: linthis --check-only --output github-actions
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
#### GitLab CI
|
|
635
|
+
|
|
636
|
+
```yaml
|
|
637
|
+
lint:
|
|
638
|
+
image: rust:latest
|
|
639
|
+
script:
|
|
640
|
+
- cargo install linthis
|
|
641
|
+
- linthis --check-only
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
## Creating Custom Plugins
|
|
645
|
+
|
|
646
|
+
### 1. Initialize Plugin
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
linthis plugin init my-company-standards
|
|
650
|
+
cd my-company-standards
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### 2. Edit Plugin Configuration
|
|
654
|
+
|
|
655
|
+
Edit `linthis-plugin.toml`:
|
|
656
|
+
|
|
657
|
+
```toml
|
|
658
|
+
[plugin]
|
|
659
|
+
name = "my-company-standards"
|
|
660
|
+
version = "1.0.0"
|
|
661
|
+
description = "My company's coding standards"
|
|
662
|
+
|
|
663
|
+
["language.python"]
|
|
664
|
+
config_count = 2
|
|
665
|
+
|
|
666
|
+
["language.python".tools.flake8]
|
|
667
|
+
priority = "P0"
|
|
668
|
+
files = [".flake8"]
|
|
669
|
+
|
|
670
|
+
["language.python".tools.black]
|
|
671
|
+
priority = "P1"
|
|
672
|
+
files = ["pyproject.toml"]
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
### 3. Add Configuration Files
|
|
676
|
+
|
|
677
|
+
```bash
|
|
678
|
+
mkdir -p python
|
|
679
|
+
# Add your config files to corresponding language directories
|
|
680
|
+
cp /path/to/.flake8 python/
|
|
681
|
+
cp /path/to/pyproject.toml python/
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
### 4. Publish to Git
|
|
685
|
+
|
|
686
|
+
```bash
|
|
687
|
+
git init
|
|
688
|
+
git add .
|
|
689
|
+
git commit -m "feat: Initial commit of my company coding standards"
|
|
690
|
+
git remote add origin git@github.com:mycompany/linthis-standards.git
|
|
691
|
+
git push -u origin main
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
### 5. Use Your Plugin
|
|
695
|
+
|
|
696
|
+
```bash
|
|
697
|
+
linthis plugin add company https://github.com/mycompany/linthis-standards.git
|
|
698
|
+
linthis --plugin company
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
## FAQ
|
|
702
|
+
|
|
703
|
+
### Q: How to specify multiple paths?
|
|
704
|
+
|
|
705
|
+
```bash
|
|
706
|
+
linthis -i src -i lib -i tests
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
### Q: How to check only specific file types?
|
|
710
|
+
|
|
711
|
+
```bash
|
|
712
|
+
linthis -l python # Only check Python files
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
### Q: Where is the plugin cache?
|
|
716
|
+
|
|
717
|
+
- macOS: `~/Library/Caches/linthis/plugins`
|
|
718
|
+
- Linux: `~/.cache/linthis/plugins`
|
|
719
|
+
- Windows: `%LOCALAPPDATA%\linthis\plugins`
|
|
720
|
+
|
|
721
|
+
### Q: How to update plugins?
|
|
722
|
+
|
|
723
|
+
```bash
|
|
724
|
+
linthis --plugin-update
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
### Q: What is the plugin Git reference (ref) used for?
|
|
728
|
+
|
|
729
|
+
The ref can specify:
|
|
730
|
+
|
|
731
|
+
- Branch name: `--ref main`
|
|
732
|
+
- Tag: `--ref v1.0.0`
|
|
733
|
+
- Commit hash: `--ref abc1234`
|
|
734
|
+
|
|
735
|
+
This allows you to lock plugin versions or use development versions.
|
|
736
|
+
|
|
737
|
+
## Documentation
|
|
738
|
+
|
|
739
|
+
- [Plugin Auto-Sync](docs/AUTO_SYNC.md) - Automatic plugin synchronization (inspired by oh-my-zsh)
|
|
740
|
+
- [Self Auto-Update](docs/SELF_UPDATE.md) - Automatic self-update functionality
|
|
741
|
+
|
|
742
|
+
## Development
|
|
743
|
+
|
|
744
|
+
### Build
|
|
745
|
+
|
|
746
|
+
```bash
|
|
747
|
+
cargo build
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
### Test
|
|
751
|
+
|
|
752
|
+
```bash
|
|
753
|
+
cargo test
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
### Release
|
|
757
|
+
|
|
758
|
+
```bash
|
|
759
|
+
cargo build --release
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
## Contributing
|
|
763
|
+
|
|
764
|
+
Issues and Pull Requests are welcome!
|
|
765
|
+
|
|
766
|
+
## License
|
|
767
|
+
|
|
768
|
+
MIT License - See [LICENSE](LICENSE) file for details
|
|
769
|
+
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
linthis-0.0.7.data/scripts/linthis,sha256=zOb2JJhp4X8EiS-INtG2TVvhPhu7ql3nk6FXqrR5QQ8,4843888
|
|
2
|
+
linthis-0.0.7.dist-info/METADATA,sha256=yfnQ5HERBInfY7WfNtGkLK-cjkFqy-dfQm_DRHK6rX0,20366
|
|
3
|
+
linthis-0.0.7.dist-info/WHEEL,sha256=AbUP6xlasRpPiNgXC_062hp-N1DPgJL-D40r71abeW0,106
|
|
4
|
+
linthis-0.0.7.dist-info/RECORD,,
|