slim_lint 0.23.0 → 0.24.0
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 +4 -4
- data/bin/slim-lint +1 -1
- data/config/default.yml +3 -0
- data/lib/slim_lint/document.rb +1 -1
- data/lib/slim_lint/filters/control_processor.rb +1 -1
- data/lib/slim_lint/linter/control_statement_spacing.rb +1 -1
- data/lib/slim_lint/linter/zwsp.rb +1 -1
- data/lib/slim_lint/linter.rb +1 -2
- data/lib/slim_lint/rake_task.rb +2 -2
- data/lib/slim_lint/ruby_parser.rb +9 -1
- data/lib/slim_lint/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e50e0e7ca03f55bd42e692cc7875adab1d454bf9b2984f97e1b7140677bbc700
|
4
|
+
data.tar.gz: b5d93260c2f354cedac16577e8692c5202eb685e7532b511edfefd196a086e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a64584b6cda49797435f8e996a9ef448f75ab2f2956b2f6d94810d4a654178a7e35949a031af5d5bf543657916aaae9368a68e66942a02fd0619cab63c73521
|
7
|
+
data.tar.gz: 7846bf8dc4aef4a78e4406b9c661ac44823297f66c59cbd7d3b714cf51efa30b424350e0f017d1ebabb9348b8ae1569f302330efc66613cd07f70b1025929087
|
data/bin/slim-lint
CHANGED
data/config/default.yml
CHANGED
data/lib/slim_lint/document.rb
CHANGED
@@ -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 =
|
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*(\|[
|
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
|
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]
|
data/lib/slim_lint/linter.rb
CHANGED
@@ -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.
|
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
|
data/lib/slim_lint/rake_task.rb
CHANGED
@@ -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(
|
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
|
-
#
|
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
|
-
|
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
|
data/lib/slim_lint/version.rb
CHANGED
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.
|
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-
|
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:
|
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:
|
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
|