slim_lint_standard 0.0.0 → 0.0.2

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: 6dcf68f7cde5910a4f87dc7f7c1409976006ffde7a554601cb2ff0fad4240dad
4
- data.tar.gz: c1b6f4332831e572aa1f3adbb010a254ad752c222531849b2891cd740013a997
3
+ metadata.gz: 7422ae7eeeebc3038f016acae62c3f5486f5a5ca5469bbffe985c5f6a9144932
4
+ data.tar.gz: 6300d2ee64468e96adce1069c20dfe787d33e2a5f21cea76e1f3224453824284
5
5
  SHA512:
6
- metadata.gz: ef7ee3e8871a0eb7218a7994aefe7922411435c75f112ea85998cc9bfb3be4228ebb0bdf6ebc2ba8de308cad2c03975cbbbf2d65b6f1425998ee358e25ba5252
7
- data.tar.gz: acaf35418fea782e1e8f1fe1612c0a19668d90c6b3befa00afb638e1998a1b2baead8d32770a94ca2ee0e4c7e0d2077c123912bd684110decff3c58130e545a2
6
+ metadata.gz: 4c9db89471c2b872ed6dd18cd7d01cf621e6c0f44e609b899dec24da5be673fd2ed6b7defc0e3b14e972262cff7d8acad9b2b4dc8edca2494598d4b84dccd42e
7
+ data.tar.gz: 29d1e9c713db94a8e777e634086653033306ca53d8c0cdbc8b01f8ecf4ba0334294b76977823375ef9305e4012bab188048251beba2fb3a72e490667911ba6ff
@@ -1,21 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SlimLint
4
- # Checks for unnecessary uses of the `div` tag where a class name or ID
5
- # already implies a div.
4
+ # Checks for uses of the `div` tag where a class name or ID shortcut was used.
6
5
  class Linter::RedundantDiv < Linter
7
6
  include LinterRegistry
8
7
 
9
8
  SHORTCUT_ATTRS = %w[id class]
10
- MESSAGE = "`div` is redundant when %s attribute shortcut is present"
9
+ IMPLICIT_MESSAGE = "`div` is redundant when %s attribute shortcut is present"
10
+ EXPLICIT_MESSAGE = "Use an explicit `div` rather than a standalone %s attribute shortcut"
11
11
 
12
- on [:html, :tag, "div", capture(:attrs, [:html, :attrs]), anything] do |sexp|
12
+ on [:html, :tag, anything, capture(:attrs, [:html, :attrs]), anything] do |sexp|
13
13
  _, _, name, value = captures[:attrs][2]
14
14
  next unless name
15
15
  next unless value[0] == :static
16
16
  next unless SHORTCUT_ATTRS.include?(name.value)
17
17
 
18
- report_lint(sexp[2], MESSAGE % name)
18
+ case config["style"]
19
+ when "implicit", "never", false, nil
20
+ report_lint(sexp[2], IMPLICIT_MESSAGE % name) if sexp[2] == "div"
21
+ when "explicit", "always", true
22
+ report_lint(sexp[2], EXPLICIT_MESSAGE % name) unless sexp[2] == "div"
23
+ else
24
+ raise ArgumentError, "Unknown value for `style`; please use 'implicit' or 'explicit'"
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.0"
5
+ VERSION = "0.0.2"
6
6
  end
metadata CHANGED
@@ -1,30 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_lint_standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pieter van de Bruggen
8
8
  - Shane da Silva
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-12-15 00:00:00.000000000 Z
12
+ date: 2023-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rubocop
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: 0.78.0
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: 0.78.0
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: slim
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +182,7 @@ homepage: https://github.com/pvande/slim-lint-standard
196
182
  licenses:
197
183
  - MIT
198
184
  metadata: {}
199
- post_install_message:
185
+ post_install_message:
200
186
  rdoc_options: []
201
187
  require_paths:
202
188
  - lib
@@ -211,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
197
  - !ruby/object:Gem::Version
212
198
  version: '0'
213
199
  requirements: []
214
- rubygems_version: 3.0.3.1
215
- signing_key:
200
+ rubygems_version: 3.4.1
201
+ signing_key:
216
202
  specification_version: 4
217
203
  summary: Linter for Slim templates
218
204
  test_files: []