slim_lint 0.23.0 → 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: 4d873940ddc504e1c78dc4ec1c1c7140a51ebc308294cd8083d3bde7bf7ee814
4
- data.tar.gz: d284de951c7ebf98448cdc49fab0ca54fa5c9b9cc6f6e0c731359b73a0ba64fa
3
+ metadata.gz: e50e0e7ca03f55bd42e692cc7875adab1d454bf9b2984f97e1b7140677bbc700
4
+ data.tar.gz: b5d93260c2f354cedac16577e8692c5202eb685e7532b511edfefd196a086e65
5
5
  SHA512:
6
- metadata.gz: 5147b5647239c39231529cc18cb397ac33fe1d6a07db58b33ddcda9924022e71cc24f3a4b7f91bf4795b668d031b8d65deb85dc5ee8869bca1237e18eb5af5a3
7
- data.tar.gz: 4afba73fe9d49dc124554b63bb230c1135c18288d377fb0ad9af098b418dec31d1524410c09dba6fb284fb1ab8e0742a06b04c97fdd850d04500e500d9ef57ac
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]
@@ -4,7 +4,7 @@ module SlimLint
4
4
  class Linter::Zwsp < Linter
5
5
  include LinterRegistry
6
6
 
7
- MSG = 'Remove Zwsp'
7
+ MSG = 'Remove zero-width space'
8
8
 
9
9
  on_start do |_sexp|
10
10
  dummy_node = Struct.new(:line)
@@ -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.23.0'
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.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-27 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