slim_lint 0.31.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81a5d5ae220cfdfdc7ea0c5104f6e693867a1812a18c5f82bcac920ebddd1046
4
- data.tar.gz: a41c4b53c23b75d230db2822506650ad283ac5008883087d71a79731c0550368
3
+ metadata.gz: 57f5ec1042e443a09867926172b5b5b0282902c520d178ab0082ef349b938df7
4
+ data.tar.gz: d8edb2714c4c68b4e58dfb4042d00209a0ac250ac669fdf4251f1a4574050f9c
5
5
  SHA512:
6
- metadata.gz: c8a830e1241026eab80c015c490dba08af7968d3932ca40a5a4349c888ac5a8209a47d8c4700e04f411827302bbbf8fe004a6529ec82989266e7cbc2bf60814b
7
- data.tar.gz: cf8da83da3a823bda67e767bba1cd9beeb76500982ca9b7156aba2e88331e5858e6bc34dcf199947fb8c857c2fddc3fb056d28adf453689189ca29d25ed8e525
6
+ metadata.gz: d7c4d11c784321cf40fc1dd5ed8174f14f41f352f7c826604b013a08eb2515cf05d84dffbc1eb9b0f53bd00b0fdd3bee3b0999a31bc25cd9a086d3d9799ce510
7
+ data.tar.gz: fe69df4001565d50098eb30239959733ea1abae9a816c36337b6ef4e4931a35a5cd7361ed88a84189eb2cd7f75f5083ad33f661d842502195b1282523121522e
data/config/default.yml CHANGED
@@ -115,5 +115,8 @@ linters:
115
115
  TrailingWhitespace:
116
116
  enabled: true
117
117
 
118
+ QuoteConsistency:
119
+ enabled: false
120
+
118
121
  Zwsp:
119
122
  enabled: false
@@ -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
- if super
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
@@ -4,6 +4,7 @@ require_relative '../ruby_extractor'
4
4
  require_relative '../ruby_extract_engine'
5
5
 
6
6
  require 'rubocop'
7
+ require 'stringio'
7
8
 
8
9
  module SlimLint
9
10
  # Runs RuboCop on Ruby code extracted from Slim templates.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module SlimLint
5
- VERSION = '0.31.0'
5
+ VERSION = '0.32.0'
6
6
  end
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.31.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: 2024-10-05 00:00:00.000000000 Z
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.5.9
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: []