slim_lint 0.32.2 → 0.34.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3586e4fdad857cd9982603d97fd17acca434ef45caabe63ad6df523d1ca7ed76
|
|
4
|
+
data.tar.gz: 56bf2830ea686935a7ab26b6128fc4a3aa367ddb0de20a0ed6cbcd3f1b771338
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b8b60196d99f38fff022cd248b40bfbcd5ce7d0fd82ce2ff8eb3e1e1bdf1a7582537e7d4b2a2c9c9eb7713d0dc6f58a002e029889a11f69d76b7d0b61636d4c
|
|
7
|
+
data.tar.gz: 324ef5fbb06bf9b81134ff9fbf698bf02482f66ab0f42f10f2685f06524a6d2b1353310a5c9fe4feb001bffcd541c99036904bc4501f9af9607bf9cf6b68bbdc
|
data/lib/slim_lint/cli.rb
CHANGED
|
@@ -65,7 +65,7 @@ module SlimLint
|
|
|
65
65
|
# exception.
|
|
66
66
|
def handle_exception(exception)
|
|
67
67
|
case exception
|
|
68
|
-
when SlimLint::Exceptions::ConfigurationError
|
|
68
|
+
when SlimLint::Exceptions::ConfigurationError, SlimLint::NoSuchLinter
|
|
69
69
|
log.error exception.message
|
|
70
70
|
EX_CONFIG
|
|
71
71
|
when SlimLint::Exceptions::InvalidCLIOption
|
|
@@ -82,9 +82,25 @@ module SlimLint
|
|
|
82
82
|
def validate
|
|
83
83
|
ensure_exclude_option_array_exists
|
|
84
84
|
ensure_linter_section_exists
|
|
85
|
+
ensure_linter_names_are_valid
|
|
85
86
|
ensure_linter_include_exclude_arrays_exist
|
|
86
87
|
end
|
|
87
88
|
|
|
89
|
+
# Ensures all linter names in the configuration are valid.
|
|
90
|
+
def ensure_linter_names_are_valid
|
|
91
|
+
return if @hash['linters'].nil?
|
|
92
|
+
|
|
93
|
+
valid_names = SlimLint::LinterRegistry.linter_names
|
|
94
|
+
return if valid_names.empty? # Skip if linters not yet loaded
|
|
95
|
+
|
|
96
|
+
@hash['linters'].each_key do |linter_name|
|
|
97
|
+
next if valid_names.include?(linter_name)
|
|
98
|
+
|
|
99
|
+
raise SlimLint::NoSuchLinter,
|
|
100
|
+
"No such linter: #{linter_name}. Available: #{valid_names.join(', ')}"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
88
104
|
# Ensures the `exclude` global option is an array.
|
|
89
105
|
def ensure_exclude_option_array_exists
|
|
90
106
|
@hash['exclude'] = Array(@hash['exclude'])
|
|
@@ -5,7 +5,8 @@ module SlimLint
|
|
|
5
5
|
class Linter::ControlStatementSpacing < Linter
|
|
6
6
|
include LinterRegistry
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
MESSAGE_OUTPUT = 'Please add a space before and after the `=`'
|
|
9
|
+
MESSAGE_CONTROL = 'Please add a space after the `-`'
|
|
9
10
|
|
|
10
11
|
on [:html, :tag, anything, [],
|
|
11
12
|
[:slim, :output, anything, capture(:ruby, anything)]] do |sexp|
|
|
@@ -18,7 +19,15 @@ module SlimLint
|
|
|
18
19
|
|
|
19
20
|
next if line =~ /[^ ] ==?<?>? [^ ]/
|
|
20
21
|
|
|
21
|
-
report_lint(sexp,
|
|
22
|
+
report_lint(sexp, MESSAGE_OUTPUT)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
on [:slim, :control] do |sexp|
|
|
26
|
+
line = document.source_lines[sexp.line - 1]
|
|
27
|
+
|
|
28
|
+
next if line =~ /^ *- [^ ]/
|
|
29
|
+
|
|
30
|
+
report_lint(sexp, MESSAGE_CONTROL)
|
|
22
31
|
end
|
|
23
32
|
end
|
|
24
33
|
end
|
|
@@ -11,6 +11,13 @@ module SlimLint
|
|
|
11
11
|
# List of all registered linters.
|
|
12
12
|
attr_reader :linters
|
|
13
13
|
|
|
14
|
+
# Returns the short names of all registered linters.
|
|
15
|
+
#
|
|
16
|
+
# @return [Array<String>]
|
|
17
|
+
def linter_names
|
|
18
|
+
@linters.map { |linter| linter.name.split('::').last }
|
|
19
|
+
end
|
|
20
|
+
|
|
14
21
|
# Executed when a linter includes the {LinterRegistry} module.
|
|
15
22
|
#
|
|
16
23
|
# This results in the linter being registered with the registry.
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slim_lint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.34.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane da Silva
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rexml
|
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
182
182
|
- !ruby/object:Gem::Version
|
|
183
183
|
version: '0'
|
|
184
184
|
requirements: []
|
|
185
|
-
rubygems_version: 3.6.
|
|
185
|
+
rubygems_version: 3.6.9
|
|
186
186
|
specification_version: 4
|
|
187
187
|
summary: Slim template linting tool
|
|
188
188
|
test_files: []
|