scss-lint 0.31.0 → 0.32.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/lib/scss_lint/cli.rb +13 -0
- data/lib/scss_lint/linter/bang_format.rb +3 -2
- data/lib/scss_lint/linter/selector_format.rb +7 -8
- data/lib/scss_lint/options.rb +5 -9
- data/lib/scss_lint/rake_task.rb +1 -4
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/linter/bang_format_spec.rb +12 -0
- data/spec/scss_lint/linter/space_before_brace_spec.rb +0 -2
- data/spec/scss_lint/options_spec.rb +1 -9
- data/spec/scss_lint/rake_task_spec.rb +20 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78eefba7814228e097ecd728f37ec53bd3a9c98b
|
4
|
+
data.tar.gz: 21356e0c75ed328ac007f0ae9841d0e30a434fbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 919f35cdcaa899ca549c87e549f653c89d0da5241bf45127d85ab89f9a76186df21432af47fc080827c7c9436aa915171aa70320faf859189d7ca051197d0c84
|
7
|
+
data.tar.gz: c29ec8826b699855207837b10ae2679707b599a5a1db8c06c5579f6631e989e385bf545453498f9ef37408602e11201ee6d3e9658f3998fa8b5557bf10b6c57d
|
data/lib/scss_lint/cli.rb
CHANGED
@@ -31,6 +31,7 @@ module SCSSLint
|
|
31
31
|
|
32
32
|
def act_on_options(options)
|
33
33
|
load_required_paths(options)
|
34
|
+
load_reporters(options)
|
34
35
|
|
35
36
|
if options[:help]
|
36
37
|
print_help(options)
|
@@ -176,6 +177,18 @@ module SCSSLint
|
|
176
177
|
end
|
177
178
|
end
|
178
179
|
|
180
|
+
def load_reporters(options)
|
181
|
+
options[:reporters].map! do |reporter_name, output_file|
|
182
|
+
begin
|
183
|
+
reporter = SCSSLint::Reporter.const_get(reporter_name + 'Reporter')
|
184
|
+
rescue NameError
|
185
|
+
raise SCSSLint::Exceptions::InvalidCLIOption,
|
186
|
+
"Invalid output format specified: #{reporter_name}"
|
187
|
+
end
|
188
|
+
[reporter, output_file]
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
179
192
|
def print_formatters
|
180
193
|
puts 'Installed formatters:'
|
181
194
|
|
@@ -3,6 +3,8 @@ module SCSSLint
|
|
3
3
|
class Linter::BangFormat < Linter
|
4
4
|
include LinterRegistry
|
5
5
|
|
6
|
+
STOPPING_CHARACTERS = ['!', "'", '"', nil]
|
7
|
+
|
6
8
|
def visit_prop(node)
|
7
9
|
return unless node.to_sass.include?('!')
|
8
10
|
return unless check_spacing(node)
|
@@ -21,9 +23,8 @@ module SCSSLint
|
|
21
23
|
# stop at quotation marks to protect against linting !'s within strings
|
22
24
|
# (e.g. `content`)
|
23
25
|
def find_bang_offset(range)
|
24
|
-
stopping_characters = ['!', '\'', '"']
|
25
26
|
offset = 0
|
26
|
-
offset -= 1 until
|
27
|
+
offset -= 1 until STOPPING_CHARACTERS.include?(character_at(range.end_pos, offset))
|
27
28
|
offset
|
28
29
|
end
|
29
30
|
|
@@ -37,29 +37,28 @@ module SCSSLint
|
|
37
37
|
return if @ignored_names.include?(name)
|
38
38
|
return unless violation = violated_convention(name, type)
|
39
39
|
|
40
|
-
add_lint(node, "Selector `#{name}`
|
41
|
-
"written #{violation[:explanation]}")
|
40
|
+
add_lint(node, "Selector `#{name}` #{violation[:explanation]}")
|
42
41
|
end
|
43
42
|
|
44
43
|
CONVENTIONS = {
|
45
44
|
'hyphenated_lowercase' => {
|
46
|
-
explanation: 'in lowercase with hyphens',
|
45
|
+
explanation: 'should be written in lowercase with hyphens',
|
47
46
|
validator: ->(name) { name !~ /[^\-a-z0-9]/ },
|
48
47
|
},
|
49
48
|
'snake_case' => {
|
50
|
-
explanation: 'in lowercase with underscores',
|
49
|
+
explanation: 'should be written in lowercase with underscores',
|
51
50
|
validator: ->(name) { name !~ /[^_a-z0-9]/ },
|
52
51
|
},
|
53
52
|
'camel_case' => {
|
54
|
-
explanation: '
|
53
|
+
explanation: 'should be written in camelCase format',
|
55
54
|
validator: ->(name) { name =~ /^[a-z][a-zA-Z0-9]*$/ },
|
56
55
|
},
|
57
56
|
'hyphenated_BEM' => {
|
58
|
-
explanation: 'in hyphenated BEM (Block Element Modifier) format',
|
57
|
+
explanation: 'should be written in hyphenated BEM (Block Element Modifier) format',
|
59
58
|
validator: ->(name) { name !~ /[A-Z]|-{3}|_{3}|[^_]_[^_]/ },
|
60
59
|
},
|
61
60
|
'BEM' => {
|
62
|
-
explanation: 'in BEM (Block Element Modifier) format',
|
61
|
+
explanation: 'should be written in BEM (Block Element Modifier) format',
|
63
62
|
validator: lambda do |name|
|
64
63
|
name =~ /
|
65
64
|
^[a-z]([-]?[a-z0-9]+)*
|
@@ -77,7 +76,7 @@ module SCSSLint
|
|
77
76
|
'hyphenated_lowercase'
|
78
77
|
|
79
78
|
convention = CONVENTIONS[convention_name] || {
|
80
|
-
explanation: "
|
79
|
+
explanation: "should match regex /#{convention_name}/",
|
81
80
|
validator: ->(name) { name =~ /#{convention_name}/ }
|
82
81
|
}
|
83
82
|
|
data/lib/scss_lint/options.rb
CHANGED
@@ -3,7 +3,7 @@ require 'optparse'
|
|
3
3
|
module SCSSLint
|
4
4
|
# Handles option parsing for the command line application.
|
5
5
|
class Options
|
6
|
-
DEFAULT_REPORTER = [
|
6
|
+
DEFAULT_REPORTER = ['Default', :stdout]
|
7
7
|
|
8
8
|
# Parses command line options into an options hash.
|
9
9
|
#
|
@@ -48,14 +48,10 @@ module SCSSLint
|
|
48
48
|
|
49
49
|
# @param format [String]
|
50
50
|
def define_output_format(format)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
rescue NameError
|
57
|
-
raise SCSSLint::Exceptions::InvalidCLIOption,
|
58
|
-
"Invalid output format specified: #{format}"
|
51
|
+
return if @options[:reporters] == [DEFAULT_REPORTER] && format == 'Default'
|
52
|
+
|
53
|
+
@options[:reporters].reject! { |i| i == DEFAULT_REPORTER }
|
54
|
+
@options[:reporters] << [format, :stdout]
|
59
55
|
end
|
60
56
|
|
61
57
|
def add_linter_options(parser)
|
data/lib/scss_lint/rake_task.rb
CHANGED
@@ -29,10 +29,7 @@ module SCSSLint
|
|
29
29
|
require 'scss_lint'
|
30
30
|
require 'scss_lint/cli'
|
31
31
|
|
32
|
-
CLI.new([])
|
33
|
-
cli.parse_arguments
|
34
|
-
cli.run
|
35
|
-
end
|
32
|
+
CLI.new.run([])
|
36
33
|
rescue SystemExit => ex
|
37
34
|
if ex.status == CLI::EXIT_CODES[:data]
|
38
35
|
abort('scss-lint found lints')
|
data/lib/scss_lint/version.rb
CHANGED
@@ -96,4 +96,16 @@ describe SCSSLint::Linter::BangFormat do
|
|
96
96
|
|
97
97
|
it { should_not report_lint }
|
98
98
|
end
|
99
|
+
|
100
|
+
context 'when !<word> is not followed by a semicolon' do
|
101
|
+
let(:css) { <<-CSS }
|
102
|
+
.class {
|
103
|
+
margin: 0 !important
|
104
|
+
}
|
105
|
+
CSS
|
106
|
+
|
107
|
+
it 'does not loop forever' do
|
108
|
+
subject.should_not report_lint
|
109
|
+
end
|
110
|
+
end
|
99
111
|
end
|
@@ -654,7 +654,6 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
|
|
654
654
|
end
|
655
655
|
|
656
656
|
context 'when using #{} interpolation' do
|
657
|
-
|
658
657
|
context 'and the `style` option is `space`' do
|
659
658
|
let(:css) { <<-CSS }
|
660
659
|
@mixin test-mixin($class, $prop, $pixels) {
|
@@ -769,7 +768,6 @@ describe SCSSLint::Linter::SpaceBeforeBrace do
|
|
769
768
|
|
770
769
|
it { should_not report_lint }
|
771
770
|
end
|
772
|
-
|
773
771
|
end
|
774
772
|
|
775
773
|
context 'when curly brace is on own line' do
|
@@ -15,7 +15,7 @@ describe SCSSLint::Options do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'specifies the DefaultReporter by default' do
|
18
|
-
subject[:reporters].first.should include
|
18
|
+
subject[:reporters].first.should include 'Default'
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'outputs to STDOUT' do
|
@@ -30,13 +30,5 @@ describe SCSSLint::Options do
|
|
30
30
|
expect { subject }.to raise_error SCSSLint::Exceptions::InvalidCLIOption
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
context 'when a non-existent reporter is specified' do
|
35
|
-
let(:args) { %w[--format NonExistentReporter] }
|
36
|
-
|
37
|
-
it 'raises an error' do
|
38
|
-
expect { subject }.to raise_error SCSSLint::Exceptions::InvalidCLIOption
|
39
|
-
end
|
40
|
-
end
|
41
33
|
end
|
42
34
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'scss_lint/rake_task'
|
3
|
+
|
4
|
+
describe SCSSLint::RakeTask do
|
5
|
+
before do
|
6
|
+
# Silence console output
|
7
|
+
STDOUT.stub(:write)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#run' do
|
11
|
+
subject do
|
12
|
+
SCSSLint::RakeTask.new
|
13
|
+
Rake::Task['scss_lint']
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns a successful exit code' do
|
17
|
+
expect(subject.invoke.first.call).to be_truthy
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scss-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Causes Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- spec/scss_lint/linter_spec.rb
|
208
208
|
- spec/scss_lint/location_spec.rb
|
209
209
|
- spec/scss_lint/options_spec.rb
|
210
|
+
- spec/scss_lint/rake_task_spec.rb
|
210
211
|
- spec/scss_lint/reporter/config_reporter_spec.rb
|
211
212
|
- spec/scss_lint/reporter/default_reporter_spec.rb
|
212
213
|
- spec/scss_lint/reporter/files_reporter_spec.rb
|
@@ -246,7 +247,6 @@ test_files:
|
|
246
247
|
- spec/scss_lint/cli_spec.rb
|
247
248
|
- spec/scss_lint/config_spec.rb
|
248
249
|
- spec/scss_lint/engine_spec.rb
|
249
|
-
- spec/scss_lint/linter/bang_format_spec.rb
|
250
250
|
- spec/scss_lint/linter/border_zero_spec.rb
|
251
251
|
- spec/scss_lint/linter/color_keyword_spec.rb
|
252
252
|
- spec/scss_lint/linter/comment_spec.rb
|
@@ -278,7 +278,6 @@ test_files:
|
|
278
278
|
- spec/scss_lint/linter/space_after_comma_spec.rb
|
279
279
|
- spec/scss_lint/linter/space_after_property_colon_spec.rb
|
280
280
|
- spec/scss_lint/linter/space_after_property_name_spec.rb
|
281
|
-
- spec/scss_lint/linter/space_before_brace_spec.rb
|
282
281
|
- spec/scss_lint/linter/space_between_parens_spec.rb
|
283
282
|
- spec/scss_lint/linter/string_quotes_spec.rb
|
284
283
|
- spec/scss_lint/linter/trailing_semicolon_spec.rb
|
@@ -291,9 +290,10 @@ test_files:
|
|
291
290
|
- spec/scss_lint/linter/zero_unit_spec.rb
|
292
291
|
- spec/scss_lint/linter/name_format_spec.rb
|
293
292
|
- spec/scss_lint/linter/empty_line_between_blocks_spec.rb
|
293
|
+
- spec/scss_lint/linter/bang_format_spec.rb
|
294
|
+
- spec/scss_lint/linter/space_before_brace_spec.rb
|
294
295
|
- spec/scss_lint/linter_registry_spec.rb
|
295
296
|
- spec/scss_lint/location_spec.rb
|
296
|
-
- spec/scss_lint/options_spec.rb
|
297
297
|
- spec/scss_lint/reporter/config_reporter_spec.rb
|
298
298
|
- spec/scss_lint/reporter/default_reporter_spec.rb
|
299
299
|
- spec/scss_lint/reporter/files_reporter_spec.rb
|
@@ -303,7 +303,9 @@ test_files:
|
|
303
303
|
- spec/scss_lint/runner_spec.rb
|
304
304
|
- spec/scss_lint/selector_visitor_spec.rb
|
305
305
|
- spec/scss_lint/linter_spec.rb
|
306
|
-
- spec/
|
306
|
+
- spec/scss_lint/rake_task_spec.rb
|
307
|
+
- spec/scss_lint/options_spec.rb
|
307
308
|
- spec/support/isolated_environment.rb
|
308
309
|
- spec/support/matchers/report_lint.rb
|
310
|
+
- spec/spec_helper.rb
|
309
311
|
has_rdoc:
|