linthis 0.0.6__tar.gz → 0.0.8__tar.gz

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.
Files changed (73) hide show
  1. {linthis-0.0.6 → linthis-0.0.8}/.github/workflows/release.yml +2 -1
  2. {linthis-0.0.6 → linthis-0.0.8}/Cargo.lock +8 -1
  3. {linthis-0.0.6 → linthis-0.0.8}/Cargo.toml +4 -1
  4. {linthis-0.0.6 → linthis-0.0.8}/PKG-INFO +71 -23
  5. {linthis-0.0.6 → linthis-0.0.8}/README.md +68 -20
  6. linthis-0.0.8/docs/GLOBAL_HOOKS.md +373 -0
  7. {linthis-0.0.6 → linthis-0.0.8}/pyproject.toml +1 -1
  8. {linthis-0.0.6 → linthis-0.0.8}/src/checkers/cpp.rs +115 -9
  9. {linthis-0.0.6 → linthis-0.0.8}/src/config/mod.rs +3 -0
  10. linthis-0.0.8/src/interactive/editor.rs +300 -0
  11. linthis-0.0.8/src/interactive/menu.rs +734 -0
  12. linthis-0.0.8/src/interactive/mod.rs +27 -0
  13. linthis-0.0.8/src/interactive/nolint.rs +728 -0
  14. linthis-0.0.8/src/interactive/quickfix.rs +171 -0
  15. {linthis-0.0.6 → linthis-0.0.8}/src/lib.rs +175 -74
  16. {linthis-0.0.6 → linthis-0.0.8}/src/main.rs +1225 -274
  17. {linthis-0.0.6 → linthis-0.0.8}/src/utils/mod.rs +63 -0
  18. {linthis-0.0.6 → linthis-0.0.8}/src/utils/output.rs +36 -7
  19. {linthis-0.0.6 → linthis-0.0.8}/src/utils/types.rs +28 -1
  20. {linthis-0.0.6 → linthis-0.0.8}/src/utils/walker.rs +18 -4
  21. {linthis-0.0.6 → linthis-0.0.8}/.gitignore +0 -0
  22. {linthis-0.0.6 → linthis-0.0.8}/CHANGELOG.md +0 -0
  23. {linthis-0.0.6 → linthis-0.0.8}/defaults/.clang-tidy +0 -0
  24. {linthis-0.0.6 → linthis-0.0.8}/defaults/config.toml +0 -0
  25. {linthis-0.0.6 → linthis-0.0.8}/dev.sh +0 -0
  26. {linthis-0.0.6 → linthis-0.0.8}/docs/AUTO_SYNC.md +0 -0
  27. {linthis-0.0.6 → linthis-0.0.8}/docs/SELF_UPDATE.md +0 -0
  28. {linthis-0.0.6 → linthis-0.0.8}/docs/config-cli-design.md +0 -0
  29. {linthis-0.0.6 → linthis-0.0.8}/docs/init-hooks-design.md +0 -0
  30. {linthis-0.0.6 → linthis-0.0.8}/docs/plan-ruff-integration.md +0 -0
  31. {linthis-0.0.6 → linthis-0.0.8}/docs/tasks.md +0 -0
  32. {linthis-0.0.6 → linthis-0.0.8}/scripts/release.sh +0 -0
  33. {linthis-0.0.6 → linthis-0.0.8}/src/benchmark.rs +0 -0
  34. {linthis-0.0.6 → linthis-0.0.8}/src/checkers/go.rs +0 -0
  35. {linthis-0.0.6 → linthis-0.0.8}/src/checkers/java.rs +0 -0
  36. {linthis-0.0.6 → linthis-0.0.8}/src/checkers/mod.rs +0 -0
  37. {linthis-0.0.6 → linthis-0.0.8}/src/checkers/python.rs +0 -0
  38. {linthis-0.0.6 → linthis-0.0.8}/src/checkers/rust.rs +0 -0
  39. {linthis-0.0.6 → linthis-0.0.8}/src/checkers/traits.rs +0 -0
  40. {linthis-0.0.6 → linthis-0.0.8}/src/checkers/typescript.rs +0 -0
  41. {linthis-0.0.6 → linthis-0.0.8}/src/config/cli.rs +0 -0
  42. {linthis-0.0.6 → linthis-0.0.8}/src/fixers/cpplint.rs +0 -0
  43. {linthis-0.0.6 → linthis-0.0.8}/src/fixers/mod.rs +0 -0
  44. {linthis-0.0.6 → linthis-0.0.8}/src/fixers/source.rs +0 -0
  45. {linthis-0.0.6 → linthis-0.0.8}/src/formatters/cpp.rs +0 -0
  46. {linthis-0.0.6 → linthis-0.0.8}/src/formatters/go.rs +0 -0
  47. {linthis-0.0.6 → linthis-0.0.8}/src/formatters/java.rs +0 -0
  48. {linthis-0.0.6 → linthis-0.0.8}/src/formatters/mod.rs +0 -0
  49. {linthis-0.0.6 → linthis-0.0.8}/src/formatters/python.rs +0 -0
  50. {linthis-0.0.6 → linthis-0.0.8}/src/formatters/rust.rs +0 -0
  51. {linthis-0.0.6 → linthis-0.0.8}/src/formatters/traits.rs +0 -0
  52. {linthis-0.0.6 → linthis-0.0.8}/src/formatters/typescript.rs +0 -0
  53. {linthis-0.0.6 → linthis-0.0.8}/src/plugin/auto_sync.rs +0 -0
  54. {linthis-0.0.6 → linthis-0.0.8}/src/plugin/cache.rs +0 -0
  55. {linthis-0.0.6 → linthis-0.0.8}/src/plugin/config_manager.rs +0 -0
  56. {linthis-0.0.6 → linthis-0.0.8}/src/plugin/fetcher.rs +0 -0
  57. {linthis-0.0.6 → linthis-0.0.8}/src/plugin/loader.rs +0 -0
  58. {linthis-0.0.6 → linthis-0.0.8}/src/plugin/manifest.rs +0 -0
  59. {linthis-0.0.6 → linthis-0.0.8}/src/plugin/mod.rs +0 -0
  60. {linthis-0.0.6 → linthis-0.0.8}/src/plugin/registry.rs +0 -0
  61. {linthis-0.0.6 → linthis-0.0.8}/src/presets/mod.rs +0 -0
  62. {linthis-0.0.6 → linthis-0.0.8}/src/self_update.rs +0 -0
  63. {linthis-0.0.6 → linthis-0.0.8}/src/utils/language.rs +0 -0
  64. {linthis-0.0.6 → linthis-0.0.8}/src/utils/unicode.rs +0 -0
  65. {linthis-0.0.6 → linthis-0.0.8}/test-plugin-check/README.md +0 -0
  66. {linthis-0.0.6 → linthis-0.0.8}/test-plugin-check/linthis-plugin.toml +0 -0
  67. {linthis-0.0.6 → linthis-0.0.8}/tests/fixtures/test-plugin/linthis-plugin.toml +0 -0
  68. {linthis-0.0.6 → linthis-0.0.8}/tests/fixtures/test-plugin/python/ruff.toml +0 -0
  69. {linthis-0.0.6 → linthis-0.0.8}/tests/fixtures/test-plugin/rust/clippy.toml +0 -0
  70. {linthis-0.0.6 → linthis-0.0.8}/tests/fixtures/test-plugin/rust/rustfmt.toml +0 -0
  71. {linthis-0.0.6 → linthis-0.0.8}/tests/fixtures/us1/good.rs +0 -0
  72. {linthis-0.0.6 → linthis-0.0.8}/tests/fixtures/us1/unformatted.rs +0 -0
  73. {linthis-0.0.6 → linthis-0.0.8}/tests/integration/mod.rs +0 -0
@@ -36,7 +36,7 @@ jobs:
36
36
  with:
37
37
  target: ${{ matrix.target }}
38
38
  args: --release --locked --out dist
39
- manylinux: '2_17'
39
+ manylinux: '2_28'
40
40
  - name: Upload wheels
41
41
  uses: actions/upload-artifact@v4
42
42
  with:
@@ -239,6 +239,7 @@ jobs:
239
239
  name: Publish to crates.io
240
240
  runs-on: ubuntu-latest
241
241
  if: startsWith(github.ref, 'refs/tags/')
242
+ needs: [linux, windows, macos, sdist]
242
243
  steps:
243
244
  - uses: actions/checkout@v4
244
245
  - uses: dtolnay/rust-toolchain@stable
@@ -497,7 +497,7 @@ dependencies = [
497
497
 
498
498
  [[package]]
499
499
  name = "linthis"
500
- version = "0.0.6"
500
+ version = "0.0.8"
501
501
  dependencies = [
502
502
  "anyhow",
503
503
  "chrono",
@@ -514,6 +514,7 @@ dependencies = [
514
514
  "serde",
515
515
  "serde_json",
516
516
  "serde_yaml",
517
+ "similar",
517
518
  "tempfile",
518
519
  "thiserror",
519
520
  "toml",
@@ -745,6 +746,12 @@ version = "1.3.0"
745
746
  source = "registry+https://github.com/rust-lang/crates.io-index"
746
747
  checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
747
748
 
749
+ [[package]]
750
+ name = "similar"
751
+ version = "2.7.0"
752
+ source = "registry+https://github.com/rust-lang/crates.io-index"
753
+ checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
754
+
748
755
  [[package]]
749
756
  name = "strsim"
750
757
  version = "0.10.0"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "linthis"
3
- version = "0.0.6"
3
+ version = "0.0.8"
4
4
  edition = "2021"
5
5
  authors = ["zhlinh"]
6
6
  description = "A fast, cross-platform multi-language linter and formatter"
@@ -42,6 +42,9 @@ regex = "1.8"
42
42
  # Glob pattern matching
43
43
  globset = "0.4"
44
44
 
45
+ # Diff algorithm
46
+ similar = "2.4"
47
+
45
48
  # Lazy initialization
46
49
  lazy_static = "1.4"
47
50
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linthis
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -16,9 +16,9 @@ Author: zhlinh
16
16
  License: MIT
17
17
  Requires-Python: >=3.8
18
18
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
19
- Project-URL: Repository, https://github.com/zhlinh/linthis
20
- Project-URL: Homepage, https://github.com/zhlinh/linthis
21
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
22
 
23
23
  # linthis
24
24
 
@@ -76,14 +76,17 @@ linthis init
76
76
  # Create global configuration file
77
77
  linthis init -g
78
78
 
79
- # Initialize with pre-commit hooks
80
- linthis init --hook prek
81
- linthis init --hook pre-commit
82
- linthis init --hook git
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
83
86
 
84
87
  # Force overwrite existing files
85
88
  linthis init --force
86
- linthis init --hook prek -f
89
+ linthis init --hook-type prek -f
87
90
  ```
88
91
 
89
92
  ### Basic Usage
@@ -149,15 +152,16 @@ linthis plugin add --global <alias> <git-url>
149
152
 
150
153
  ### Use Plugin
151
154
 
155
+ Plugins are automatically loaded when running linthis. After adding a plugin:
156
+
152
157
  ```bash
153
- # Use plugin configuration for linting and formatting
154
- linthis -p myplugin
155
- linthis --plugin myplugin
158
+ # Plugin configs are auto-loaded
159
+ linthis
156
160
 
157
161
  # Combine with other options
158
- linthis -p myplugin -l python -i src/
159
- linthis --plugin myplugin --check-only
160
- linthis --plugin myplugin --staged
162
+ linthis -l python -i src/
163
+ linthis --check-only
164
+ linthis --staged
161
165
  ```
162
166
 
163
167
  ### Remove Plugin
@@ -185,8 +189,9 @@ linthis plugin list
185
189
  linthis plugin list -g
186
190
  linthis plugin list --global
187
191
 
188
- # Update plugin cache
189
- linthis --plugin-update
192
+ # Sync (update) plugins
193
+ linthis plugin sync # Sync local plugins
194
+ linthis plugin sync --global # Sync global plugins
190
195
 
191
196
  # Initialize new plugin
192
197
  linthis plugin init my-config
@@ -424,7 +429,6 @@ All modifications preserve TOML file format and comments.
424
429
  | ----- | ----------------------- | ---------------------------------------- | ----------------------- |
425
430
  | `-i` | `--include` | Specify files or directories to check | `-i src -i lib` |
426
431
  | `-e` | `--exclude` | Exclude patterns (can be used multiple times) | `-e "*.test.js"` |
427
- | `-p` | `--plugin` | Use plugin (alias or Git URL) | `-p myplugin` |
428
432
  | `-c` | `--check-only` | Check only, no formatting | `-c` |
429
433
  | `-f` | `--format-only` | Format only, no checking | `-f` |
430
434
  | `-s` | `--staged` | Check only Git staged files | `-s` |
@@ -435,9 +439,9 @@ All modifications preserve TOML file format and comments.
435
439
  | | `--config` | Specify config file path | `--config custom.toml` |
436
440
  | | `--init` | Initialize .linthis.toml config file | `--init` |
437
441
  | | `--preset` | Format preset | `--preset google` |
438
- | | `--plugin-update` | Force update plugin cache | `--plugin-update` |
439
442
  | | `--no-default-excludes` | Disable default exclude rules | `--no-default-excludes` |
440
443
  | | `--no-gitignore` | Disable .gitignore rules | `--no-gitignore` |
444
+ | | `--no-plugin` | Skip loading plugins, use default config | `--no-plugin` |
441
445
 
442
446
  ### Plugin Management Subcommands
443
447
 
@@ -506,7 +510,45 @@ All modifications preserve TOML file format and comments.
506
510
 
507
511
  ### Pre-commit Hook
508
512
 
509
- #### Method 1: Using prek (Recommended, Faster)
513
+ #### Method 1: Global Hook Template (One-time Setup)
514
+
515
+ Set up a global Git hook template that applies to all new repositories:
516
+
517
+ ```bash
518
+ # Create global hook template
519
+ linthis init -g --hook-type git
520
+
521
+ # All new repos will automatically include the hook
522
+ git init new-project
523
+ cd new-project
524
+ # .git/hooks/pre-commit is already set up!
525
+ ```
526
+
527
+ For existing repositories:
528
+ ```bash
529
+ cd existing-project
530
+ git init # Re-apply template
531
+ ```
532
+
533
+ **Features:**
534
+ - 🎯 **Smart Detection**: Only runs if project has linthis config
535
+ - 🔗 **Hook Chaining**: Supports `.git/hooks/pre-commit.local` for project-specific hooks
536
+ - 🚫 **Zero Interference**: Projects without linthis config are not affected
537
+ - ⚡ **One-time Setup**: Works for all your new repositories
538
+
539
+ **Pros:**
540
+ - One-time setup for all your projects
541
+ - No need to configure hooks per project
542
+ - Perfect for personal development
543
+ - Won't interfere with other projects or hook tools
544
+
545
+ **Cons:**
546
+ - Not shared with team members
547
+ - Requires manual setup on each machine
548
+
549
+ See [Global Hooks Guide](docs/GLOBAL_HOOKS.md) for details.
550
+
551
+ #### Method 2: Using prek (Recommended for Teams)
510
552
 
511
553
  [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.
512
554
 
@@ -540,7 +582,7 @@ Install hook:
540
582
  prek install
541
583
  ```
542
584
 
543
- #### Method 2: Traditional Git Hook
585
+ #### Method 3: Traditional Git Hook (Project-level)
544
586
 
545
587
  Add to `.git/hooks/pre-commit`:
546
588
 
@@ -549,7 +591,12 @@ Add to `.git/hooks/pre-commit`:
549
591
  linthis --staged --check-only
550
592
  ```
551
593
 
552
- #### Method 3: Using pre-commit Framework
594
+ Or use linthis to create it automatically:
595
+ ```bash
596
+ linthis init --hook-type git
597
+ ```
598
+
599
+ #### Method 4: Using pre-commit Framework
553
600
 
554
601
  Using the [pre-commit](https://pre-commit.com/) framework:
555
602
 
@@ -649,7 +696,7 @@ git push -u origin main
649
696
 
650
697
  ```bash
651
698
  linthis plugin add company https://github.com/mycompany/linthis-standards.git
652
- linthis --plugin company
699
+ linthis # Plugin configs are auto-loaded
653
700
  ```
654
701
 
655
702
  ## FAQ
@@ -675,7 +722,8 @@ linthis -l python # Only check Python files
675
722
  ### Q: How to update plugins?
676
723
 
677
724
  ```bash
678
- linthis --plugin-update
725
+ linthis plugin sync # Sync local plugins
726
+ linthis plugin sync --global # Sync global plugins
679
727
  ```
680
728
 
681
729
  ### Q: What is the plugin Git reference (ref) used for?
@@ -54,14 +54,17 @@ linthis init
54
54
  # Create global configuration file
55
55
  linthis init -g
56
56
 
57
- # Initialize with pre-commit hooks
58
- linthis init --hook prek
59
- linthis init --hook pre-commit
60
- linthis init --hook git
57
+ # Create global git hook template (for all new repos)
58
+ linthis init -g --hook-type git
59
+
60
+ # Initialize with pre-commit hooks (project-level)
61
+ linthis init --hook-type prek
62
+ linthis init --hook-type pre-commit
63
+ linthis init --hook-type git
61
64
 
62
65
  # Force overwrite existing files
63
66
  linthis init --force
64
- linthis init --hook prek -f
67
+ linthis init --hook-type prek -f
65
68
  ```
66
69
 
67
70
  ### Basic Usage
@@ -127,15 +130,16 @@ linthis plugin add --global <alias> <git-url>
127
130
 
128
131
  ### Use Plugin
129
132
 
133
+ Plugins are automatically loaded when running linthis. After adding a plugin:
134
+
130
135
  ```bash
131
- # Use plugin configuration for linting and formatting
132
- linthis -p myplugin
133
- linthis --plugin myplugin
136
+ # Plugin configs are auto-loaded
137
+ linthis
134
138
 
135
139
  # Combine with other options
136
- linthis -p myplugin -l python -i src/
137
- linthis --plugin myplugin --check-only
138
- linthis --plugin myplugin --staged
140
+ linthis -l python -i src/
141
+ linthis --check-only
142
+ linthis --staged
139
143
  ```
140
144
 
141
145
  ### Remove Plugin
@@ -163,8 +167,9 @@ linthis plugin list
163
167
  linthis plugin list -g
164
168
  linthis plugin list --global
165
169
 
166
- # Update plugin cache
167
- linthis --plugin-update
170
+ # Sync (update) plugins
171
+ linthis plugin sync # Sync local plugins
172
+ linthis plugin sync --global # Sync global plugins
168
173
 
169
174
  # Initialize new plugin
170
175
  linthis plugin init my-config
@@ -402,7 +407,6 @@ All modifications preserve TOML file format and comments.
402
407
  | ----- | ----------------------- | ---------------------------------------- | ----------------------- |
403
408
  | `-i` | `--include` | Specify files or directories to check | `-i src -i lib` |
404
409
  | `-e` | `--exclude` | Exclude patterns (can be used multiple times) | `-e "*.test.js"` |
405
- | `-p` | `--plugin` | Use plugin (alias or Git URL) | `-p myplugin` |
406
410
  | `-c` | `--check-only` | Check only, no formatting | `-c` |
407
411
  | `-f` | `--format-only` | Format only, no checking | `-f` |
408
412
  | `-s` | `--staged` | Check only Git staged files | `-s` |
@@ -413,9 +417,9 @@ All modifications preserve TOML file format and comments.
413
417
  | | `--config` | Specify config file path | `--config custom.toml` |
414
418
  | | `--init` | Initialize .linthis.toml config file | `--init` |
415
419
  | | `--preset` | Format preset | `--preset google` |
416
- | | `--plugin-update` | Force update plugin cache | `--plugin-update` |
417
420
  | | `--no-default-excludes` | Disable default exclude rules | `--no-default-excludes` |
418
421
  | | `--no-gitignore` | Disable .gitignore rules | `--no-gitignore` |
422
+ | | `--no-plugin` | Skip loading plugins, use default config | `--no-plugin` |
419
423
 
420
424
  ### Plugin Management Subcommands
421
425
 
@@ -484,7 +488,45 @@ All modifications preserve TOML file format and comments.
484
488
 
485
489
  ### Pre-commit Hook
486
490
 
487
- #### Method 1: Using prek (Recommended, Faster)
491
+ #### Method 1: Global Hook Template (One-time Setup)
492
+
493
+ Set up a global Git hook template that applies to all new repositories:
494
+
495
+ ```bash
496
+ # Create global hook template
497
+ linthis init -g --hook-type git
498
+
499
+ # All new repos will automatically include the hook
500
+ git init new-project
501
+ cd new-project
502
+ # .git/hooks/pre-commit is already set up!
503
+ ```
504
+
505
+ For existing repositories:
506
+ ```bash
507
+ cd existing-project
508
+ git init # Re-apply template
509
+ ```
510
+
511
+ **Features:**
512
+ - 🎯 **Smart Detection**: Only runs if project has linthis config
513
+ - 🔗 **Hook Chaining**: Supports `.git/hooks/pre-commit.local` for project-specific hooks
514
+ - 🚫 **Zero Interference**: Projects without linthis config are not affected
515
+ - ⚡ **One-time Setup**: Works for all your new repositories
516
+
517
+ **Pros:**
518
+ - One-time setup for all your projects
519
+ - No need to configure hooks per project
520
+ - Perfect for personal development
521
+ - Won't interfere with other projects or hook tools
522
+
523
+ **Cons:**
524
+ - Not shared with team members
525
+ - Requires manual setup on each machine
526
+
527
+ See [Global Hooks Guide](docs/GLOBAL_HOOKS.md) for details.
528
+
529
+ #### Method 2: Using prek (Recommended for Teams)
488
530
 
489
531
  [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.
490
532
 
@@ -518,7 +560,7 @@ Install hook:
518
560
  prek install
519
561
  ```
520
562
 
521
- #### Method 2: Traditional Git Hook
563
+ #### Method 3: Traditional Git Hook (Project-level)
522
564
 
523
565
  Add to `.git/hooks/pre-commit`:
524
566
 
@@ -527,7 +569,12 @@ Add to `.git/hooks/pre-commit`:
527
569
  linthis --staged --check-only
528
570
  ```
529
571
 
530
- #### Method 3: Using pre-commit Framework
572
+ Or use linthis to create it automatically:
573
+ ```bash
574
+ linthis init --hook-type git
575
+ ```
576
+
577
+ #### Method 4: Using pre-commit Framework
531
578
 
532
579
  Using the [pre-commit](https://pre-commit.com/) framework:
533
580
 
@@ -627,7 +674,7 @@ git push -u origin main
627
674
 
628
675
  ```bash
629
676
  linthis plugin add company https://github.com/mycompany/linthis-standards.git
630
- linthis --plugin company
677
+ linthis # Plugin configs are auto-loaded
631
678
  ```
632
679
 
633
680
  ## FAQ
@@ -653,7 +700,8 @@ linthis -l python # Only check Python files
653
700
  ### Q: How to update plugins?
654
701
 
655
702
  ```bash
656
- linthis --plugin-update
703
+ linthis plugin sync # Sync local plugins
704
+ linthis plugin sync --global # Sync global plugins
657
705
  ```
658
706
 
659
707
  ### Q: What is the plugin Git reference (ref) used for?