slim_lint_standard 0.0.1 → 0.0.2.1

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: 668e2943e3d0529d6b8899d5e2746466e2f5c1b180409ca12d2ab1ca041e1f5a
4
- data.tar.gz: 5ad56fadf5476d0acd2e80294f44fd9b753a2fffef59f0a46673e760ab07a99a
3
+ metadata.gz: 4947750dc5b81a693f803a3b34088318bcbcc75693fca82ad33b5ee28f242c9e
4
+ data.tar.gz: ba4bcc06286c6ffff6f3a5b165866bd767c965bf6adf8def6b0b7dda1e5bead0
5
5
  SHA512:
6
- metadata.gz: 8f202aca2e554ef4b45ce7f088e35f400154eb925eac32f7fa5e620d75c4f2a946e9129ebcd0e119fc4ea233037f8c158aaa687e0c2d7f57e2a7a2b38e9024a7
7
- data.tar.gz: 1a6e3d6b56d7f5b56a3eea7d9b4fc53fdf5e52da901c2e33ce2a448e80f274747da232c89ad937e3e880a95c4968bb5b784caa05b41159dbebb35f0b9346dc25
6
+ metadata.gz: 4972ca564b1bebc424bbc0e016dcf924d0e0a63a12673beb9d8130bb3c8b68cc3c99c3d18d30d06be4bbd4be495b9753649eb1e0bf18b23c6bd54b4a28d9e3aa
7
+ data.tar.gz: bd2b45d764b6283c4536828e6c9cde0bc30a1d9991c91f84be59b32b78fb4d91a4fdf38f9c09bf259edd9a2686faa76989937e85b9ca2601fc44d226d9af5477
@@ -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) if sexp[2] =~ /[#.]/
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.1"
5
+ VERSION = "0.0.2.1"
6
6
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_lint_standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2.1
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-16 00:00:00.000000000 Z
12
+ date: 2023-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slim
@@ -182,7 +182,7 @@ homepage: https://github.com/pvande/slim-lint-standard
182
182
  licenses:
183
183
  - MIT
184
184
  metadata: {}
185
- post_install_message:
185
+ post_install_message:
186
186
  rdoc_options: []
187
187
  require_paths:
188
188
  - lib
@@ -197,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  requirements: []
200
- rubygems_version: 3.0.3.1
201
- signing_key:
200
+ rubygems_version: 3.4.1
201
+ signing_key:
202
202
  specification_version: 4
203
203
  summary: Linter for Slim templates
204
204
  test_files: []