erb_lint 0.0.31 → 0.0.32
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 -7
- data/lib/erb_lint/runner_config.rb +19 -13
- data/lib/erb_lint/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31efb24d1c4403b9325a23da3fcabce1be3e5cad7cf2f802c707911f966cfd16
|
4
|
+
data.tar.gz: 9a6a612f87175d77212f84c4062973ea7d6ceaf0a7c2b9dca9debe10020fd524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5fa4f3cb3051d6a30ffe2c9ff87770b40b224a5fb8dd000201846a613b42519a00e6a795082bc2dd055ef9e7aa88e92cecd7c365ca189bdbec6e9a41da32531
|
7
|
+
data.tar.gz: e9683a5db2457f4460a2eaed0e1c005dc98c33295ef554d77edf081e47503a4059537da75367ed5db31396a71547d8f0bf87c24f64c996ffc7c6b5c1f5fb6703
|
data/lib/erb_lint/cli.rb
CHANGED
@@ -33,8 +33,9 @@ module ERBLint
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def run(args = ARGV)
|
36
|
-
|
37
|
-
|
36
|
+
dupped_args = args.dup
|
37
|
+
load_options(dupped_args)
|
38
|
+
@files = dupped_args
|
38
39
|
|
39
40
|
load_config
|
40
41
|
|
@@ -149,14 +150,15 @@ module ERBLint
|
|
149
150
|
def load_config
|
150
151
|
if File.exist?(config_filename)
|
151
152
|
config = RunnerConfig.new(file_loader.yaml(config_filename), file_loader)
|
152
|
-
@config = RunnerConfig.
|
153
|
+
@config = RunnerConfig.default_for(config)
|
153
154
|
else
|
154
155
|
warn(Rainbow("#{config_filename} not found: using default config").yellow)
|
155
156
|
@config = RunnerConfig.default
|
156
157
|
end
|
157
|
-
@config.merge!(runner_config_override)
|
158
158
|
rescue Psych::SyntaxError => e
|
159
159
|
failure!("error parsing config: #{e.message}")
|
160
|
+
ensure
|
161
|
+
@config.merge!(runner_config_override)
|
160
162
|
end
|
161
163
|
|
162
164
|
def file_loader
|
@@ -170,11 +172,11 @@ module ERBLint
|
|
170
172
|
def lint_files
|
171
173
|
@lint_files ||=
|
172
174
|
if @options[:lint_all]
|
173
|
-
pattern = File.expand_path(
|
175
|
+
pattern = File.expand_path(glob, Dir.pwd)
|
174
176
|
Dir[pattern].select { |filename| !excluded?(filename) }
|
175
177
|
else
|
176
178
|
@files
|
177
|
-
.map { |f| Dir.exist?(f) ? Dir[File.join(f,
|
179
|
+
.map { |f| Dir.exist?(f) ? Dir[File.join(f, glob)] : f }
|
178
180
|
.map { |f| f.include?('*') ? Dir[f] : f }
|
179
181
|
.flatten
|
180
182
|
.map { |f| File.expand_path(f, Dir.pwd) }
|
@@ -182,6 +184,10 @@ module ERBLint
|
|
182
184
|
end
|
183
185
|
end
|
184
186
|
|
187
|
+
def glob
|
188
|
+
@config.to_hash["glob"] || DEFAULT_LINT_ALL_GLOB
|
189
|
+
end
|
190
|
+
|
185
191
|
def excluded?(filename)
|
186
192
|
@config.global_exclude.any? do |path|
|
187
193
|
File.fnmatch?(path, filename)
|
@@ -252,7 +258,7 @@ module ERBLint
|
|
252
258
|
end
|
253
259
|
end
|
254
260
|
|
255
|
-
opts.on("--lint-all", "Lint all files matching #{DEFAULT_LINT_ALL_GLOB}") do |config|
|
261
|
+
opts.on("--lint-all", "Lint all files matching configured glob [default: #{DEFAULT_LINT_ALL_GLOB}]") do |config|
|
256
262
|
@options[:lint_all] = config
|
257
263
|
end
|
258
264
|
|
@@ -45,24 +45,30 @@ module ERBLint
|
|
45
45
|
end
|
46
46
|
|
47
47
|
class << self
|
48
|
-
def default
|
48
|
+
def default(default_enabled: nil)
|
49
|
+
default_enabled = default_enabled.nil? ? true : default_enabled
|
49
50
|
new(
|
50
51
|
linters: {
|
51
|
-
AllowedScriptType: { enabled:
|
52
|
-
ClosingErbTagIndent: { enabled:
|
53
|
-
ExtraNewline: { enabled:
|
54
|
-
FinalNewline: { enabled:
|
55
|
-
NoJavascriptTagHelper: { enabled:
|
56
|
-
ParserErrors: { enabled:
|
57
|
-
RightTrim: { enabled:
|
58
|
-
SelfClosingTag: { enabled:
|
59
|
-
SpaceAroundErbTag: { enabled:
|
60
|
-
SpaceIndentation: { enabled:
|
61
|
-
SpaceInHtmlTag: { enabled:
|
62
|
-
TrailingWhitespace: { enabled:
|
52
|
+
AllowedScriptType: { enabled: default_enabled },
|
53
|
+
ClosingErbTagIndent: { enabled: default_enabled },
|
54
|
+
ExtraNewline: { enabled: default_enabled },
|
55
|
+
FinalNewline: { enabled: default_enabled },
|
56
|
+
NoJavascriptTagHelper: { enabled: default_enabled },
|
57
|
+
ParserErrors: { enabled: default_enabled },
|
58
|
+
RightTrim: { enabled: default_enabled },
|
59
|
+
SelfClosingTag: { enabled: default_enabled },
|
60
|
+
SpaceAroundErbTag: { enabled: default_enabled },
|
61
|
+
SpaceIndentation: { enabled: default_enabled },
|
62
|
+
SpaceInHtmlTag: { enabled: default_enabled },
|
63
|
+
TrailingWhitespace: { enabled: default_enabled },
|
63
64
|
},
|
64
65
|
)
|
65
66
|
end
|
67
|
+
|
68
|
+
def default_for(config)
|
69
|
+
default_linters_enabled = config.to_hash.dig("EnableDefaultLinters")
|
70
|
+
default(default_enabled: default_linters_enabled).merge(config)
|
71
|
+
end
|
66
72
|
end
|
67
73
|
|
68
74
|
private
|
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.0.
|
4
|
+
version: 0.0.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Chan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: better_html
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.79
|
47
|
+
version: '0.79'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.79
|
54
|
+
version: '0.79'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activesupport
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,7 +167,8 @@ files:
|
|
167
167
|
homepage: https://github.com/Shopify/erb-lint
|
168
168
|
licenses:
|
169
169
|
- MIT
|
170
|
-
metadata:
|
170
|
+
metadata:
|
171
|
+
allowed_push_host: https://rubygems.org
|
171
172
|
post_install_message:
|
172
173
|
rdoc_options: []
|
173
174
|
require_paths:
|