linthis 0.2.0__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,924 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: linthis
|
|
3
|
+
Version: 0.2.0
|
|
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
|
+
# Install pre-commit hooks (project-level)
|
|
80
|
+
linthis hook install --type prek
|
|
81
|
+
linthis hook install --type pre-commit
|
|
82
|
+
linthis hook install --type git
|
|
83
|
+
|
|
84
|
+
# Install pre-push hook
|
|
85
|
+
linthis hook install --type git --event pre-push
|
|
86
|
+
|
|
87
|
+
# Install commit-msg hook
|
|
88
|
+
linthis hook install --type git --event commit-msg
|
|
89
|
+
|
|
90
|
+
# Force overwrite existing files
|
|
91
|
+
linthis init --force
|
|
92
|
+
linthis hook install --type prek --force
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Basic Usage
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Check and format current directory (default behavior)
|
|
99
|
+
linthis
|
|
100
|
+
|
|
101
|
+
# Check and format specific directories
|
|
102
|
+
linthis -i src/
|
|
103
|
+
linthis --include src/ --include lib/
|
|
104
|
+
|
|
105
|
+
# Check only, no formatting
|
|
106
|
+
linthis -c
|
|
107
|
+
linthis --check-only
|
|
108
|
+
|
|
109
|
+
# Format only, no checking
|
|
110
|
+
linthis -f
|
|
111
|
+
linthis --format-only
|
|
112
|
+
|
|
113
|
+
# Check Git staged files (suitable for pre-commit hook)
|
|
114
|
+
linthis -s
|
|
115
|
+
linthis --staged
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Specify Languages
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Check specific language
|
|
122
|
+
linthis -l python
|
|
123
|
+
linthis --lang rust
|
|
124
|
+
|
|
125
|
+
# Check multiple languages
|
|
126
|
+
linthis -l python,rust,cpp
|
|
127
|
+
linthis --lang "python,javascript,go"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Exclude Files
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Exclude specific patterns
|
|
134
|
+
linthis -e "*.test.js" -e "dist/**"
|
|
135
|
+
linthis --exclude "target/**" --exclude "node_modules/**"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Plugin System
|
|
139
|
+
|
|
140
|
+
linthis supports Git-based configuration plugins for easy sharing of code standards across projects and teams.
|
|
141
|
+
|
|
142
|
+
### Add Plugin
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Add plugin to project config (.linthis.toml)
|
|
146
|
+
linthis plugin add <alias> <git-url>
|
|
147
|
+
|
|
148
|
+
# Example: Add a custom plugin
|
|
149
|
+
linthis plugin add myplugin https://github.com/zhlinh/linthis-plugin.git
|
|
150
|
+
|
|
151
|
+
# Add to global config (~/.linthis/config.toml)
|
|
152
|
+
linthis plugin add -g <alias> <git-url>
|
|
153
|
+
linthis plugin add --global <alias> <git-url>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Use Plugin
|
|
157
|
+
|
|
158
|
+
Plugins are automatically loaded when running linthis. After adding a plugin:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Plugin configs are auto-loaded
|
|
162
|
+
linthis
|
|
163
|
+
|
|
164
|
+
# Combine with other options
|
|
165
|
+
linthis -i src/
|
|
166
|
+
# Check only
|
|
167
|
+
linthis -c
|
|
168
|
+
# Format only
|
|
169
|
+
linthis -f
|
|
170
|
+
# Check and format files staged
|
|
171
|
+
linthis -s
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Remove Plugin
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Remove plugin from project config
|
|
178
|
+
linthis plugin remove <alias>
|
|
179
|
+
linthis plugin remove myplugin
|
|
180
|
+
|
|
181
|
+
# Remove plugin from global config
|
|
182
|
+
linthis plugin remove -g <alias>
|
|
183
|
+
linthis plugin remove --global myplugin
|
|
184
|
+
|
|
185
|
+
# Supports flexible parameter ordering
|
|
186
|
+
linthis plugin remove --global myplugin
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### View and Manage Plugins
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# View project config plugins
|
|
193
|
+
linthis plugin list
|
|
194
|
+
|
|
195
|
+
# View global config plugins
|
|
196
|
+
linthis plugin list -g
|
|
197
|
+
linthis plugin list --global
|
|
198
|
+
|
|
199
|
+
# Sync (update) plugins
|
|
200
|
+
linthis plugin sync # Sync local plugins
|
|
201
|
+
linthis plugin sync --global # Sync global plugins
|
|
202
|
+
|
|
203
|
+
# Initialize new plugin
|
|
204
|
+
linthis plugin init my-config
|
|
205
|
+
|
|
206
|
+
# Validate plugin structure
|
|
207
|
+
linthis plugin validate /path/to/plugin
|
|
208
|
+
|
|
209
|
+
# Clean plugin cache
|
|
210
|
+
linthis plugin clean # Interactive cleanup
|
|
211
|
+
linthis plugin clean --all # Clean all caches
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Configuration Files
|
|
215
|
+
|
|
216
|
+
### Project Configuration
|
|
217
|
+
|
|
218
|
+
Create `.linthis.toml` in your project root:
|
|
219
|
+
|
|
220
|
+
```toml
|
|
221
|
+
# Specify languages to check (omit for auto-detection)
|
|
222
|
+
languages = ["rust", "python", "javascript"]
|
|
223
|
+
|
|
224
|
+
# Exclude files and directories
|
|
225
|
+
excludes = [
|
|
226
|
+
"target/**",
|
|
227
|
+
"node_modules/**",
|
|
228
|
+
"*.generated.rs",
|
|
229
|
+
"dist/**"
|
|
230
|
+
]
|
|
231
|
+
|
|
232
|
+
# Maximum cyclomatic complexity
|
|
233
|
+
max_complexity = 20
|
|
234
|
+
|
|
235
|
+
# Format preset
|
|
236
|
+
preset = "google" # Options: google, airbnb, standard
|
|
237
|
+
|
|
238
|
+
# Configure plugins
|
|
239
|
+
[plugins]
|
|
240
|
+
sources = [
|
|
241
|
+
{ name = "official" },
|
|
242
|
+
{ name = "myplugin", url = "https://github.com/zhlinh/linthis-plugin.git", ref = "main" }
|
|
243
|
+
]
|
|
244
|
+
|
|
245
|
+
# Language-specific configuration
|
|
246
|
+
# [rust]
|
|
247
|
+
# max_complexity = 15
|
|
248
|
+
|
|
249
|
+
# [python]
|
|
250
|
+
# excludes = ["*_test.py"]
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Global Configuration
|
|
254
|
+
|
|
255
|
+
Global configuration file is located at `~/.linthis/config.toml`, with the same format as project config.
|
|
256
|
+
|
|
257
|
+
### Configuration Priority
|
|
258
|
+
|
|
259
|
+
Configuration merge priority (from high to low):
|
|
260
|
+
|
|
261
|
+
1. **CLI Parameters**: `--option value`
|
|
262
|
+
2. **Project Config**: `.linthis.toml`
|
|
263
|
+
3. **Global Config**: `~/.linthis/config.toml`
|
|
264
|
+
4. **Plugin Config**: Plugins in sources array (later ones override earlier ones)
|
|
265
|
+
5. **Built-in Defaults**
|
|
266
|
+
|
|
267
|
+
## Configuration Management
|
|
268
|
+
|
|
269
|
+
linthis provides a `config` subcommand for convenient command-line configuration management without manual TOML editing.
|
|
270
|
+
|
|
271
|
+
### Array Field Operations
|
|
272
|
+
|
|
273
|
+
Supported array fields: `includes`, `excludes`, `languages`
|
|
274
|
+
|
|
275
|
+
#### Add Values (add)
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
# Add to project config
|
|
279
|
+
linthis config add includes "src/**"
|
|
280
|
+
linthis config add excludes "*.log"
|
|
281
|
+
linthis config add languages "rust"
|
|
282
|
+
|
|
283
|
+
# Add to global config (-g or --global)
|
|
284
|
+
linthis config add -g includes "lib/**"
|
|
285
|
+
linthis config add --global excludes "node_modules/**"
|
|
286
|
+
|
|
287
|
+
# Add multiple values (automatically deduped)
|
|
288
|
+
linthis config add includes "src/**"
|
|
289
|
+
linthis config add includes "lib/**"
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### Remove Values (remove)
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Remove from project config
|
|
296
|
+
linthis config remove excludes "*.log"
|
|
297
|
+
linthis config remove languages "python"
|
|
298
|
+
|
|
299
|
+
# Remove from global config
|
|
300
|
+
linthis config remove -g includes "lib/**"
|
|
301
|
+
linthis config remove --global excludes "target/**"
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### Clear Field (clear)
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Clear project config field
|
|
308
|
+
linthis config clear languages
|
|
309
|
+
linthis config clear includes
|
|
310
|
+
|
|
311
|
+
# Clear global config field
|
|
312
|
+
linthis config clear -g excludes
|
|
313
|
+
linthis config clear --global languages
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Scalar Field Operations
|
|
317
|
+
|
|
318
|
+
Supported scalar fields: `max_complexity`, `preset`, `verbose`
|
|
319
|
+
|
|
320
|
+
#### Set Value (set)
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
# Set complexity limit
|
|
324
|
+
linthis config set max_complexity 15
|
|
325
|
+
linthis config set max_complexity 30 -g
|
|
326
|
+
|
|
327
|
+
# Set format preset (google, standard, airbnb)
|
|
328
|
+
linthis config set preset google
|
|
329
|
+
linthis config set preset airbnb --global
|
|
330
|
+
|
|
331
|
+
# Set verbose output
|
|
332
|
+
linthis config set verbose true
|
|
333
|
+
linthis config set verbose false -g
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
#### Unset Value (unset)
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# Remove field from project config
|
|
340
|
+
linthis config unset max_complexity
|
|
341
|
+
linthis config unset preset
|
|
342
|
+
|
|
343
|
+
# Remove field from global config
|
|
344
|
+
linthis config unset -g verbose
|
|
345
|
+
linthis config unset --global max_complexity
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Query Operations
|
|
349
|
+
|
|
350
|
+
#### Get Single Field Value (get)
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# View project config field
|
|
354
|
+
linthis config get includes
|
|
355
|
+
linthis config get max_complexity
|
|
356
|
+
linthis config get preset
|
|
357
|
+
|
|
358
|
+
# View global config field
|
|
359
|
+
linthis config get -g excludes
|
|
360
|
+
linthis config get --global languages
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
#### List All Configuration (list)
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
# List project config
|
|
367
|
+
linthis config list
|
|
368
|
+
|
|
369
|
+
# List global config
|
|
370
|
+
linthis config list -g
|
|
371
|
+
linthis config list --global
|
|
372
|
+
|
|
373
|
+
# Verbose mode (show all fields including empty values)
|
|
374
|
+
linthis config list -v
|
|
375
|
+
linthis config list --verbose
|
|
376
|
+
linthis config list --global --verbose
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Configuration Management Examples
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
# Initialize project config
|
|
383
|
+
linthis config add includes "src/**"
|
|
384
|
+
linthis config add includes "lib/**"
|
|
385
|
+
linthis config add excludes "target/**"
|
|
386
|
+
linthis config add excludes "*.log"
|
|
387
|
+
linthis config add languages "rust"
|
|
388
|
+
linthis config add languages "python"
|
|
389
|
+
linthis config set max_complexity 20
|
|
390
|
+
linthis config set preset google
|
|
391
|
+
|
|
392
|
+
# View config
|
|
393
|
+
linthis config list
|
|
394
|
+
|
|
395
|
+
# Adjust config
|
|
396
|
+
linthis config set max_complexity 15
|
|
397
|
+
linthis config remove excludes "*.log"
|
|
398
|
+
linthis config add excludes "*.tmp"
|
|
399
|
+
|
|
400
|
+
# Set global defaults
|
|
401
|
+
linthis config set -g max_complexity 20
|
|
402
|
+
linthis config add -g excludes "node_modules/**"
|
|
403
|
+
linthis config add -g excludes ".git/**"
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Configuration Migration
|
|
407
|
+
|
|
408
|
+
linthis can automatically detect and migrate existing linter/formatter configurations to linthis format.
|
|
409
|
+
|
|
410
|
+
#### Supported Tools
|
|
411
|
+
|
|
412
|
+
| Tool | Detected Files |
|
|
413
|
+
| -------- | --------------------------------------------------------------------------------------------- |
|
|
414
|
+
| ESLint | `.eslintrc.js`, `.eslintrc.json`, `.eslintrc.yml`, `.eslintrc`, `eslint.config.js`, `package.json[eslintConfig]` |
|
|
415
|
+
| Prettier | `.prettierrc`, `.prettierrc.json`, `.prettierrc.yml`, `.prettierrc.js`, `prettier.config.js`, `package.json[prettier]` |
|
|
416
|
+
| Black | `pyproject.toml[tool.black]` |
|
|
417
|
+
| isort | `pyproject.toml[tool.isort]` |
|
|
418
|
+
|
|
419
|
+
#### Migration Commands
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
# Auto-detect and migrate all configs
|
|
423
|
+
linthis config migrate
|
|
424
|
+
|
|
425
|
+
# Migrate specific tool only
|
|
426
|
+
linthis config migrate --from eslint
|
|
427
|
+
linthis config migrate --from prettier
|
|
428
|
+
linthis config migrate --from black
|
|
429
|
+
linthis config migrate --from isort
|
|
430
|
+
|
|
431
|
+
# Preview changes without applying
|
|
432
|
+
linthis config migrate --dry-run
|
|
433
|
+
|
|
434
|
+
# Create backup of original files
|
|
435
|
+
linthis config migrate --backup
|
|
436
|
+
|
|
437
|
+
# Verbose output
|
|
438
|
+
linthis config migrate --verbose
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
#### Migration Output
|
|
442
|
+
|
|
443
|
+
Migrated configurations are placed in `.linthis/configs/{language}/`:
|
|
444
|
+
|
|
445
|
+
- ESLint → `.linthis/configs/javascript/.eslintrc.js`
|
|
446
|
+
- Prettier → `.linthis/configs/javascript/prettierrc.js`
|
|
447
|
+
- Black/isort → `.linthis/configs/python/ruff.toml`
|
|
448
|
+
|
|
449
|
+
### Initialize Configuration File
|
|
450
|
+
|
|
451
|
+
Use the `init` subcommand to explicitly create configuration files:
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# Create project config (.linthis.toml)
|
|
455
|
+
linthis init
|
|
456
|
+
|
|
457
|
+
# Create global config (~/.linthis/config.toml)
|
|
458
|
+
linthis init -g
|
|
459
|
+
linthis init --global
|
|
460
|
+
|
|
461
|
+
# Backward compatible: can also use --init flag
|
|
462
|
+
linthis --init
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### Auto-Create Configuration Files
|
|
466
|
+
|
|
467
|
+
When using the `config` command, configuration files are automatically created if they don't exist:
|
|
468
|
+
|
|
469
|
+
- **Project Config**: Creates `.linthis.toml` in current directory
|
|
470
|
+
- **Global Config**: Creates `config.toml` in `~/.linthis/` directory
|
|
471
|
+
|
|
472
|
+
All modifications preserve TOML file format and comments.
|
|
473
|
+
|
|
474
|
+
## Command Line Options
|
|
475
|
+
|
|
476
|
+
### Main Command Options
|
|
477
|
+
|
|
478
|
+
| Short | Long | Description | Example |
|
|
479
|
+
| ----- | ----------------------- | --------------------------------------------- | ----------------------- |
|
|
480
|
+
| `-i` | `--include` | Specify files or directories to check | `-i src -i lib` |
|
|
481
|
+
| `-e` | `--exclude` | Exclude patterns (can be used multiple times) | `-e "*.test.js"` |
|
|
482
|
+
| `-c` | `--check-only` | Check only, no formatting | `-c` |
|
|
483
|
+
| `-f` | `--format-only` | Format only, no checking | `-f` |
|
|
484
|
+
| `-s` | `--staged` | Check only Git staged files | `-s` |
|
|
485
|
+
| `-l` | `--lang` | Specify languages (comma-separated) | `-l python,rust` |
|
|
486
|
+
| `-o` | `--output` | Output format: human, json, github-actions | `-o json` |
|
|
487
|
+
| `-v` | `--verbose` | Verbose output | `-v` |
|
|
488
|
+
| `-q` | `--quiet` | Quiet mode (errors only) | `-q` |
|
|
489
|
+
| | `--config` | Specify config file path | `--config custom.toml` |
|
|
490
|
+
| | `--init` | Initialize .linthis.toml config file | `--init` |
|
|
491
|
+
| | `--preset` | Format preset | `--preset google` |
|
|
492
|
+
| | `--no-default-excludes` | Disable default exclude rules | `--no-default-excludes` |
|
|
493
|
+
| | `--no-gitignore` | Disable .gitignore rules | `--no-gitignore` |
|
|
494
|
+
| | `--no-plugin` | Skip loading plugins, use default config | `--no-plugin` |
|
|
495
|
+
|
|
496
|
+
### Plugin Management Subcommands
|
|
497
|
+
|
|
498
|
+
| Command | Short | Long | Description |
|
|
499
|
+
| -------------------------- | ----- | ----------- | -------------------------- |
|
|
500
|
+
| `plugin add <alias> <url>` | `-g` | `--global` | Add to global config |
|
|
501
|
+
| | | `--ref` | Specify Git reference |
|
|
502
|
+
| `plugin remove <alias>` | `-g` | `--global` | Remove from global config |
|
|
503
|
+
| `plugin list` | `-g` | `--global` | Show global config plugins |
|
|
504
|
+
| | `-v` | `--verbose` | Show detailed info |
|
|
505
|
+
| `plugin clean` | | `--all` | Clean all caches |
|
|
506
|
+
| `plugin init <name>` | | | Initialize new plugin |
|
|
507
|
+
| `plugin validate <path>` | | | Validate plugin structure |
|
|
508
|
+
|
|
509
|
+
### Configuration Management Subcommands
|
|
510
|
+
|
|
511
|
+
| Command | Short | Long | Description |
|
|
512
|
+
| ------------------------------- | ----- | ----------- | ------------------------------------------- |
|
|
513
|
+
| `config add <field> <value>` | `-g` | `--global` | Add value to array field |
|
|
514
|
+
| `config remove <field> <value>` | `-g` | `--global` | Remove value from array field |
|
|
515
|
+
| `config clear <field>` | `-g` | `--global` | Clear array field |
|
|
516
|
+
| `config set <field> <value>` | `-g` | `--global` | Set scalar field value |
|
|
517
|
+
| `config unset <field>` | `-g` | `--global` | Remove scalar field |
|
|
518
|
+
| `config get <field>` | `-g` | `--global` | Get field value |
|
|
519
|
+
| `config list` | `-g` | `--global` | List all configuration |
|
|
520
|
+
| | `-v` | `--verbose` | Show detailed info (including empty values) |
|
|
521
|
+
| `config migrate` | | `--from` | Migrate from specific tool |
|
|
522
|
+
| | | `--dry-run` | Preview changes without applying |
|
|
523
|
+
| | | `--backup` | Create backup of original files |
|
|
524
|
+
| | `-v` | `--verbose` | Show detailed output |
|
|
525
|
+
|
|
526
|
+
**Supported array fields**: `includes`, `excludes`, `languages`
|
|
527
|
+
**Supported scalar fields**: `max_complexity`, `preset`, `verbose`
|
|
528
|
+
|
|
529
|
+
### Init Subcommand
|
|
530
|
+
|
|
531
|
+
| Command | Short | Long | Description |
|
|
532
|
+
| ------- | ----- | ------------- | -------------------------------- |
|
|
533
|
+
| `init` | `-g` | `--global` | Create global config file |
|
|
534
|
+
| | | `--with-hook` | Also install git hook after init |
|
|
535
|
+
| | | `--force` | Force overwrite existing files |
|
|
536
|
+
|
|
537
|
+
**Created configuration files**:
|
|
538
|
+
|
|
539
|
+
- Without `-g`: Creates `.linthis.toml` (current directory)
|
|
540
|
+
- With `-g`: Creates `~/.linthis/config.toml` (global config)
|
|
541
|
+
|
|
542
|
+
### Hook Subcommand
|
|
543
|
+
|
|
544
|
+
| Command | Short | Long | Description |
|
|
545
|
+
| ---------------- | ----- | --------------- | -------------------------------------- |
|
|
546
|
+
| `hook install` | | `--type` | Hook type (prek/pre-commit/git) |
|
|
547
|
+
| | | `--event` | Hook event (pre-commit/pre-push/commit-msg) |
|
|
548
|
+
| | `-c` | `--check-only` | Hook only runs check |
|
|
549
|
+
| | `-f` | `--format-only` | Hook only runs format |
|
|
550
|
+
| | | `--force` | Force overwrite existing hook |
|
|
551
|
+
| | `-y` | `--yes` | Non-interactive mode |
|
|
552
|
+
| `hook uninstall` | | `--event` | Hook event to uninstall |
|
|
553
|
+
| | `-y` | `--yes` | Non-interactive mode |
|
|
554
|
+
| `hook status` | | | Show git hook status |
|
|
555
|
+
| `hook check` | | | Check for hook conflicts |
|
|
556
|
+
|
|
557
|
+
**Hook types**:
|
|
558
|
+
|
|
559
|
+
- `prek`: Rust-based pre-commit tool (faster)
|
|
560
|
+
- `pre-commit`: Python-based standard tool
|
|
561
|
+
- `git`: Traditional git hook
|
|
562
|
+
|
|
563
|
+
**Hook events**:
|
|
564
|
+
|
|
565
|
+
- `pre-commit`: Run before commit (default, checks staged files)
|
|
566
|
+
- `pre-push`: Run before push (checks all files)
|
|
567
|
+
- `commit-msg`: Validate commit message format
|
|
568
|
+
|
|
569
|
+
## Supported Languages
|
|
570
|
+
|
|
571
|
+
| Language | Linter | Formatter |
|
|
572
|
+
| ---------- | -------------------- | ------------------ |
|
|
573
|
+
| Rust | clippy | rustfmt |
|
|
574
|
+
| Python | pylint, flake8, ruff | black, ruff |
|
|
575
|
+
| TypeScript | eslint | prettier |
|
|
576
|
+
| JavaScript | eslint | prettier |
|
|
577
|
+
| Go | golangci-lint | gofmt |
|
|
578
|
+
| Java | checkstyle | google-java-format |
|
|
579
|
+
| C++ | cpplint, cppcheck | clang-format |
|
|
580
|
+
| Swift | swiftlint | swift-format |
|
|
581
|
+
| Kotlin | detekt | ktlint |
|
|
582
|
+
| Lua | luacheck | stylua |
|
|
583
|
+
| Dart | dart analyze | dart format |
|
|
584
|
+
|
|
585
|
+
## Editor Plugins
|
|
586
|
+
|
|
587
|
+
linthis provides official plugins for popular editors, offering seamless integration with format-on-save, manual lint/format commands, and configurable settings.
|
|
588
|
+
|
|
589
|
+
### VSCode
|
|
590
|
+
|
|
591
|
+
Install from [VS Marketplace](https://marketplace.visualstudio.com/items?itemName=zhlinh.linthis) or search "linthis" in VSCode Extensions.
|
|
592
|
+
|
|
593
|
+
**Features:**
|
|
594
|
+
- Format on Save (configurable)
|
|
595
|
+
- Manual Lint/Format commands via Command Palette
|
|
596
|
+
- Configurable executable path and additional arguments
|
|
597
|
+
- Status bar integration
|
|
598
|
+
|
|
599
|
+
**Installation via Command Palette:**
|
|
600
|
+
```
|
|
601
|
+
ext install zhlinh.linthis
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
**Configuration (settings.json):**
|
|
605
|
+
```json
|
|
606
|
+
{
|
|
607
|
+
"linthis.formatOnSave": true,
|
|
608
|
+
"linthis.executable.path": "",
|
|
609
|
+
"linthis.executable.additionalArguments": ""
|
|
610
|
+
}
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
📁 Source: [vscode-linthis](./vscode-linthis/)
|
|
614
|
+
|
|
615
|
+
### JetBrains (IntelliJ IDEA, WebStorm, PyCharm, etc.)
|
|
616
|
+
|
|
617
|
+
Install from [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/XXXXX-linthis) or search "linthis" in IDE Settings → Plugins.
|
|
618
|
+
|
|
619
|
+
**Features:**
|
|
620
|
+
- Format on Save (configurable)
|
|
621
|
+
- Manual Lint/Format via Tools menu
|
|
622
|
+
- Configurable executable path and additional arguments
|
|
623
|
+
- Settings UI in Preferences → Tools → Linthis
|
|
624
|
+
|
|
625
|
+
**Installation:**
|
|
626
|
+
1. Open Settings/Preferences → Plugins
|
|
627
|
+
2. Search for "linthis"
|
|
628
|
+
3. Click Install and restart IDE
|
|
629
|
+
|
|
630
|
+
**Configuration:**
|
|
631
|
+
- Settings → Tools → Linthis
|
|
632
|
+
- Enable/disable Format on Save
|
|
633
|
+
- Set custom executable path
|
|
634
|
+
- Add additional command-line arguments
|
|
635
|
+
|
|
636
|
+
📁 Source: [jetbrains-linthis](./jetbrains-linthis/)
|
|
637
|
+
|
|
638
|
+
### Neovim
|
|
639
|
+
|
|
640
|
+
Install using your favorite plugin manager. Distributed via GitHub.
|
|
641
|
+
|
|
642
|
+
#### lazy.nvim (Recommended)
|
|
643
|
+
|
|
644
|
+
```lua
|
|
645
|
+
-- For monorepo (plugin in subdirectory)
|
|
646
|
+
{
|
|
647
|
+
"zhlinh/linthis",
|
|
648
|
+
subdir = "nvim-linthis",
|
|
649
|
+
config = function()
|
|
650
|
+
require("linthis").setup()
|
|
651
|
+
end,
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
-- For standalone repository
|
|
655
|
+
{
|
|
656
|
+
"zhlinh/nvim-linthis",
|
|
657
|
+
config = function()
|
|
658
|
+
require("linthis").setup()
|
|
659
|
+
end,
|
|
660
|
+
}
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
#### packer.nvim
|
|
664
|
+
|
|
665
|
+
```lua
|
|
666
|
+
-- For monorepo
|
|
667
|
+
use {
|
|
668
|
+
"zhlinh/linthis",
|
|
669
|
+
rtp = "nvim-linthis",
|
|
670
|
+
config = function()
|
|
671
|
+
require("linthis").setup()
|
|
672
|
+
end,
|
|
673
|
+
}
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
#### vim-plug
|
|
677
|
+
|
|
678
|
+
```vim
|
|
679
|
+
" For monorepo
|
|
680
|
+
Plug 'zhlinh/linthis', { 'rtp': 'nvim-linthis' }
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
**Features:**
|
|
684
|
+
- Format on Save (configurable)
|
|
685
|
+
- Commands: `:LinthisLint`, `:LinthisFormat`, `:LinthisLintFormat`
|
|
686
|
+
- Configurable via `setup()` options
|
|
687
|
+
|
|
688
|
+
**Configuration:**
|
|
689
|
+
```lua
|
|
690
|
+
require("linthis").setup({
|
|
691
|
+
format_on_save = true,
|
|
692
|
+
executable = "linthis",
|
|
693
|
+
additional_args = {},
|
|
694
|
+
})
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
📁 Source: [nvim-linthis](./nvim-linthis/)
|
|
698
|
+
|
|
699
|
+
## Usage Scenarios
|
|
700
|
+
|
|
701
|
+
### Pre-commit Hook
|
|
702
|
+
|
|
703
|
+
#### Method 1: Using prek (Recommended for Teams)
|
|
704
|
+
|
|
705
|
+
[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.
|
|
706
|
+
|
|
707
|
+
Install prek:
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
# Using cargo
|
|
711
|
+
cargo install prek
|
|
712
|
+
|
|
713
|
+
# Or using pip
|
|
714
|
+
pip install prek
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
Create `.pre-commit-config.yaml` in your project:
|
|
718
|
+
|
|
719
|
+
```yaml
|
|
720
|
+
# .pre-commit-config.yaml
|
|
721
|
+
repos:
|
|
722
|
+
- repo: local
|
|
723
|
+
hooks:
|
|
724
|
+
- id: linthis
|
|
725
|
+
name: linthis
|
|
726
|
+
entry: linthis --staged --check-only
|
|
727
|
+
language: system
|
|
728
|
+
pass_filenames: false
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
Install hook:
|
|
732
|
+
|
|
733
|
+
```bash
|
|
734
|
+
prek install
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
#### Method 2: Traditional Git Hook (Project-level)
|
|
738
|
+
|
|
739
|
+
Add to `.git/hooks/pre-commit`:
|
|
740
|
+
|
|
741
|
+
```bash
|
|
742
|
+
#!/bin/sh
|
|
743
|
+
linthis --staged --check-only
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
Or use linthis to create it automatically:
|
|
747
|
+
|
|
748
|
+
```bash
|
|
749
|
+
linthis hook install --type git
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
#### Method 3: Using pre-commit Framework
|
|
753
|
+
|
|
754
|
+
Using the [pre-commit](https://pre-commit.com/) framework:
|
|
755
|
+
|
|
756
|
+
```yaml
|
|
757
|
+
# .pre-commit-config.yaml
|
|
758
|
+
repos:
|
|
759
|
+
- repo: local
|
|
760
|
+
hooks:
|
|
761
|
+
- id: linthis
|
|
762
|
+
name: linthis
|
|
763
|
+
entry: linthis --staged --check-only
|
|
764
|
+
language: system
|
|
765
|
+
pass_filenames: false
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
### CI/CD Integration
|
|
769
|
+
|
|
770
|
+
#### GitHub Actions
|
|
771
|
+
|
|
772
|
+
```yaml
|
|
773
|
+
name: Lint
|
|
774
|
+
|
|
775
|
+
on: [push, pull_request]
|
|
776
|
+
|
|
777
|
+
jobs:
|
|
778
|
+
lint:
|
|
779
|
+
runs-on: ubuntu-latest
|
|
780
|
+
steps:
|
|
781
|
+
- uses: actions/checkout@v3
|
|
782
|
+
- name: Install linthis
|
|
783
|
+
run: pip install linthis
|
|
784
|
+
- name: Run linthis
|
|
785
|
+
run: linthis --check-only --output github-actions
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
#### GitLab CI
|
|
789
|
+
|
|
790
|
+
```yaml
|
|
791
|
+
lint:
|
|
792
|
+
image: rust:latest
|
|
793
|
+
script:
|
|
794
|
+
- cargo install linthis
|
|
795
|
+
- linthis --check-only
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
## Creating Custom Plugins
|
|
799
|
+
|
|
800
|
+
### 1. Initialize Plugin
|
|
801
|
+
|
|
802
|
+
```bash
|
|
803
|
+
linthis plugin init my-company-standards
|
|
804
|
+
cd my-company-standards
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
### 2. Edit Plugin Configuration
|
|
808
|
+
|
|
809
|
+
Edit `linthis-plugin.toml`:
|
|
810
|
+
|
|
811
|
+
```toml
|
|
812
|
+
[plugin]
|
|
813
|
+
name = "my-company-standards"
|
|
814
|
+
version = "1.0.0"
|
|
815
|
+
description = "My company's coding standards"
|
|
816
|
+
|
|
817
|
+
["language.python"]
|
|
818
|
+
config_count = 2
|
|
819
|
+
|
|
820
|
+
["language.python".tools.flake8]
|
|
821
|
+
priority = "P0"
|
|
822
|
+
files = [".flake8"]
|
|
823
|
+
|
|
824
|
+
["language.python".tools.black]
|
|
825
|
+
priority = "P1"
|
|
826
|
+
files = ["pyproject.toml"]
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
### 3. Add Configuration Files
|
|
830
|
+
|
|
831
|
+
```bash
|
|
832
|
+
mkdir -p python
|
|
833
|
+
# Add your config files to corresponding language directories
|
|
834
|
+
cp /path/to/.flake8 python/
|
|
835
|
+
cp /path/to/pyproject.toml python/
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
### 4. Publish to Git
|
|
839
|
+
|
|
840
|
+
```bash
|
|
841
|
+
git init
|
|
842
|
+
git add .
|
|
843
|
+
git commit -m "feat: Initial commit of my company coding standards"
|
|
844
|
+
git remote add origin git@github.com:mycompany/linthis-standards.git
|
|
845
|
+
git push -u origin main
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
### 5. Use Your Plugin
|
|
849
|
+
|
|
850
|
+
```bash
|
|
851
|
+
linthis plugin add company https://github.com/mycompany/linthis-standards.git
|
|
852
|
+
linthis # Plugin configs are auto-loaded
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
## FAQ
|
|
856
|
+
|
|
857
|
+
### Q: How to specify multiple paths?
|
|
858
|
+
|
|
859
|
+
```bash
|
|
860
|
+
linthis -i src -i lib -i tests
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
### Q: How to check only specific file types?
|
|
864
|
+
|
|
865
|
+
```bash
|
|
866
|
+
linthis -l python # Only check Python files
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
### Q: Where is the plugin cache?
|
|
870
|
+
|
|
871
|
+
- macOS: `~/Library/Caches/linthis/plugins`
|
|
872
|
+
- Linux: `~/.cache/linthis/plugins`
|
|
873
|
+
- Windows: `%LOCALAPPDATA%\linthis\cache\plugins`
|
|
874
|
+
|
|
875
|
+
### Q: How to update plugins?
|
|
876
|
+
|
|
877
|
+
```bash
|
|
878
|
+
linthis plugin sync # Sync local plugins
|
|
879
|
+
linthis plugin sync --global # Sync global plugins
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
### Q: What is the plugin Git reference (ref) used for?
|
|
883
|
+
|
|
884
|
+
The ref can specify:
|
|
885
|
+
|
|
886
|
+
- Branch name: `--ref main`
|
|
887
|
+
- Tag: `--ref v1.0.0`
|
|
888
|
+
- Commit hash: `--ref abc1234`
|
|
889
|
+
|
|
890
|
+
This allows you to lock plugin versions or use development versions.
|
|
891
|
+
|
|
892
|
+
## Documentation
|
|
893
|
+
|
|
894
|
+
- [Plugin Auto-Sync](docs/AUTO_SYNC.md) - Automatic plugin synchronization (inspired by oh-my-zsh)
|
|
895
|
+
- [Self Auto-Update](docs/SELF_UPDATE.md) - Automatic self-update functionality
|
|
896
|
+
|
|
897
|
+
## Development
|
|
898
|
+
|
|
899
|
+
### Build
|
|
900
|
+
|
|
901
|
+
```bash
|
|
902
|
+
cargo build
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
### Test
|
|
906
|
+
|
|
907
|
+
```bash
|
|
908
|
+
cargo test
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
### Release
|
|
912
|
+
|
|
913
|
+
```bash
|
|
914
|
+
cargo build --release
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
## Contributing
|
|
918
|
+
|
|
919
|
+
Issues and Pull Requests are welcome!
|
|
920
|
+
|
|
921
|
+
## License
|
|
922
|
+
|
|
923
|
+
MIT License - See [LICENSE](LICENSE) file for details
|
|
924
|
+
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
linthis-0.2.0.data/scripts/linthis,sha256=R2EYFXI-pz9iZdUPlR4MoxWqxf7m30UqC8f_ELPBA_s,12508512
|
|
2
|
+
linthis-0.2.0.dist-info/METADATA,sha256=1C8F-kQuefL0d20x9EPECxkPMM-5jbrpnv6eLgVHQlw,25353
|
|
3
|
+
linthis-0.2.0.dist-info/WHEEL,sha256=-UC-30_KW0M5UOiw2JWkZWkxs52Gf2zb1JdhQnuscms,106
|
|
4
|
+
linthis-0.2.0.dist-info/RECORD,,
|