slim_lint 0.26.0 → 0.27.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4318d25d9325fb30a43a2db83a14aca0002c83960dc7edb0e8a5c87eaa59e64
|
4
|
+
data.tar.gz: 7ae359e3575cdae4293216064fc6a4bc0a07bd9d6ebb5b5688949634ae1ccbf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a03e56f04fefa1fc83f95356bcb2bbe5b13db122140aa34afda23809cfd1af6469bed95c681436f4ec7230deebf3b7f932cbbff21423eba88b61bd107006029
|
7
|
+
data.tar.gz: d59790c900df3af0486a8c4b636bf970ef9b35932e67342b3d9fb3b8a8dee779016fb0ab8d65ebcd1f9fadb26fa14149da771499159686bc665b0a56608b1774
|
data/config/default.yml
CHANGED
@@ -32,6 +32,12 @@ linters:
|
|
32
32
|
enabled: false
|
33
33
|
max: 300
|
34
34
|
|
35
|
+
InstanceVariables:
|
36
|
+
enabled: false
|
37
|
+
include:
|
38
|
+
# Include only partial templates by default
|
39
|
+
- app/views/**/_*.html.slim
|
40
|
+
|
35
41
|
LineLength:
|
36
42
|
enabled: true
|
37
43
|
max: 80
|
@@ -83,6 +89,12 @@ linters:
|
|
83
89
|
- Style/WhileUntilDo
|
84
90
|
- Style/WhileUntilModifier
|
85
91
|
|
92
|
+
StrictLocalsMissing:
|
93
|
+
enabled: false
|
94
|
+
include:
|
95
|
+
# Include only Rails partial templates by default
|
96
|
+
- app/views/**/_*.html.slim
|
97
|
+
|
86
98
|
Tab:
|
87
99
|
enabled: true
|
88
100
|
|
@@ -12,7 +12,7 @@ module SlimLint
|
|
12
12
|
dummy_node = Struct.new(:line)
|
13
13
|
document.source_lines.each_with_index do |line, index|
|
14
14
|
forbidden_engines.each do |forbidden_engine|
|
15
|
-
next unless line =~
|
15
|
+
next unless line =~ /^\s*#{forbidden_engine}.*:\s*$/
|
16
16
|
|
17
17
|
report_lint(dummy_node.new(index + 1), MESSAGE % forbidden_engine)
|
18
18
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SlimLint
|
4
|
+
# Searches for instance variables in partial or other templates.
|
5
|
+
class Linter::InstanceVariables < Linter
|
6
|
+
include LinterRegistry
|
7
|
+
|
8
|
+
on_start do |_sexp|
|
9
|
+
processed_sexp = SlimLint::RubyExtractEngine.new.call(document.source)
|
10
|
+
|
11
|
+
extractor = SlimLint::RubyExtractor.new
|
12
|
+
extracted_source = extractor.extract(processed_sexp)
|
13
|
+
next if extracted_source.source.empty?
|
14
|
+
|
15
|
+
parsed_ruby = parse_ruby(extracted_source.source)
|
16
|
+
next unless parsed_ruby
|
17
|
+
|
18
|
+
report_instance_variables(parsed_ruby, extracted_source.source_map)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def report_instance_variables(parsed_ruby, source_map)
|
24
|
+
parsed_ruby.each_node do |node|
|
25
|
+
next unless node.ivar_type?
|
26
|
+
|
27
|
+
dummy_node = Struct.new(:line)
|
28
|
+
report_lint(dummy_node.new(source_map[node.loc.line]),
|
29
|
+
'Avoid instance variables in the configured ' \
|
30
|
+
"view templates (found `#{node.source}`)")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SlimLint
|
4
|
+
# Reports on missing strict locals magic line in Slim templates.
|
5
|
+
class Linter::StrictLocalsMissing < Linter
|
6
|
+
include LinterRegistry
|
7
|
+
|
8
|
+
on_start do |_sexp|
|
9
|
+
unless document.source =~ %r{/#\s+locals:\s+\(.*\)}
|
10
|
+
dummy_node = Struct.new(:line)
|
11
|
+
report_lint(dummy_node.new(1), 'Strict locals magic line is missing')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01
|
11
|
+
date: 2024-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -114,9 +114,11 @@ files:
|
|
114
114
|
- lib/slim_lint/linter/empty_control_statement.rb
|
115
115
|
- lib/slim_lint/linter/empty_lines.rb
|
116
116
|
- lib/slim_lint/linter/file_length.rb
|
117
|
+
- lib/slim_lint/linter/instance_variables.rb
|
117
118
|
- lib/slim_lint/linter/line_length.rb
|
118
119
|
- lib/slim_lint/linter/redundant_div.rb
|
119
120
|
- lib/slim_lint/linter/rubocop.rb
|
121
|
+
- lib/slim_lint/linter/strict_locals_missing.rb
|
120
122
|
- lib/slim_lint/linter/tab.rb
|
121
123
|
- lib/slim_lint/linter/tag_case.rb
|
122
124
|
- lib/slim_lint/linter/trailing_blank_lines.rb
|
@@ -149,7 +151,7 @@ homepage: https://github.com/sds/slim-lint
|
|
149
151
|
licenses:
|
150
152
|
- MIT
|
151
153
|
metadata: {}
|
152
|
-
post_install_message:
|
154
|
+
post_install_message:
|
153
155
|
rdoc_options: []
|
154
156
|
require_paths:
|
155
157
|
- lib
|
@@ -164,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
166
|
- !ruby/object:Gem::Version
|
165
167
|
version: '0'
|
166
168
|
requirements: []
|
167
|
-
rubygems_version: 3.
|
168
|
-
signing_key:
|
169
|
+
rubygems_version: 3.0.3.1
|
170
|
+
signing_key:
|
169
171
|
specification_version: 4
|
170
172
|
summary: Slim template linting tool
|
171
173
|
test_files: []
|