erb_lint 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/erb_lint/cli.rb +13 -1
- data/lib/erb_lint/corrector.rb +1 -1
- data/lib/erb_lint/linters/rubocop.rb +6 -25
- data/lib/erb_lint/linters/rubocop_text.rb +1 -0
- data/lib/erb_lint/version.rb +1 -1
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f417b343f6b0b891bd095ba568b2d50e78bb7d619b637b3bf2d70f2607f990cc
|
4
|
+
data.tar.gz: 1c080ab44d8238ad32138babe65076626e82974a96a13a1f4041bf7b9568b6ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 407d4f4813eaef3b2247357e0af4373cf7511bd8162c5706bc951af05e8577a9584bd5d3dbd00d6dba98bb62aa9d5d58a36a2e484553f7e9ade6af3f95803881
|
7
|
+
data.tar.gz: 7e5fb9bdb8c0cd455279ef3a1c46df75704f6f53eea0ab2eb37b4ff2c5e8292a6ced137b0fbeb6e89c2382d5f1be3220d0e12c4889127cb6d430578f2dbe8945
|
data/lib/erb_lint/cli.rb
CHANGED
@@ -35,7 +35,11 @@ module ERBLint
|
|
35
35
|
load_config
|
36
36
|
|
37
37
|
if !@files.empty? && lint_files.empty?
|
38
|
-
|
38
|
+
if allow_no_files?
|
39
|
+
success!("no files found...\n")
|
40
|
+
else
|
41
|
+
failure!("no files found...\n")
|
42
|
+
end
|
39
43
|
elsif lint_files.empty?
|
40
44
|
failure!("no files found or given, specify files or config...\n#{option_parser}")
|
41
45
|
end
|
@@ -302,6 +306,10 @@ module ERBLint
|
|
302
306
|
@options[:autocorrect] = config
|
303
307
|
end
|
304
308
|
|
309
|
+
opts.on("--allow-no-files", "When no matching files found, exit successfully (default: false)") do |config|
|
310
|
+
@options[:allow_no_files] = config
|
311
|
+
end
|
312
|
+
|
305
313
|
opts.on(
|
306
314
|
"-sFILE",
|
307
315
|
"--stdin FILE",
|
@@ -333,5 +341,9 @@ module ERBLint
|
|
333
341
|
def stdin?
|
334
342
|
@options[:stdin].present?
|
335
343
|
end
|
344
|
+
|
345
|
+
def allow_no_files?
|
346
|
+
@options[:allow_no_files]
|
347
|
+
end
|
336
348
|
end
|
337
349
|
end
|
data/lib/erb_lint/corrector.rb
CHANGED
@@ -12,7 +12,7 @@ module ERBLint
|
|
12
12
|
|
13
13
|
def corrections
|
14
14
|
@corrections ||= @offenses.map do |offense|
|
15
|
-
offense.linter.autocorrect(@processed_source, offense)
|
15
|
+
offense.linter.autocorrect(@processed_source, offense) if offense.linter.class.support_autocorrect?
|
16
16
|
end.compact
|
17
17
|
end
|
18
18
|
|
@@ -13,6 +13,7 @@ module ERBLint
|
|
13
13
|
class ConfigSchema < LinterConfig
|
14
14
|
property :only, accepts: array_of?(String)
|
15
15
|
property :rubocop_config, accepts: Hash, default: -> { {} }
|
16
|
+
property :config_file_path, accepts: String
|
16
17
|
end
|
17
18
|
|
18
19
|
self.config_schema = ConfigSchema
|
@@ -24,7 +25,8 @@ module ERBLint
|
|
24
25
|
def initialize(file_loader, config)
|
25
26
|
super
|
26
27
|
@only_cops = @config.only
|
27
|
-
custom_config =
|
28
|
+
custom_config = config_from_path(@config.config_file_path) if @config.config_file_path
|
29
|
+
custom_config ||= config_from_hash(@config.rubocop_config)
|
28
30
|
@rubocop_config = ::RuboCop::ConfigLoader.merge_with_default(custom_config, "")
|
29
31
|
end
|
30
32
|
|
@@ -158,34 +160,13 @@ module ERBLint
|
|
158
160
|
end
|
159
161
|
|
160
162
|
def config_from_hash(hash)
|
161
|
-
inherit_from = hash&.delete("inherit_from")
|
162
|
-
resolve_inheritance(hash, inherit_from)
|
163
|
-
|
164
163
|
tempfile_from(".erblint-rubocop", hash.to_yaml) do |tempfile|
|
165
|
-
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def resolve_inheritance(hash, inherit_from)
|
170
|
-
base_configs(inherit_from)
|
171
|
-
.reverse_each do |base_config|
|
172
|
-
base_config.each do |k, v|
|
173
|
-
hash[k] = hash.key?(k) ? ::RuboCop::ConfigLoader.merge(v, hash[k]) : v if v.is_a?(Hash)
|
174
|
-
end
|
164
|
+
config_from_path(tempfile.path)
|
175
165
|
end
|
176
166
|
end
|
177
167
|
|
178
|
-
def
|
179
|
-
|
180
|
-
configs = Array(inherit_from).compact.map do |base_name|
|
181
|
-
if base_name =~ /\A#{regex}\z/
|
182
|
-
::RuboCop::ConfigLoader.load_file(::RuboCop::RemoteConfig.new(base_name, Dir.pwd))
|
183
|
-
else
|
184
|
-
config_from_hash(@file_loader.yaml(base_name))
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
configs.compact
|
168
|
+
def config_from_path(path)
|
169
|
+
::RuboCop::ConfigLoader.load_file(path)
|
189
170
|
end
|
190
171
|
|
191
172
|
def add_offense(rubocop_offense, offense_range, correction, offset, bound_range)
|
data/lib/erb_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erb_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Chan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -26,32 +26,18 @@ dependencies:
|
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: better_html
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.7
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.7
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: html_tokenizer
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
33
|
+
version: 2.0.1
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
40
|
+
version: 2.0.1
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: parser
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -215,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
201
|
requirements:
|
216
202
|
- - ">="
|
217
203
|
- !ruby/object:Gem::Version
|
218
|
-
version: 2.
|
204
|
+
version: 2.7.0
|
219
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
206
|
requirements:
|
221
207
|
- - ">="
|