guard-slimlint 2.0.0 → 2.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfb29b85e6e86adbf353fd8a8f7ebb7d4ddffc72f79d7015ccdc12927ae91ece
4
- data.tar.gz: 6d50a482ee6fad85b3d5474ab4a59a398e62e0fb8c42fbe0ffb997d1d9e056d3
3
+ metadata.gz: 47da81ec1db0fb4fa7809b0bd5403413f6572ab142508b9d8a979718f75aa873
4
+ data.tar.gz: a8309923aa75cd04905c61473d3e403c0ac9a0bc4e293a24aa1c8bc9ecd1d951
5
5
  SHA512:
6
- metadata.gz: 9e294839c1b05bf9bee7527b13d7847c99adf6b876ac21ca442ad63f74cde6badb216098af6604257e7d4d568f543b0fb0d8170e9ab2c456ce939ac3dcda2a93
7
- data.tar.gz: 4e40c7f1451eb500cafde4ad53798db37f6f8f114bde89cf1724215aaf698693fcc6b163acc16d2fe924e31522af38b8d5c5ecd3dfb697e68bcd10d6bfda37f3
6
+ metadata.gz: cd5617c218afc0f9bfcb3f9ef72b2b89fb3ca70d0ca108f7dce1d07ca8db921404aa8af7688cea10937747cdfcc8769087a74ed02a2d43bb84d6ae2cb4a2685f
7
+ data.tar.gz: 41a792aa16d6d22345126120c6df3bf5f0242271351d71f70b39f98ae1f77b1eecb664705e5468a016f8125b2176ecb2aa30ab77f75acfb61827403f355da26d
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.1.0] - 2026-09-14
10
+
11
+ ### Added
12
+
13
+ - `autocorrect:` option, default `false`, to automatically correct offences that
14
+ support it using `slim-lint -a`. Offences are corrected in-place on disk. If all
15
+ offences are corrected, the run succeeds cleanly.
16
+ - Non-boolean values passed to `autocorrect:`, `all_on_start:`, or `halt_on_fail:`
17
+ raise an `ArgumentError` on startup.
18
+
9
19
  ## [2.0.0] - 2026-09-07
10
20
 
11
21
  A behaviour release. The plugin still runs slim-lint as a subprocess, which
@@ -117,7 +127,8 @@ without changing the plugin's interface.
117
127
  - `all_on_start` is honoured, so the plugin no longer lints everything on
118
128
  startup when the option is disabled.
119
129
 
120
- [Unreleased]: https://github.com/mike927/guard-slimlint/compare/v2.0.0...HEAD
130
+ [Unreleased]: https://github.com/mike927/guard-slimlint/compare/v2.1.0...HEAD
131
+ [2.1.0]: https://github.com/mike927/guard-slimlint/compare/v2.0.0...v2.1.0
121
132
  [2.0.0]: https://github.com/mike927/guard-slimlint/compare/v1.4.0...v2.0.0
122
133
  [1.4.0]: https://github.com/mike927/guard-slimlint/compare/v1.3.2...v1.4.0
123
134
  [1.3.2]: https://github.com/mike927/guard-slimlint/compare/v1.3.1...v1.3.2
data/README.md CHANGED
@@ -55,9 +55,16 @@ end
55
55
  | `notify_on` | `:change` | When to send a desktop notification. One of `:change`, `:failure`, `:success`, `:both`, `:none`. |
56
56
  | `all_on_start` | `true` | Lint everything once when Guard starts. |
57
57
  | `halt_on_fail` | `true` | Tell Guard the task failed, so a group's `halt_on_fail` can stop the rest of it. |
58
+ | `autocorrect` | `false` | Automatically correct offences that support it using `slim-lint -a`. |
58
59
  | `cli` | none | Extra arguments passed straight to slim-lint. String or Array. |
59
60
 
60
- An unrecognised `notify_on` raises at startup rather than silently going quiet.
61
+ An unrecognised `notify_on` or non-boolean option raises at startup rather than silently going quiet.
62
+
63
+ ### Autocorrect
64
+
65
+ Setting `autocorrect: true` automatically runs `slim-lint -a`, fixing offences that support auto-correction directly on disk. If all offences in a file are corrected, slim-lint exits with status 0 and Guard reports success. If uncorrectable offences remain, slim-lint exits with status 65 and Guard reports the remaining offences.
66
+
67
+ Because auto-correction modifies files in-place, Guard's file listener detects the disk write and re-lints the now-clean template. The default `notify_on: :change` ensures this follow-up pass stays quiet and does not send duplicate desktop notifications.
61
68
 
62
69
  ### Notifications
63
70
 
@@ -2,6 +2,7 @@
2
2
  # notify_on: change (default), failure, success, both, none
3
3
  # all_on_start: true (default), false
4
4
  # halt_on_fail: true (default), false
5
+ # autocorrect: false (default), true
5
6
  # cli: extra arguments for slim-lint, e.g. '-c config/.slim-lint.yml'
6
7
  guard :slimlint, notify_on: :change do
7
8
  # Rails views. For a non-Rails project, watch wherever your templates live,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Guard
4
4
  class SlimLintVersion
5
- VERSION = '2.0.0'
5
+ VERSION = '2.1.0'
6
6
  end
7
7
  end
@@ -27,18 +27,21 @@ module Guard
27
27
  127 => 'slim-lint is not on PATH, check that the gem is installed'
28
28
  }.freeze
29
29
 
30
- attr_reader :notify_on, :all_on_start, :halt_on_fail, :cli
30
+ AUTOCORRECT_FLAGS = %w[-a --autocorrect --auto-correct -A --autocorrect-all].freeze
31
+
32
+ attr_reader :notify_on, :all_on_start, :halt_on_fail, :cli, :autocorrect
31
33
 
32
34
  def initialize(options = {})
33
35
  @notify_on = options.fetch(:notify_on, :change)
34
36
  @all_on_start = options.fetch(:all_on_start, true)
35
37
  @halt_on_fail = options.fetch(:halt_on_fail, true)
36
38
  @cli = options[:cli]
39
+ @autocorrect = options.fetch(:autocorrect, false)
37
40
  # Assume the project starts green, so a clean first run stays quiet
38
41
  # under :change instead of announcing that nothing is wrong.
39
42
  @last_success = true
40
43
 
41
- validate_notify_on!
44
+ validate_options!
42
45
  super
43
46
  end
44
47
 
@@ -60,6 +63,13 @@ module Guard
60
63
 
61
64
  private
62
65
 
66
+ def validate_options!
67
+ validate_notify_on!
68
+ validate_boolean!(:all_on_start, all_on_start)
69
+ validate_boolean!(:halt_on_fail, halt_on_fail)
70
+ validate_boolean!(:autocorrect, autocorrect)
71
+ end
72
+
63
73
  def validate_notify_on!
64
74
  return if NOTIFY_MODES.include?(notify_on)
65
75
 
@@ -68,6 +78,12 @@ module Guard
68
78
  "#{NOTIFY_MODES.map(&:inspect).join(', ')}"
69
79
  end
70
80
 
81
+ def validate_boolean!(name, value)
82
+ return if [true, false].include?(value)
83
+
84
+ raise ArgumentError, ":#{name} must be true or false, got #{value.inspect}"
85
+ end
86
+
71
87
  # The directories Guard was told to watch, so run_all honours a
72
88
  # `directories` line in the Guardfile instead of always sweeping the
73
89
  # whole project.
@@ -102,11 +118,14 @@ module Guard
102
118
  end
103
119
 
104
120
  def cli_args
105
- case cli
106
- when Array then cli.map(&:to_s)
107
- when String then cli.shellsplit
108
- else []
109
- end
121
+ args = case cli
122
+ when Array then cli.map(&:to_s)
123
+ when String then cli.shellsplit
124
+ else []
125
+ end
126
+
127
+ args.unshift('-a') if autocorrect && !args.intersect?(AUTOCORRECT_FLAGS)
128
+ args
110
129
  end
111
130
 
112
131
  def report_success
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-slimlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Gajowiak