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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 421010e9ed7767b1702afd3360fc90e3461ba2955a06d9757aa7377943b26d7e
4
- data.tar.gz: a8d4558c8407297f5470a7f50aae478f295b370a2af76f86118b24637a417de2
3
+ metadata.gz: 31efb24d1c4403b9325a23da3fcabce1be3e5cad7cf2f802c707911f966cfd16
4
+ data.tar.gz: 9a6a612f87175d77212f84c4062973ea7d6ceaf0a7c2b9dca9debe10020fd524
5
5
  SHA512:
6
- metadata.gz: c00c0b52e0da4421ad79a52981a47a7dc7c1d289ab7ecd2757a201dac54ed75ff09a4f1ec009e8c7c242635eb5f8231059e147bf4d7e62c46518f07ccff7c08a
7
- data.tar.gz: 4ec4bf36b000df7e2118f147e02507fa82a9a033c5bb656f35719616ed023ac89eec9e5b26ffa1a67ae642cde47d061e0e657ae9237afd0a520ed0b799364786
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
- load_options(args)
37
- @files = args.dup
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.default.merge(config)
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(DEFAULT_LINT_ALL_GLOB, Dir.pwd)
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, DEFAULT_LINT_ALL_GLOB)] : 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: true },
52
- ClosingErbTagIndent: { enabled: true },
53
- ExtraNewline: { enabled: true },
54
- FinalNewline: { enabled: true },
55
- NoJavascriptTagHelper: { enabled: true },
56
- ParserErrors: { enabled: true },
57
- RightTrim: { enabled: true },
58
- SelfClosingTag: { enabled: true },
59
- SpaceAroundErbTag: { enabled: true },
60
- SpaceIndentation: { enabled: true },
61
- SpaceInHtmlTag: { enabled: true },
62
- TrailingWhitespace: { enabled: true },
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ERBLint
4
- VERSION = '0.0.31'
4
+ VERSION = '0.0.32'
5
5
  end
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.31
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-01-22 00:00:00.000000000 Z
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.0
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.0
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: