slim_lint 0.32.0 → 0.32.2
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/lib/slim_lint/linter/quote_consistency.rb +16 -27
- data/lib/slim_lint/linter/rubocop.rb +11 -6
- data/lib/slim_lint/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd046a032cb7d554e447d0e2ef1a790ff22f163eb734450d330ab1fc769c575b
|
4
|
+
data.tar.gz: 676860f6eb8fce36a54d82efab06fbf38dab1a68139ce330dbd16b4cdc42d7d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d81d8c6bcc920c6d3c676da85d87d7c1792468428bfa3045af11bf45222ee70faf12d4d8383e30889453eb0f08d0fce7b43b65cb8ad7c1fadcd0da27ac4262b6
|
7
|
+
data.tar.gz: 887d73d3cec672e79987668bd733ae90a2c60d505b17ba6a7bcb7cf5ffcd71a43fbc5b501b2d51032945d4612baf7a85d57803a6e07c7c56af0e06f4425558bb
|
@@ -7,29 +7,22 @@ module SlimLint
|
|
7
7
|
|
8
8
|
MSG = 'Inconsistent quote style. %s'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
10
|
+
on [:html, :attrs] do |node|
|
11
|
+
line = document.source_lines[node.line - 1]
|
12
|
+
|
13
|
+
# Skip lines without any quotes
|
14
|
+
next unless line =~ /['"]/
|
15
|
+
|
16
|
+
# Find all quoted strings in attributes (ignoring nested quotes)
|
17
|
+
single_quotes = line.scan(/^(?:[^'"]*'[^'"]*'[^'"]*)?(?:[^'"]*)('[^'"]*')/)
|
18
|
+
double_quotes = line.scan(/^(?:[^'"]*'[^'"]*'[^'"]*)?(?:[^'"]*)("[^'"]*")/)
|
19
|
+
|
20
|
+
if enforced_style == :single_quotes && double_quotes.any?
|
21
|
+
report_lint(node,
|
22
|
+
format(MSG, "Use single quotes for attribute values (')"))
|
23
|
+
elsif enforced_style == :double_quotes && single_quotes.any?
|
24
|
+
report_lint(node,
|
25
|
+
format(MSG, 'Use double quotes for attribute values (")'))
|
33
26
|
end
|
34
27
|
end
|
35
28
|
|
@@ -38,9 +31,5 @@ module SlimLint
|
|
38
31
|
def enforced_style
|
39
32
|
config['enforced_style']&.to_sym || :single_quotes
|
40
33
|
end
|
41
|
-
|
42
|
-
def skip_ruby_lines
|
43
|
-
config.fetch('skip_ruby_lines', true)
|
44
|
-
end
|
45
34
|
end
|
46
35
|
end
|
@@ -11,6 +11,14 @@ module SlimLint
|
|
11
11
|
class Linter::RuboCop < Linter
|
12
12
|
include LinterRegistry
|
13
13
|
|
14
|
+
# Initializes a RuboCop linter with the specified configuration.
|
15
|
+
#
|
16
|
+
# @param config [Hash] configuration for this linter
|
17
|
+
def initialize(config)
|
18
|
+
super(config)
|
19
|
+
@rubocop = ::RuboCop::CLI.new
|
20
|
+
end
|
21
|
+
|
14
22
|
on_start do |_sexp|
|
15
23
|
processed_sexp = SlimLint::RubyExtractEngine.new.call(document.source)
|
16
24
|
|
@@ -31,22 +39,19 @@ module SlimLint
|
|
31
39
|
# @param source_map [Hash] map of Ruby code line numbers to original line
|
32
40
|
# numbers in the template
|
33
41
|
def find_lints(ruby, source_map)
|
34
|
-
rubocop = ::RuboCop::CLI.new
|
35
|
-
|
36
42
|
filename = document.file ? "#{document.file}.rb" : 'ruby_script.rb'
|
37
43
|
|
38
44
|
with_ruby_from_stdin(ruby) do
|
39
|
-
extract_lints_from_offenses(lint_file(
|
45
|
+
extract_lints_from_offenses(lint_file(filename), source_map)
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
43
49
|
# Defined so we can stub the results in tests
|
44
50
|
#
|
45
|
-
# @param rubocop [RuboCop::CLI]
|
46
51
|
# @param file [String]
|
47
52
|
# @return [Array<RuboCop::Cop::Offense>]
|
48
|
-
def lint_file(
|
49
|
-
rubocop.run(rubocop_flags << file)
|
53
|
+
def lint_file(file)
|
54
|
+
@rubocop.run(rubocop_flags << file)
|
50
55
|
OffenseCollector.offenses
|
51
56
|
end
|
52
57
|
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.32.
|
4
|
+
version: 0.32.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-06 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rexml
|