erb_lint 0.0.37 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/exe/erblint +1 -1
  3. data/lib/erb_lint/all.rb +26 -0
  4. data/lib/erb_lint/cli.rb +73 -24
  5. data/lib/erb_lint/corrector.rb +1 -1
  6. data/lib/erb_lint/linter.rb +5 -5
  7. data/lib/erb_lint/linter_config.rb +3 -3
  8. data/lib/erb_lint/linter_registry.rb +2 -2
  9. data/lib/erb_lint/linters/allowed_script_type.rb +7 -7
  10. data/lib/erb_lint/linters/closing_erb_tag_indent.rb +2 -2
  11. data/lib/erb_lint/linters/deprecated_classes.rb +7 -7
  12. data/lib/erb_lint/linters/erb_safety.rb +2 -2
  13. data/lib/erb_lint/linters/extra_newline.rb +1 -1
  14. data/lib/erb_lint/linters/final_newline.rb +2 -2
  15. data/lib/erb_lint/linters/hard_coded_string.rb +36 -16
  16. data/lib/erb_lint/linters/no_javascript_tag_helper.rb +8 -8
  17. data/lib/erb_lint/linters/partial_instance_variable.rb +23 -0
  18. data/lib/erb_lint/linters/require_input_autocomplete.rb +121 -0
  19. data/lib/erb_lint/linters/require_script_nonce.rb +92 -0
  20. data/lib/erb_lint/linters/right_trim.rb +1 -1
  21. data/lib/erb_lint/linters/rubocop.rb +11 -11
  22. data/lib/erb_lint/linters/rubocop_text.rb +1 -1
  23. data/lib/erb_lint/linters/self_closing_tag.rb +5 -7
  24. data/lib/erb_lint/linters/space_around_erb_tag.rb +5 -5
  25. data/lib/erb_lint/linters/space_in_html_tag.rb +6 -6
  26. data/lib/erb_lint/linters/space_indentation.rb +1 -1
  27. data/lib/erb_lint/linters/trailing_whitespace.rb +1 -1
  28. data/lib/erb_lint/offense.rb +7 -4
  29. data/lib/erb_lint/reporter.rb +2 -2
  30. data/lib/erb_lint/reporters/compact_reporter.rb +9 -3
  31. data/lib/erb_lint/reporters/json_reporter.rb +72 -0
  32. data/lib/erb_lint/reporters/multiline_reporter.rb +1 -1
  33. data/lib/erb_lint/runner.rb +1 -1
  34. data/lib/erb_lint/runner_config.rb +8 -7
  35. data/lib/erb_lint/runner_config_resolver.rb +4 -4
  36. data/lib/erb_lint/stats.rb +9 -6
  37. data/lib/erb_lint/utils/block_map.rb +2 -2
  38. data/lib/erb_lint/utils/offset_corrector.rb +1 -1
  39. data/lib/erb_lint/utils/ruby_to_erb.rb +5 -5
  40. data/lib/erb_lint/utils/severity_levels.rb +16 -0
  41. data/lib/erb_lint/version.rb +1 -1
  42. data/lib/erb_lint.rb +1 -24
  43. metadata +9 -3
@@ -9,10 +9,10 @@ module ERBLint
9
9
  def html_options_to_tag_attributes(hash_node)
10
10
  hash_node.children.map do |pair_node|
11
11
  key_node, value_node = *pair_node
12
- key = ruby_to_erb(key_node, '=') { |s| s.tr('_', '-') }
13
- value = ruby_to_erb(value_node, '=') { |s| escape_quote(s) }
14
- [key, "\"#{value}\""].join('=')
15
- end.join(' ')
12
+ key = ruby_to_erb(key_node, "=") { |s| s.tr("_", "-") }
13
+ value = ruby_to_erb(value_node, "=") { |s| escape_quote(s) }
14
+ [key, "\"#{value}\""].join("=")
15
+ end.join(" ")
16
16
  end
17
17
 
18
18
  def ruby_to_erb(node, indicator = nil, &block)
@@ -43,7 +43,7 @@ module ERBLint
43
43
  end
44
44
 
45
45
  def escape_quote(str)
46
- str.gsub('"', '"')
46
+ str.gsub('"', """)
47
47
  end
48
48
  end
49
49
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ERBLint
4
+ module Utils
5
+ module SeverityLevels
6
+ SEVERITY_NAMES = [:info, :refactor, :convention, :warning, :error, :fatal].freeze
7
+
8
+ SEVERITY_CODE_TABLE = { I: :info, R: :refactor, C: :convention,
9
+ W: :warning, E: :error, F: :fatal, }.freeze
10
+
11
+ def severity_level_for_name(name)
12
+ SEVERITY_NAMES.index(name || :error) + 1
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ERBLint
4
- VERSION = '0.0.37'
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/erb_lint.rb CHANGED
@@ -1,26 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rubocop'
4
-
5
- require 'erb_lint/corrector'
6
- require 'erb_lint/file_loader'
7
- require 'erb_lint/linter_config'
8
- require 'erb_lint/linter_registry'
9
- require 'erb_lint/linter'
10
- require 'erb_lint/offense'
11
- require 'erb_lint/processed_source'
12
- require 'erb_lint/runner_config'
13
- require 'erb_lint/runner'
14
- require 'erb_lint/version'
15
- require 'erb_lint/stats'
16
- require 'erb_lint/reporter'
17
-
18
- # Load linters
19
- Dir[File.expand_path('erb_lint/linters/**/*.rb', File.dirname(__FILE__))].each do |file|
20
- require file
21
- end
22
-
23
- # Load reporters
24
- Dir[File.expand_path('erb_lint/reporters/**/*.rb', File.dirname(__FILE__))].each do |file|
25
- require file
26
- end
3
+ require "erb_lint/version"
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.37
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Chan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-12 00:00:00.000000000 Z
11
+ date: 2021-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: better_html
@@ -160,6 +160,7 @@ extra_rdoc_files: []
160
160
  files:
161
161
  - exe/erblint
162
162
  - lib/erb_lint.rb
163
+ - lib/erb_lint/all.rb
163
164
  - lib/erb_lint/cli.rb
164
165
  - lib/erb_lint/corrector.rb
165
166
  - lib/erb_lint/file_loader.rb
@@ -175,6 +176,9 @@ files:
175
176
  - lib/erb_lint/linters/hard_coded_string.rb
176
177
  - lib/erb_lint/linters/no_javascript_tag_helper.rb
177
178
  - lib/erb_lint/linters/parser_errors.rb
179
+ - lib/erb_lint/linters/partial_instance_variable.rb
180
+ - lib/erb_lint/linters/require_input_autocomplete.rb
181
+ - lib/erb_lint/linters/require_script_nonce.rb
178
182
  - lib/erb_lint/linters/right_trim.rb
179
183
  - lib/erb_lint/linters/rubocop.rb
180
184
  - lib/erb_lint/linters/rubocop_text.rb
@@ -187,6 +191,7 @@ files:
187
191
  - lib/erb_lint/processed_source.rb
188
192
  - lib/erb_lint/reporter.rb
189
193
  - lib/erb_lint/reporters/compact_reporter.rb
194
+ - lib/erb_lint/reporters/json_reporter.rb
190
195
  - lib/erb_lint/reporters/multiline_reporter.rb
191
196
  - lib/erb_lint/runner.rb
192
197
  - lib/erb_lint/runner_config.rb
@@ -195,6 +200,7 @@ files:
195
200
  - lib/erb_lint/utils/block_map.rb
196
201
  - lib/erb_lint/utils/offset_corrector.rb
197
202
  - lib/erb_lint/utils/ruby_to_erb.rb
203
+ - lib/erb_lint/utils/severity_levels.rb
198
204
  - lib/erb_lint/version.rb
199
205
  homepage: https://github.com/Shopify/erb-lint
200
206
  licenses:
@@ -216,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
222
  - !ruby/object:Gem::Version
217
223
  version: '0'
218
224
  requirements: []
219
- rubygems_version: 3.0.3
225
+ rubygems_version: 3.2.20
220
226
  signing_key:
221
227
  specification_version: 4
222
228
  summary: ERB lint tool