scss_lint 0.41.0 → 0.42.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +21 -0
- data/config/default.yml +1 -0
- data/lib/scss_lint/cli.rb +0 -4
- data/lib/scss_lint/config.rb +1 -1
- data/lib/scss_lint/engine.rb +8 -2
- data/lib/scss_lint/exceptions.rb +0 -4
- data/lib/scss_lint/file_finder.rb +1 -8
- data/lib/scss_lint/linter.rb +3 -3
- data/lib/scss_lint/linter/color_variable.rb +20 -0
- data/lib/scss_lint/linter/else_placement.rb +1 -0
- data/lib/scss_lint/linter/import_path.rb +2 -2
- data/lib/scss_lint/linter/name_format.rb +1 -1
- data/lib/scss_lint/linter/space_after_comma.rb +11 -2
- data/lib/scss_lint/linter/space_around_operator.rb +115 -59
- data/lib/scss_lint/linter/trailing_semicolon.rb +17 -3
- data/lib/scss_lint/linter/url_format.rb +3 -3
- data/lib/scss_lint/linter/variable_for_property.rb +8 -0
- data/lib/scss_lint/linter/vendor_prefix.rb +1 -1
- data/lib/scss_lint/rake_task.rb +6 -1
- data/lib/scss_lint/runner.rb +2 -2
- data/lib/scss_lint/sass/tree.rb +1 -1
- data/lib/scss_lint/selector_visitor.rb +4 -4
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/cli_spec.rb +0 -12
- data/spec/scss_lint/file_finder_spec.rb +2 -6
- data/spec/scss_lint/linter/color_variable_spec.rb +41 -1
- data/spec/scss_lint/linter/space_after_comma_spec.rb +891 -153
- data/spec/scss_lint/linter/space_around_operator_spec.rb +25 -0
- data/spec/scss_lint/linter/trailing_semicolon_spec.rb +50 -0
- data/spec/scss_lint/linter/variable_for_property_spec.rb +10 -0
- data/spec/scss_lint/rake_task_spec.rb +59 -10
- data/spec/scss_lint/reporter/clean_files_reporter_spec.rb +2 -2
- data/spec/scss_lint/reporter/default_reporter_spec.rb +3 -3
- data/spec/scss_lint/reporter/files_reporter_spec.rb +1 -1
- metadata +3 -2
@@ -151,6 +151,30 @@ describe SCSSLint::Linter::SpaceAroundOperator do
|
|
151
151
|
it { should report_lint line: 2 }
|
152
152
|
end
|
153
153
|
|
154
|
+
context 'when a selector contains an interpolated infix operator, well spaced' do
|
155
|
+
let(:scss) { <<-SCSS }
|
156
|
+
@for $i from 1 through 25 {
|
157
|
+
.progress-bar[aria-valuenow="\#{$i / 25 * 100}"] {
|
158
|
+
opacity: 0;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
SCSS
|
162
|
+
|
163
|
+
it { should_not report_lint }
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'when a selector contains an interpolated infix operator, badly spaced' do
|
167
|
+
let(:scss) { <<-SCSS }
|
168
|
+
@for $i from 1 through 25 {
|
169
|
+
.progress-bar[aria-valuenow="\#{$i/25*100}"] {
|
170
|
+
opacity: 0;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
SCSS
|
174
|
+
|
175
|
+
it { should report_lint line: 2, count: 2 }
|
176
|
+
end
|
177
|
+
|
154
178
|
context 'when values with non-evaluated operations exist' do
|
155
179
|
let(:scss) { <<-SCSS }
|
156
180
|
$my-variable: 10px;
|
@@ -207,6 +231,7 @@ describe SCSSLint::Linter::SpaceAroundOperator do
|
|
207
231
|
it { should report_lint line: 6 }
|
208
232
|
end
|
209
233
|
end
|
234
|
+
|
210
235
|
context 'when one space is preferred' do
|
211
236
|
let(:style) { 'no_space' }
|
212
237
|
|
@@ -301,4 +301,54 @@ describe SCSSLint::Linter::TrailingSemicolon do
|
|
301
301
|
|
302
302
|
it { should_not report_lint }
|
303
303
|
end
|
304
|
+
|
305
|
+
context 'when variable declaration is followed by a comment and semicolon' do
|
306
|
+
let(:scss) { '$foo: bar // comment;' }
|
307
|
+
|
308
|
+
it { should report_lint }
|
309
|
+
end
|
310
|
+
|
311
|
+
context 'when a variable declaration contains parentheses' do
|
312
|
+
context 'and ends with a semicolon' do
|
313
|
+
let(:scss) { '$foo: ($expr);' }
|
314
|
+
|
315
|
+
it { should_not report_lint }
|
316
|
+
end
|
317
|
+
|
318
|
+
context 'and is missing a semicolon' do
|
319
|
+
let(:scss) { '$foo: ($expr)' }
|
320
|
+
|
321
|
+
it { should report_lint }
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
context 'when a variable declaration contains a multiline map' do
|
326
|
+
context 'with a trailing comma' do
|
327
|
+
context 'and ends with a semicolon' do
|
328
|
+
let(:scss) { "$foo: (\n one: 1,\ntwo: 2,\n);" }
|
329
|
+
|
330
|
+
it { should_not report_lint }
|
331
|
+
end
|
332
|
+
|
333
|
+
context 'and is missing a semicolon' do
|
334
|
+
let(:scss) { "$foo: (\n one: 1,\ntwo: 2,\n)" }
|
335
|
+
|
336
|
+
it { should report_lint }
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
context 'without a trailing comma' do
|
341
|
+
context 'and ends with a semicolon' do
|
342
|
+
let(:scss) { "$foo: (\n one: 1,\ntwo: 2\n);" }
|
343
|
+
|
344
|
+
it { should_not report_lint }
|
345
|
+
end
|
346
|
+
|
347
|
+
context 'and is missing a semicolon' do
|
348
|
+
let(:scss) { "$foo: (\n one: 1,\ntwo: 2\n)" }
|
349
|
+
|
350
|
+
it { should report_lint }
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
304
354
|
end
|
@@ -88,6 +88,16 @@ describe SCSSLint::Linter::VariableForProperty do
|
|
88
88
|
it { should report_lint line: 3 }
|
89
89
|
end
|
90
90
|
|
91
|
+
context 'when configured property value is used with !important' do
|
92
|
+
let(:scss) { <<-SCSS }
|
93
|
+
p {
|
94
|
+
color: $black !important;
|
95
|
+
}
|
96
|
+
SCSS
|
97
|
+
|
98
|
+
it { should_not report_lint }
|
99
|
+
end
|
100
|
+
|
91
101
|
context 'when property specifies `currentColor`' do
|
92
102
|
let(:scss) { <<-SCSS }
|
93
103
|
p {
|
@@ -3,14 +3,14 @@ require 'scss_lint/rake_task'
|
|
3
3
|
require 'tempfile'
|
4
4
|
|
5
5
|
describe SCSSLint::RakeTask do
|
6
|
-
before(:all) do
|
7
|
-
SCSSLint::RakeTask.new
|
8
|
-
end
|
9
|
-
|
10
6
|
before do
|
11
7
|
STDOUT.stub(:write) # Silence console output
|
12
8
|
end
|
13
9
|
|
10
|
+
after(:each) do
|
11
|
+
Rake::Task['scss_lint'].clear if Rake::Task.task_defined?('scss_lint')
|
12
|
+
end
|
13
|
+
|
14
14
|
let(:file) do
|
15
15
|
Tempfile.new(%w[scss-file .scss]).tap do |f|
|
16
16
|
f.write(scss)
|
@@ -25,19 +25,68 @@ describe SCSSLint::RakeTask do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
context '
|
28
|
+
context 'basic RakeTask' do
|
29
|
+
before(:each) do
|
30
|
+
SCSSLint::RakeTask.new
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when SCSS document is valid with no lints' do
|
34
|
+
let(:scss) { '' }
|
35
|
+
|
36
|
+
it 'does not call Kernel.exit' do
|
37
|
+
expect { run_task }.not_to raise_error
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when SCSS document is invalid' do
|
42
|
+
let(:scss) { '.class {' }
|
43
|
+
|
44
|
+
it 'calls Kernel.exit with the status code' do
|
45
|
+
expect { run_task }.to raise_error SystemExit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'configured RakeTask with a config file' do
|
29
51
|
let(:scss) { '' }
|
30
52
|
|
31
|
-
|
53
|
+
let(:config_file) do
|
54
|
+
config = Tempfile.new(%w[foo .yml])
|
55
|
+
config.write('')
|
56
|
+
config.close
|
57
|
+
config.path
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'passes config files to the CLI' do
|
61
|
+
SCSSLint::RakeTask.new.tap do |t|
|
62
|
+
t.config = config_file
|
63
|
+
end
|
64
|
+
|
65
|
+
cli = double(SCSSLint::CLI)
|
66
|
+
SCSSLint::CLI.should_receive(:new) { cli }
|
67
|
+
args = ['--config', config_file, file.path]
|
68
|
+
cli.should_receive(:run).with(args) { 0 }
|
69
|
+
|
32
70
|
expect { run_task }.not_to raise_error
|
33
71
|
end
|
34
72
|
end
|
35
73
|
|
36
|
-
context '
|
37
|
-
let(:scss) { '
|
74
|
+
context 'configured RakeTask with args' do
|
75
|
+
let(:scss) { '' }
|
76
|
+
|
77
|
+
it 'passes args to the CLI' do
|
78
|
+
formatter_args = ['--formatter', 'JSON']
|
79
|
+
|
80
|
+
SCSSLint::RakeTask.new.tap do |t|
|
81
|
+
t.args = formatter_args
|
82
|
+
end
|
38
83
|
|
39
|
-
|
40
|
-
|
84
|
+
cli = double(SCSSLint::CLI)
|
85
|
+
SCSSLint::CLI.should_receive(:new) { cli }
|
86
|
+
args = formatter_args + [file.path]
|
87
|
+
cli.should_receive(:run).with(args) { 0 }
|
88
|
+
|
89
|
+
expect { run_task }.not_to raise_error
|
41
90
|
end
|
42
91
|
end
|
43
92
|
end
|
@@ -45,13 +45,13 @@ describe SCSSLint::Reporter::CleanFilesReporter do
|
|
45
45
|
|
46
46
|
it 'prints the file for each lint' do
|
47
47
|
clean_files.each do |file|
|
48
|
-
subject.report_lints.scan(
|
48
|
+
subject.report_lints.scan(file).count.should == 1
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'does not print clean files' do
|
53
53
|
dirty_files.each do |file|
|
54
|
-
subject.report_lints.scan(
|
54
|
+
subject.report_lints.scan(file).count.should == 0
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -35,19 +35,19 @@ describe SCSSLint::Reporter::DefaultReporter do
|
|
35
35
|
|
36
36
|
it 'prints the filename for each lint' do
|
37
37
|
filenames.each do |filename|
|
38
|
-
subject.report_lints.scan(
|
38
|
+
subject.report_lints.scan(filename).count.should == 1
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'prints the line number for each lint' do
|
43
43
|
lines.each do |line|
|
44
|
-
subject.report_lints.scan(
|
44
|
+
subject.report_lints.scan(line.to_s).count.should == 1
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'prints the description for each lint' do
|
49
49
|
descriptions.each do |description|
|
50
|
-
subject.report_lints.scan(
|
50
|
+
subject.report_lints.scan(description).count.should == 1
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -31,7 +31,7 @@ describe SCSSLint::Reporter::FilesReporter do
|
|
31
31
|
|
32
32
|
it 'prints the filename for each lint' do
|
33
33
|
filenames.each do |filename|
|
34
|
-
subject.report_lints.scan(
|
34
|
+
subject.report_lints.scan(filename).count.should == 1
|
35
35
|
end
|
36
36
|
end
|
37
37
|
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.42.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brigade Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -62,6 +62,7 @@ executables:
|
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
|
+
- MIT-LICENSE
|
65
66
|
- bin/scss-lint
|
66
67
|
- config/default.yml
|
67
68
|
- data/prefixed-identifiers/base.txt
|