slim_lint 0.31.1 → 0.32.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 +4 -4
- data/config/default.yml +3 -0
- data/lib/slim_lint/atom.rb +1 -5
- data/lib/slim_lint/linter/quote_consistency.rb +46 -0
- data/lib/slim_lint/version.rb +1 -1
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57f5ec1042e443a09867926172b5b5b0282902c520d178ab0082ef349b938df7
|
4
|
+
data.tar.gz: d8edb2714c4c68b4e58dfb4042d00209a0ac250ac669fdf4251f1a4574050f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7c4d11c784321cf40fc1dd5ed8174f14f41f352f7c826604b013a08eb2515cf05d84dffbc1eb9b0f53bd00b0fdd3bee3b0999a31bc25cd9a086d3d9799ce510
|
7
|
+
data.tar.gz: fe69df4001565d50098eb30239959733ea1abae9a816c36337b6ef4e4931a35a5cd7361ed88a84189eb2cd7f75f5083ad33f661d842502195b1282523121522e
|
data/config/default.yml
CHANGED
data/lib/slim_lint/atom.rb
CHANGED
@@ -88,11 +88,7 @@ module SlimLint
|
|
88
88
|
# @param include_private [Boolean]
|
89
89
|
# @return [Boolean]
|
90
90
|
def respond_to?(method_sym, include_private = false)
|
91
|
-
|
92
|
-
true
|
93
|
-
else
|
94
|
-
@value.respond_to?(method_sym, include_private)
|
95
|
-
end
|
91
|
+
super || @value.respond_to?(method_sym, include_private)
|
96
92
|
end
|
97
93
|
end
|
98
94
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SlimLint
|
4
|
+
# Checks for consistent quote usage in HTML attributes
|
5
|
+
class Linter::QuoteConsistency < Linter
|
6
|
+
include LinterRegistry
|
7
|
+
|
8
|
+
MSG = 'Inconsistent quote style. %s'
|
9
|
+
|
10
|
+
on_start do |_sexp|
|
11
|
+
dummy_node = Struct.new(:line)
|
12
|
+
document.source_lines.each_with_index do |line, index|
|
13
|
+
# Skip lines without any quotes
|
14
|
+
next unless line =~ /['"]/
|
15
|
+
|
16
|
+
# Skip comments
|
17
|
+
next if line =~ %r{^\s*(/{1,3})}
|
18
|
+
|
19
|
+
# Skip Ruby lines that RuboCop will check
|
20
|
+
next if skip_ruby_lines && line =~ /^\s*[=-]/
|
21
|
+
|
22
|
+
# Find all quoted strings in attributes (ignoring nested quotes)
|
23
|
+
single_quotes = line.scan(/^(?:[^'"]*'[^'"]*'[^'"]*)?(?:[^'"]*)('[^'"]*')/)
|
24
|
+
double_quotes = line.scan(/^(?:[^'"]*'[^'"]*'[^'"]*)?(?:[^'"]*)("[^'"]*")/)
|
25
|
+
|
26
|
+
if enforced_style == :single_quotes && double_quotes.any?
|
27
|
+
report_lint(dummy_node.new(index + 1),
|
28
|
+
format(MSG, "Use single quotes for attribute values (')"))
|
29
|
+
elsif enforced_style == :double_quotes && single_quotes.any?
|
30
|
+
report_lint(dummy_node.new(index + 1),
|
31
|
+
format(MSG, 'Use double quotes for attribute values (")'))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def enforced_style
|
39
|
+
config['enforced_style']&.to_sym || :single_quotes
|
40
|
+
end
|
41
|
+
|
42
|
+
def skip_ruby_lines
|
43
|
+
config.fetch('skip_ruby_lines', true)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rexml
|
@@ -130,6 +129,7 @@ files:
|
|
130
129
|
- lib/slim_lint/linter/file_length.rb
|
131
130
|
- lib/slim_lint/linter/instance_variables.rb
|
132
131
|
- lib/slim_lint/linter/line_length.rb
|
132
|
+
- lib/slim_lint/linter/quote_consistency.rb
|
133
133
|
- lib/slim_lint/linter/redundant_div.rb
|
134
134
|
- lib/slim_lint/linter/rubocop.rb
|
135
135
|
- lib/slim_lint/linter/strict_locals_missing.rb
|
@@ -168,7 +168,6 @@ homepage: https://github.com/sds/slim-lint
|
|
168
168
|
licenses:
|
169
169
|
- MIT
|
170
170
|
metadata: {}
|
171
|
-
post_install_message:
|
172
171
|
rdoc_options: []
|
173
172
|
require_paths:
|
174
173
|
- lib
|
@@ -183,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
182
|
- !ruby/object:Gem::Version
|
184
183
|
version: '0'
|
185
184
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
187
|
-
signing_key:
|
185
|
+
rubygems_version: 3.6.2
|
188
186
|
specification_version: 4
|
189
187
|
summary: Slim template linting tool
|
190
188
|
test_files: []
|