slim_lint 0.22.1 → 0.24.0

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: 9bc1b16d2a34eeda71283419f8ff1bd26d83592c6f5b9492152627926a5e3d50
4
- data.tar.gz: 247b1033c44c469b17216a9c43235f7f0a65b6db4f945356656a9365f1bf0c75
3
+ metadata.gz: e50e0e7ca03f55bd42e692cc7875adab1d454bf9b2984f97e1b7140677bbc700
4
+ data.tar.gz: b5d93260c2f354cedac16577e8692c5202eb685e7532b511edfefd196a086e65
5
5
  SHA512:
6
- metadata.gz: 2bb2670dbf429ebac5ad95c9b3e9ddf03429c4bd7b87b215dbd44e19b2a7623533e6b03345b09f34f70936cf4ee5e2fd30cc21d049b4a44c9ca4f2a4b682fbf4
7
- data.tar.gz: 01f52b81335b8b19bddf47071d372a8913268c0610b9d87157154c4db8d517ab8c75b57c1b8cad32a038b5f6a24c5b3aaa4a46d3f93143cb97ec6b478e5fddc9
6
+ metadata.gz: 3a64584b6cda49797435f8e996a9ef448f75ab2f2956b2f6d94810d4a654178a7e35949a031af5d5bf543657916aaae9368a68e66942a02fd0619cab63c73521
7
+ data.tar.gz: 7846bf8dc4aef4a78e4406b9c661ac44823297f66c59cbd7d3b714cf51efa30b424350e0f017d1ebabb9348b8ae1569f302330efc66613cd07f70b1025929087
data/bin/slim-lint CHANGED
@@ -3,5 +3,5 @@
3
3
 
4
4
  require 'slim_lint/cli'
5
5
 
6
- logger = SlimLint::Logger.new(STDOUT)
6
+ logger = SlimLint::Logger.new($stdout)
7
7
  exit SlimLint::CLI.new(logger).run(ARGV)
data/config/default.yml CHANGED
@@ -94,3 +94,6 @@ linters:
94
94
 
95
95
  TrailingWhitespace:
96
96
  enabled: true
97
+
98
+ Zwsp:
99
+ enabled: false
@@ -67,7 +67,7 @@ module SlimLint
67
67
  # Second capture match --- or ... followed by optional whitespace
68
68
  # and newline. This matches the closing --- for the frontmatter.
69
69
  (---|\.\.\.)\s*$\n?/mx
70
- source = $POSTMATCH
70
+ source = ::Regexp.last_match.post_match
71
71
  end
72
72
 
73
73
  source
@@ -5,7 +5,7 @@ module SlimLint::Filters
5
5
  # variables and other cruft (which in the context of extracting Ruby code,
6
6
  # results in a lot of weird cops reported by RuboCop).
7
7
  class ControlProcessor < Slim::Filter
8
- BLOCK_RE = /\A(if|unless)\b|\bdo\s*(\|[^\|]*\|)?\s*$/
8
+ BLOCK_RE = /\A(if|unless)\b|\bdo\s*(\|[^|]*\|)?\s*$/
9
9
 
10
10
  # Handle control expression `[:slim, :control, code, content]`
11
11
  #
@@ -10,7 +10,7 @@ module SlimLint
10
10
  on [:html, :tag, anything, [],
11
11
  [:slim, :output, anything, capture(:ruby, anything)]] do |sexp|
12
12
  # Fetch original Slim code that contains an element with a control statement.
13
- line = document.source_lines[sexp.line() - 1]
13
+ line = document.source_lines[sexp.line - 1]
14
14
 
15
15
  # Remove any Ruby code, because our regexp below must not match inside Ruby.
16
16
  ruby = captures[:ruby]
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SlimLint
4
+ class Linter::Zwsp < Linter
5
+ include LinterRegistry
6
+
7
+ MSG = 'Remove zero-width space'
8
+
9
+ on_start do |_sexp|
10
+ dummy_node = Struct.new(:line)
11
+ document.source_lines.each_with_index do |line, index|
12
+ next unless line.include?("\u200b")
13
+
14
+ report_lint(dummy_node.new(index + 1), MSG)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -71,7 +71,7 @@ module SlimLint
71
71
  def disabled_lines
72
72
  @disabled_lines ||= begin
73
73
  currently_disabled = false
74
- @document.source_lines.each_with_index.reduce([]) do |lines, pair|
74
+ @document.source_lines.each_with_index.each_with_object([]) do |pair, lines|
75
75
  line = pair[0]
76
76
  line_number = pair[1] + 1
77
77
 
@@ -82,7 +82,6 @@ module SlimLint
82
82
  elsif currently_disabled
83
83
  lines << line_number
84
84
  end
85
- lines
86
85
  end
87
86
  end
88
87
  end
@@ -87,7 +87,7 @@ module SlimLint
87
87
  def run_cli(task_args)
88
88
  cli_args = ['--config', config] if config
89
89
 
90
- logger = quiet ? SlimLint::Logger.silent : SlimLint::Logger.new(STDOUT)
90
+ logger = quiet ? SlimLint::Logger.silent : SlimLint::Logger.new($stdout)
91
91
  result = SlimLint::CLI.new(logger).run(Array(cli_args) + files_to_lint(task_args))
92
92
 
93
93
  fail "#{SlimLint::APP_NAME} failed with exit code #{result}" unless result == 0
@@ -98,7 +98,7 @@ module SlimLint
98
98
  #
99
99
  # @param task_args [Rake::TaskArguments]
100
100
  def files_to_lint(task_args)
101
- # Note: we're abusing Rake's argument handling a bit here. We call the
101
+ # NOTE: we're abusing Rake's argument handling a bit here. We call the
102
102
  # first argument `files` but it's actually only the first file--we pull
103
103
  # the rest out of the `extras` from the task arguments. This is so we
104
104
  # can specify an arbitrary list of files separated by commas on the
@@ -2,7 +2,14 @@
2
2
 
3
3
  require 'rubocop'
4
4
  require 'rubocop/ast/builder'
5
- require 'parser/current'
5
+
6
+ def require_parser(path)
7
+ prev = $VERBOSE
8
+ $VERBOSE = nil
9
+ require "parser/#{path}"
10
+ ensure
11
+ $VERBOSE = prev
12
+ end
6
13
 
7
14
  module SlimLint
8
15
  # Parser for the Ruby language.
@@ -13,6 +20,7 @@ module SlimLint
13
20
  class RubyParser
14
21
  # Creates a reusable parser.
15
22
  def initialize
23
+ require_parser('current')
16
24
  @builder = ::RuboCop::AST::Builder.new
17
25
  @parser = ::Parser::CurrentRuby.new(@builder)
18
26
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module SlimLint
5
- VERSION = '0.22.1'
5
+ VERSION = '0.24.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.1
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-03 00:00:00.000000000 Z
11
+ date: 2023-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.78.0
19
+ version: '1.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 0.78.0
29
+ version: '1.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: slim
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -33,7 +39,7 @@ dependencies:
33
39
  version: '3.0'
34
40
  - - "<"
35
41
  - !ruby/object:Gem::Version
36
- version: '5.0'
42
+ version: '6.0'
37
43
  type: :runtime
38
44
  prerelease: false
39
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +49,7 @@ dependencies:
43
49
  version: '3.0'
44
50
  - - "<"
45
51
  - !ruby/object:Gem::Version
46
- version: '5.0'
52
+ version: '6.0'
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: pry
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -129,6 +135,7 @@ files:
129
135
  - lib/slim_lint/linter/tag_case.rb
130
136
  - lib/slim_lint/linter/trailing_blank_lines.rb
131
137
  - lib/slim_lint/linter/trailing_whitespace.rb
138
+ - lib/slim_lint/linter/zwsp.rb
132
139
  - lib/slim_lint/linter_registry.rb
133
140
  - lib/slim_lint/linter_selector.rb
134
141
  - lib/slim_lint/logger.rb
@@ -156,7 +163,7 @@ homepage: https://github.com/sds/slim-lint
156
163
  licenses:
157
164
  - MIT
158
165
  metadata: {}
159
- post_install_message:
166
+ post_install_message:
160
167
  rdoc_options: []
161
168
  require_paths:
162
169
  - lib
@@ -171,8 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
178
  - !ruby/object:Gem::Version
172
179
  version: '0'
173
180
  requirements: []
174
- rubygems_version: 3.1.4
175
- signing_key:
181
+ rubygems_version: 3.1.6
182
+ signing_key:
176
183
  specification_version: 4
177
184
  summary: Slim template linting tool
178
185
  test_files: []