erb_lint 0.0.28 → 0.0.29

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
- SHA1:
3
- metadata.gz: dd514242d6b7920461eeecfe6b2042abc1dbd879
4
- data.tar.gz: ad6e290ed5a2adce93c48d39da58df17d38a7a47
2
+ SHA256:
3
+ metadata.gz: e4a94b402b5b0e78c8597154a55807ab0cdab042b02aa105f8a84e7a800d1f78
4
+ data.tar.gz: 211323032036eee8cdc61c866d3d3049a80d8ddcf16c2e00795e8955dd8b112e
5
5
  SHA512:
6
- metadata.gz: ac08fba28282dfec1da5e078f4ddbcd42c26373947634789cd93d9f709a6c5e02f224c44fe72608c3d182630d9b0d39abd5fe181ca1d98695ed509f6e51dd9e2
7
- data.tar.gz: cef726250e669949e9f4150c30a58f5b77e1201d9149a7b5adf38b7d853b76ca3bc2204b5a516db0fddfde0e72fe9d9e4a3ab56cb853eee77468614791833d34
6
+ metadata.gz: 7721c096adf5dc25e919a1f233292d393bfb005c14bd90e4271a191313fefc5ee6c6e64d625c3f5bac39fccb5eeba42d6fd1cb64c99c069a03cf7c2a64d7fe1b
7
+ data.tar.gz: b7e7f1f7fbfab896f3ade2708cf873a19c05011b76be978df594326b47d999d27692a0afaeb9d296395a2dc09678ee4008fbf06abed8cad2c4901dad1a071152
data/exe/erblint CHANGED
@@ -6,4 +6,4 @@ $LOAD_PATH.unshift("#{__dir__}/../lib")
6
6
  require 'erb_lint/cli'
7
7
 
8
8
  cli = ERBLint::CLI.new
9
- exit cli.run
9
+ exit(cli.run)
data/lib/erb_lint/cli.rb CHANGED
@@ -67,27 +67,27 @@ module ERBLint
67
67
  if @stats.corrected > 0
68
68
  corrected_found_diff = @stats.found - @stats.corrected
69
69
  if corrected_found_diff > 0
70
- warn Rainbow(
70
+ warn(Rainbow(
71
71
  "#{@stats.corrected} error(s) corrected and #{corrected_found_diff} error(s) remaining in ERB files"
72
- ).red
72
+ ).red)
73
73
  else
74
74
  puts Rainbow("#{@stats.corrected} error(s) corrected in ERB files").green
75
75
  end
76
76
  elsif @stats.found > 0
77
- warn Rainbow("#{@stats.found} error(s) were found in ERB files").red
77
+ warn(Rainbow("#{@stats.found} error(s) were found in ERB files").red)
78
78
  else
79
79
  puts Rainbow("No errors were found in ERB files").green
80
80
  end
81
81
 
82
82
  @stats.found == 0
83
83
  rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, ExitWithFailure => e
84
- warn Rainbow(e.message).red
84
+ warn(Rainbow(e.message).red)
85
85
  false
86
86
  rescue ExitWithSuccess => e
87
87
  puts e.message
88
88
  true
89
89
  rescue => e
90
- warn Rainbow("#{e.class}: #{e.message}\n#{e.backtrace.join("\n")}").red
90
+ warn(Rainbow("#{e.class}: #{e.message}\n#{e.backtrace.join("\n")}").red)
91
91
  false
92
92
  end
93
93
 
@@ -146,7 +146,7 @@ module ERBLint
146
146
  config = RunnerConfig.new(file_loader.yaml(config_filename), file_loader)
147
147
  @config = RunnerConfig.default.merge(config)
148
148
  else
149
- warn Rainbow("#{config_filename} not found: using default config").yellow
149
+ warn(Rainbow("#{config_filename} not found: using default config").yellow)
150
150
  @config = RunnerConfig.default
151
151
  end
152
152
  @config.merge!(runner_config_override)
@@ -20,7 +20,7 @@ module ERBLint
20
20
  end
21
21
 
22
22
  property :enabled, accepts: [true, false], default: false, reader: :enabled?
23
- property :exclude, accepts: array_of?(String), default: []
23
+ property :exclude, accepts: array_of?(String), default: -> { [] }
24
24
 
25
25
  def initialize(config = {})
26
26
  config = config.dup.deep_stringify_keys
@@ -13,7 +13,7 @@ module ERBLint
13
13
 
14
14
  class ConfigSchema < LinterConfig
15
15
  property :allowed_types, accepts: array_of?(String),
16
- default: ['text/javascript']
16
+ default: -> { ['text/javascript'] }
17
17
  property :allow_blank, accepts: [true, false], default: true, reader: :allow_blank?
18
18
  property :disallow_inline_scripts, accepts: [true, false], default: false, reader: :disallow_inline_scripts?
19
19
  end
@@ -12,12 +12,12 @@ module ERBLint
12
12
  class RuleSet
13
13
  include SmartProperties
14
14
  property :suggestion, accepts: String, default: ''
15
- property :deprecated, accepts: LinterConfig.array_of?(String), default: []
15
+ property :deprecated, accepts: LinterConfig.array_of?(String), default: -> { [] }
16
16
  end
17
17
 
18
18
  class ConfigSchema < LinterConfig
19
19
  property :rule_set,
20
- default: [],
20
+ default: -> { [] },
21
21
  accepts: array_of?(RuleSet),
22
22
  converts: to_array_of(RuleSet)
23
23
  property :addendum, accepts: String
@@ -22,7 +22,7 @@ module ERBLint
22
22
  BLACK_LISTED_TEXT = Set.new(%w(&nbsp; &ensp; &emsp; &thinsp;))
23
23
 
24
24
  class ConfigSchema < LinterConfig
25
- property :corrector, accepts: Hash, required: false, default: {}
25
+ property :corrector, accepts: Hash, required: false, default: -> { {} }
26
26
  property :i18n_load_path, accepts: String, required: false, default: ''
27
27
  end
28
28
  self.config_schema = ConfigSchema
@@ -61,7 +61,7 @@ module ERBLint
61
61
 
62
62
  def autocorrect(processed_source, offense)
63
63
  string = offense.source_range.source
64
- return unless klass = load_corrector
64
+ return unless (klass = load_corrector)
65
65
  return unless string.strip.length > 1
66
66
  node = RuboCop::AST::StrNode.new(:str, [string])
67
67
  corrector = klass.new(node, processed_source.filename, corrector_i18n_load_path, offense.source_range)
@@ -13,7 +13,7 @@ module ERBLint
13
13
 
14
14
  class ConfigSchema < LinterConfig
15
15
  property :only, accepts: array_of?(String)
16
- property :rubocop_config, accepts: Hash, default: {}
16
+ property :rubocop_config, accepts: Hash, default: -> { {} }
17
17
  end
18
18
 
19
19
  self.config_schema = ConfigSchema
@@ -147,7 +147,7 @@ module ERBLint
147
147
  def base_configs(inherit_from)
148
148
  regex = URI::DEFAULT_PARSER.make_regexp(%w(http https))
149
149
  configs = Array(inherit_from).compact.map do |base_name|
150
- if base_name.match?(/\A#{regex}\z/)
150
+ if base_name =~ /\A#{regex}\z/
151
151
  RuboCop::ConfigLoader.load_file(RuboCop::RemoteConfig.new(base_name, Dir.pwd))
152
152
  else
153
153
  config_from_hash(@file_loader.yaml(base_name))
@@ -6,6 +6,11 @@ module ERBLint
6
6
  class SelfClosingTag < Linter
7
7
  include LinterRegistry
8
8
 
9
+ class ConfigSchema < LinterConfig
10
+ property :enforced_style, converts: :to_sym, accepts: [:always, :never], default: :never
11
+ end
12
+ self.config_schema = ConfigSchema
13
+
9
14
  SELF_CLOSING_TAGS = %w(
10
15
  area base br col command embed hr input keygen
11
16
  link menuitem meta param source track wbr img
@@ -20,16 +25,25 @@ module ERBLint
20
25
  start_solidus = tag_node.children.first
21
26
  add_offense(
22
27
  start_solidus.loc,
23
- "Tag `#{tag.name}` is self-closing, it must not start with `</`.",
28
+ "Tag `#{tag.name}` is a void element, it must not start with `</`.",
24
29
  ''
25
30
  )
26
31
  end
27
32
 
28
- next if tag.self_closing?
33
+ if @config.enforced_style == :always && !tag.self_closing?
34
+ add_offense(
35
+ tag_node.loc.end.offset(-1),
36
+ "Tag `#{tag.name}` is self-closing, it must end with `/>`.",
37
+ '/'
38
+ )
39
+ end
40
+
41
+ next unless @config.enforced_style == :never && tag.self_closing?
42
+ end_solidus = tag_node.children.last
29
43
  add_offense(
30
- tag_node.loc.end.offset(-1),
31
- "Tag `#{tag.name}` is self-closing, it must end with `/>`.",
32
- '/'
44
+ end_solidus.loc,
45
+ "Tag `#{tag.name}` is a void element, it must end with `>` and not `/>`.",
46
+ ''
33
47
  )
34
48
  end
35
49
  end
@@ -41,7 +41,7 @@ module ERBLint
41
41
  hash['inherit_from'] = Array(hash['inherit_from'])
42
42
  Array(config_path).reverse_each do |path|
43
43
  # Put gem configuration first so local configuration overrides it.
44
- hash['inherit_from'].unshift gem_config_path(gem_name, path)
44
+ hash['inherit_from'].unshift(gem_config_path(gem_name, path))
45
45
  end
46
46
  end
47
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ERBLint
4
- VERSION = '0.0.28'
4
+ VERSION = '0.0.29'
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.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Chan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: better_html
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.6.14
187
+ rubygems_version: 2.7.6
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: ERB lint tool