slim_lint_standard 0.0.3.1 → 0.0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7056df39196b2bccca2e7df3c153d92505ea08782f13d0ca1988cd611515829
4
- data.tar.gz: 339d15ea51b1ea34bbaf6a6bb8288edbdf9a18068e0533ca3ab57b800310e0cf
3
+ metadata.gz: 020c7a7dd42f91e0463080ae9d45ecce0d3216ad317a12d76093678762bace4f
4
+ data.tar.gz: 9180c1ba47218144cb202ef1a8acb0a2966cc1a45e02337dd5fb9f97a940c89d
5
5
  SHA512:
6
- metadata.gz: c41c3179b1474bb5dee7d3c33ac45b20ab311622c5875860b6f2517cd718a6c850f8ec51ff6985a6870b2382da9d464409680ff407d11683bd13e95510c0f251
7
- data.tar.gz: d3f8749f8c6a8bdee6dda76fe55f9a13e899abe5cdfc84095bd42d329095355ded2fef7aa9c708392170be7d436fb1c1061ed310bcea9e8a6bfac9b9003caf82
6
+ metadata.gz: fb2df502ae13382a90efe4fbf26d58b8901b7a4e0f47da6ed25419ab48144816ab8e7fc5f2fc404838ba731a7d10684003ce74f6557501ba14dbe200642da7e1
7
+ data.tar.gz: 626cdfa7d36e80933d0f8e95266c3cf5421b8a28bf53f73a99e26afe8306aef35445e93a70f4a18e8fa2d39505e7043d9a1682b2c35e2ff8cfd002d7739a0a1a
data/config/default.yml CHANGED
@@ -47,6 +47,7 @@ linters:
47
47
 
48
48
  RedundantDiv:
49
49
  enabled: true
50
+ style: implicit
50
51
 
51
52
  RuboCop:
52
53
  enabled: false
@@ -7,15 +7,22 @@ module SlimLint
7
7
  include LinterRegistry
8
8
 
9
9
  SHORTCUT_ATTRS = %w[id class]
10
- MESSAGE = "`div` is redundant when %s attribute shortcut is present"
10
+ IMPLICIT_MESSAGE = "`div` is redundant when %s attribute shortcut is present"
11
+ EXPLICIT_MESSAGE = "explicit `div` is preferred over bare %s attribute"
11
12
 
12
- on [:html, :tag, "div", capture(:attrs, [:html, :attrs]), anything] do |sexp|
13
- _, _, name, value = captures[:attrs][2]
14
- next unless name
15
- next unless value[0] == :static
16
- next unless SHORTCUT_ATTRS.include?(name.value)
17
-
18
- report_lint(sexp[2], MESSAGE % name)
13
+ on [:html, :tag, capture(:tag, anything), capture(:attrs, [:html, :attrs]), anything] do |sexp|
14
+ case @config["style"]
15
+ when "implicit", :implicit
16
+ _, _, name, value = captures[:attrs][2]
17
+ next unless captures[:tag] == "div"
18
+ next unless name
19
+ next unless value[0] == :static
20
+ next unless SHORTCUT_ATTRS.include?(name.value)
21
+ report_lint(sexp[2], IMPLICIT_MESSAGE % name)
22
+ when "explicit", :explicit
23
+ next unless captures[:tag] == "." || captures[:tag] == "#"
24
+ report_lint(sexp[2], EXPLICIT_MESSAGE % captures[:tag])
25
+ end
19
26
  end
20
27
  end
21
28
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module SlimLint
5
- VERSION = "0.0.3.1"
5
+ VERSION = "0.0.3.3"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_lint_standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.1
4
+ version: 0.0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pieter van de Bruggen