scss_lint 0.56.0 → 0.57.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/data/properties.txt +1 -0
- data/data/property-sort-orders/smacss.txt +25 -0
- data/data/pseudo-elements.txt +1 -0
- data/lib/scss_lint/linter/color_variable.rb +4 -2
- data/lib/scss_lint/linter/private_naming_convention.rb +2 -2
- data/lib/scss_lint/linter/property_sort_order.rb +0 -3
- data/lib/scss_lint/linter/shorthand.rb +1 -2
- data/lib/scss_lint/linter/space_after_property_colon.rb +8 -0
- data/lib/scss_lint/linter/space_between_parens.rb +2 -4
- data/lib/scss_lint/reporter/clean_files_reporter.rb +1 -1
- data/lib/scss_lint/sass/script.rb +3 -1
- data/lib/scss_lint/sass/tree.rb +2 -0
- data/lib/scss_lint/version.rb +1 -1
- data/spec/scss_lint/linter/color_variable_spec.rb +2 -0
- data/spec/scss_lint/linter/space_after_property_colon_spec.rb +97 -0
- data/spec/scss_lint/reporter/clean_files_reporter_spec.rb +6 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d1f5b2c584f66d7148053a525c0323e872fa08a
|
4
|
+
data.tar.gz: 8abdb50bcfff6c9b23fe3b01dacb66d602f565d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30822ae6faef50aa2d253cb88c2c7afce9e0e45fcaba3a9a4d5e4d3edbdaa5618c9f2d997121a61c96a280330f9bfb51918f14da0c53bff36dc400373f8a2015
|
7
|
+
data.tar.gz: 26fefc161597ed2f735e3315475c2cf70b3c780b2593ad6294ddbcee0fcad9834c2cb4e53897a0884926ffe4f756660b2fc6b1d043c7bef076a25de20dfc6603
|
data/data/properties.txt
CHANGED
@@ -20,6 +20,31 @@ left
|
|
20
20
|
|
21
21
|
box-sizing
|
22
22
|
|
23
|
+
grid
|
24
|
+
grid-after
|
25
|
+
grid-area
|
26
|
+
grid-auto-columns
|
27
|
+
grid-auto-flow
|
28
|
+
grid-auto-rows
|
29
|
+
grid-before
|
30
|
+
grid-column
|
31
|
+
grid-column-end
|
32
|
+
grid-column-gap
|
33
|
+
grid-column-start
|
34
|
+
grid-columns
|
35
|
+
grid-end
|
36
|
+
grid-gap
|
37
|
+
grid-row
|
38
|
+
grid-row-end
|
39
|
+
grid-row-gap
|
40
|
+
grid-row-start
|
41
|
+
grid-rows
|
42
|
+
grid-start
|
43
|
+
grid-template
|
44
|
+
grid-template-areas
|
45
|
+
grid-template-columns
|
46
|
+
grid-template-rows
|
47
|
+
|
23
48
|
flex
|
24
49
|
flex-basis
|
25
50
|
flex-direction
|
data/data/pseudo-elements.txt
CHANGED
@@ -55,11 +55,13 @@ module SCSSLint
|
|
55
55
|
def in_variable_declaration?(node)
|
56
56
|
parent = node.node_parent
|
57
57
|
parent.is_a?(Sass::Script::Tree::Literal) &&
|
58
|
-
parent.node_parent.is_a?(Sass::Tree::VariableNode)
|
58
|
+
(parent.node_parent.is_a?(Sass::Tree::VariableNode) ||
|
59
|
+
parent.node_parent.node_parent.is_a?(Sass::Tree::VariableNode))
|
59
60
|
end
|
60
61
|
|
61
62
|
def function_in_variable_declaration?(node)
|
62
|
-
node.node_parent.is_a?(Sass::Tree::VariableNode)
|
63
|
+
node.node_parent.is_a?(Sass::Tree::VariableNode) ||
|
64
|
+
node.node_parent.node_parent.is_a?(Sass::Tree::VariableNode)
|
63
65
|
end
|
64
66
|
|
65
67
|
def in_rgba_function_call?(node)
|
@@ -24,7 +24,7 @@ module SCSSLint
|
|
24
24
|
|
25
25
|
def visit_root(node)
|
26
26
|
# Register all top-level function, mixin, and variable definitions.
|
27
|
-
node.children.
|
27
|
+
node.children.each do |child_node|
|
28
28
|
if DEFINITIONS.key?(child_node.class)
|
29
29
|
register_node child_node
|
30
30
|
end
|
@@ -97,7 +97,7 @@ module SCSSLint
|
|
97
97
|
def node_defined_earlier_in_branch?(node_to_look_in, looking_for)
|
98
98
|
# Look at all of the children of this node and return true if we find a
|
99
99
|
# defining node that matches in name and type.
|
100
|
-
node_to_look_in.children.
|
100
|
+
node_to_look_in.children.each do |child_node|
|
101
101
|
break unless before?(child_node, looking_for[:location])
|
102
102
|
next unless child_node.class == looking_for[:defined_by]
|
103
103
|
next unless child_node.name == looking_for[:node].name
|
@@ -36,9 +36,7 @@ module SCSSLint
|
|
36
36
|
alias visit_media check_order
|
37
37
|
alias visit_mixin check_order
|
38
38
|
alias visit_rule check_order
|
39
|
-
alias visit_prop check_order
|
40
39
|
|
41
|
-
# rubocop:disable Lint/DuplicateMethods (FALSE POSITIVE v0.50.0)
|
42
40
|
def visit_prop(node, &block)
|
43
41
|
# Handle nested properties by appending the parent property they are
|
44
42
|
# nested under to the name
|
@@ -46,7 +44,6 @@ module SCSSLint
|
|
46
44
|
check_order(node, &block)
|
47
45
|
@nested_under = nil
|
48
46
|
end
|
49
|
-
# rubocop:enable Lint/DuplicateMethods
|
50
47
|
|
51
48
|
def visit_if(node, &block)
|
52
49
|
check_order(node, &block)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
2
1
|
module SCSSLint
|
3
2
|
# Checks for the use of the shortest form for properties that can be written
|
4
3
|
# in shorthand.
|
@@ -119,7 +118,7 @@ module SCSSLint
|
|
119
118
|
# @param bottom [String]
|
120
119
|
# @param left [String]
|
121
120
|
# @return [Boolean]
|
122
|
-
def condense_to_one_value?(top, right, bottom, left)
|
121
|
+
def condense_to_one_value?(top, right, bottom, left) # rubocop:disable Metrics/CyclomaticComplexity
|
123
122
|
return unless allowed?(1)
|
124
123
|
return unless top == right
|
125
124
|
|
@@ -24,6 +24,8 @@ module SCSSLint
|
|
24
24
|
check_for_at_least_one_space(node, whitespace)
|
25
25
|
when 'one_space_or_newline'
|
26
26
|
check_for_one_space_or_newline(node, whitespace)
|
27
|
+
when 'at_least_one_space_or_newline'
|
28
|
+
check_for_at_least_one_space_or_newline(node, whitespace)
|
27
29
|
end
|
28
30
|
|
29
31
|
yield # Continue linting children
|
@@ -52,6 +54,12 @@ module SCSSLint
|
|
52
54
|
add_lint(node, 'Colon after property should be followed by one space or a newline')
|
53
55
|
end
|
54
56
|
|
57
|
+
def check_for_at_least_one_space_or_newline(node, whitespace)
|
58
|
+
return if [[' '], ["\n"]].include?(whitespace.uniq)
|
59
|
+
return if whitespace[0] == "\n" && whitespace[1..-1].uniq == [' ']
|
60
|
+
add_lint(node, 'Colon after property should be followed by at least one space or newline')
|
61
|
+
end
|
62
|
+
|
55
63
|
def check_properties_alignment(rule_node)
|
56
64
|
properties = rule_node.children.select { |node| node.is_a?(Sass::Tree::PropNode) }
|
57
65
|
|
@@ -1,6 +1,4 @@
|
|
1
1
|
module SCSSLint
|
2
|
-
# rubocop:disable Metrics/AbcSize
|
3
|
-
|
4
2
|
# Checks for the presence of spaces between parentheses.
|
5
3
|
class Linter::SpaceBetweenParens < Linter
|
6
4
|
include LinterRegistry
|
@@ -33,7 +31,7 @@ module SCSSLint
|
|
33
31
|
|
34
32
|
TRAILING_WHITESPACE = /\s*$/
|
35
33
|
|
36
|
-
def check(node, source) # rubocop:disable Metrics/MethodLength
|
34
|
+
def check(node, source) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
37
35
|
@spaces = config['spaces']
|
38
36
|
source = trim_right_paren(source)
|
39
37
|
return if source.count('(') != source.count(')')
|
@@ -71,7 +69,7 @@ module SCSSLint
|
|
71
69
|
# An expression enclosed in parens will include or not include each paren, depending
|
72
70
|
# on whitespace. Here we feel out for enclosing parens, and return them as the new
|
73
71
|
# source for the node.
|
74
|
-
def feel_for_enclosing_parens(node) # rubocop:disable Metrics/CyclomaticComplexity
|
72
|
+
def feel_for_enclosing_parens(node) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
75
73
|
range = node.source_range
|
76
74
|
original_source = source_from_range(range)
|
77
75
|
left_offset = -1
|
@@ -3,7 +3,7 @@ module SCSSLint
|
|
3
3
|
class Reporter::CleanFilesReporter < Reporter
|
4
4
|
def report_lints
|
5
5
|
dirty_files = lints.map(&:filename).uniq
|
6
|
-
clean_files = files - dirty_files
|
6
|
+
clean_files = files.map { |e| e['path'] } - dirty_files
|
7
7
|
clean_files.sort.join("\n") + "\n" if clean_files.any?
|
8
8
|
end
|
9
9
|
end
|
@@ -22,7 +22,7 @@ module Sass::Script
|
|
22
22
|
types.each do |type|
|
23
23
|
node_name = type.downcase
|
24
24
|
|
25
|
-
eval <<-DECL
|
25
|
+
eval <<-DECL, binding, __FILE__, __LINE__ + 1
|
26
26
|
class #{namespace}::#{type}
|
27
27
|
def self.node_name
|
28
28
|
:script_#{node_name}
|
@@ -76,3 +76,5 @@ module Sass::Script
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
# rubocop:enable Documentation
|
data/lib/scss_lint/sass/tree.rb
CHANGED
data/lib/scss_lint/version.rb
CHANGED
@@ -4,6 +4,7 @@ describe SCSSLint::Linter::ColorVariable do
|
|
4
4
|
context 'when a color literal is used in a variable declaration' do
|
5
5
|
let(:scss) { <<-SCSS }
|
6
6
|
$my-color: #f00;
|
7
|
+
$my-shadow: 2px 2px 2px #f00;
|
7
8
|
SCSS
|
8
9
|
|
9
10
|
it { should_not report_lint }
|
@@ -12,6 +13,7 @@ describe SCSSLint::Linter::ColorVariable do
|
|
12
13
|
context 'when a color function containing literals is used in a variable declaration' do
|
13
14
|
let(:scss) { <<-SCSS }
|
14
15
|
$my-color: rgba(0, 0, 0, 0.2);
|
16
|
+
$my-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
|
15
17
|
SCSS
|
16
18
|
|
17
19
|
it { should_not report_lint }
|
@@ -266,6 +266,16 @@ describe SCSSLint::Linter::SpaceAfterPropertyColon do
|
|
266
266
|
it { should_not report_lint }
|
267
267
|
end
|
268
268
|
|
269
|
+
context 'when the colon after a property is followed by multiple spaces' do
|
270
|
+
let(:scss) { <<-SCSS }
|
271
|
+
p {
|
272
|
+
margin: bold;
|
273
|
+
}
|
274
|
+
SCSS
|
275
|
+
|
276
|
+
it { should report_lint line: 2 }
|
277
|
+
end
|
278
|
+
|
269
279
|
context 'when the colon after a property is followed by a newline and spaces' do
|
270
280
|
let(:scss) { <<-SCSS }
|
271
281
|
p {
|
@@ -300,6 +310,93 @@ url(https://something.crazy.long/with/paths?and=queries)
|
|
300
310
|
end
|
301
311
|
end
|
302
312
|
|
313
|
+
context 'when at least one space or newline is preferred' do
|
314
|
+
let(:style) { 'at_least_one_space_or_newline' }
|
315
|
+
|
316
|
+
context 'when the colon after a property is not followed by space' do
|
317
|
+
let(:scss) { <<-SCSS }
|
318
|
+
p {
|
319
|
+
margin:0;
|
320
|
+
}
|
321
|
+
SCSS
|
322
|
+
|
323
|
+
it { should report_lint line: 2 }
|
324
|
+
end
|
325
|
+
|
326
|
+
context 'when the colon after a property is followed by a space' do
|
327
|
+
let(:scss) { <<-SCSS }
|
328
|
+
p {
|
329
|
+
margin: 0;
|
330
|
+
}
|
331
|
+
SCSS
|
332
|
+
|
333
|
+
it { should_not report_lint }
|
334
|
+
end
|
335
|
+
|
336
|
+
context 'when the colon after a property is surrounded by spaces' do
|
337
|
+
let(:scss) { <<-SCSS }
|
338
|
+
p {
|
339
|
+
margin : bold;
|
340
|
+
}
|
341
|
+
SCSS
|
342
|
+
|
343
|
+
it { should_not report_lint }
|
344
|
+
end
|
345
|
+
|
346
|
+
context 'when the colon after a property is followed by multiple spaces' do
|
347
|
+
let(:scss) { <<-SCSS }
|
348
|
+
p {
|
349
|
+
margin: bold;
|
350
|
+
}
|
351
|
+
SCSS
|
352
|
+
|
353
|
+
it { should_not report_lint }
|
354
|
+
end
|
355
|
+
|
356
|
+
context 'when the colon after a property is followed by multiple spaces and a tab' do
|
357
|
+
let(:scss) { <<-SCSS }
|
358
|
+
p {
|
359
|
+
margin: \tbold;
|
360
|
+
}
|
361
|
+
SCSS
|
362
|
+
|
363
|
+
it { should report_lint line: 2 }
|
364
|
+
end
|
365
|
+
|
366
|
+
context 'when the colon after a property is followed by a newline and spaces' do
|
367
|
+
let(:scss) { <<-SCSS }
|
368
|
+
p {
|
369
|
+
background-image:
|
370
|
+
url(https://something.crazy.long/with/paths?and=queries)
|
371
|
+
}
|
372
|
+
SCSS
|
373
|
+
|
374
|
+
it { should_not report_lint }
|
375
|
+
end
|
376
|
+
|
377
|
+
context 'when the colon after a property is followed by a newline and no spaces' do
|
378
|
+
let(:scss) { <<-SCSS }
|
379
|
+
p {
|
380
|
+
background-image:
|
381
|
+
url(https://something.crazy.long/with/paths?and=queries)
|
382
|
+
}
|
383
|
+
SCSS
|
384
|
+
|
385
|
+
it { should_not report_lint }
|
386
|
+
end
|
387
|
+
|
388
|
+
context 'when the colon after a property is followed by a space and then a newline' do
|
389
|
+
let(:scss) { <<-SCSS }
|
390
|
+
p {
|
391
|
+
background-image:\s
|
392
|
+
url(https://something.crazy.long/with/paths?and=queries)
|
393
|
+
}
|
394
|
+
SCSS
|
395
|
+
|
396
|
+
it { should report_lint line: 2 }
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
303
400
|
context 'when aligned property values are preferred' do
|
304
401
|
let(:style) { 'aligned' }
|
305
402
|
|
@@ -14,7 +14,7 @@ describe SCSSLint::Reporter::CleanFilesReporter do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
context 'when there are no lints but some files were linted' do
|
17
|
-
let(:files) {
|
17
|
+
let(:files) { [{ 'path' => 'c.scss' }, { 'path' => 'b.scss' }, { 'path' => 'a.scss' }] }
|
18
18
|
let(:lints) { [] }
|
19
19
|
|
20
20
|
it 'prints each file on its own line' do
|
@@ -33,25 +33,25 @@ describe SCSSLint::Reporter::CleanFilesReporter do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
context 'when there are lints in some files' do
|
36
|
-
let(:dirty_files) {
|
37
|
-
let(:clean_files) {
|
36
|
+
let(:dirty_files) { [{ 'path' => 'a.scss' }, { 'path' => 'b.scss' }] }
|
37
|
+
let(:clean_files) { [{ 'path' => 'c.scss' }, { 'path' => 'd.scss' }] }
|
38
38
|
let(:files) { dirty_files + clean_files }
|
39
39
|
|
40
40
|
let(:lints) do
|
41
41
|
dirty_files.map do |file|
|
42
|
-
SCSSLint::Lint.new(SCSSLint::Linter::Comment.new, file, SCSSLint::Location.new, '')
|
42
|
+
SCSSLint::Lint.new(SCSSLint::Linter::Comment.new, file['path'], SCSSLint::Location.new, '')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'prints the file for each lint' do
|
47
47
|
clean_files.each do |file|
|
48
|
-
subject.report_lints.scan(file).count.should == 1
|
48
|
+
subject.report_lints.scan(file['path']).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(file).count.should == 0
|
54
|
+
subject.report_lints.scan(file['path']).count.should == 0
|
55
55
|
end
|
56
56
|
end
|
57
57
|
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.57.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:
|
12
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -37,14 +37,14 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.5.
|
40
|
+
version: 3.5.5
|
41
41
|
type: :runtime
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.5.
|
47
|
+
version: 3.5.5
|
48
48
|
description: Configurable tool for writing clean and consistent SCSS
|
49
49
|
email:
|
50
50
|
- eng@brigade.com
|
@@ -266,7 +266,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
266
266
|
requirements:
|
267
267
|
- - ">="
|
268
268
|
- !ruby/object:Gem::Version
|
269
|
-
version: '2'
|
269
|
+
version: '2.1'
|
270
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
271
|
requirements:
|
272
272
|
- - ">="
|
@@ -274,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
274
|
version: '0'
|
275
275
|
requirements: []
|
276
276
|
rubyforge_project:
|
277
|
-
rubygems_version: 2.
|
277
|
+
rubygems_version: 2.5.2
|
278
278
|
signing_key:
|
279
279
|
specification_version: 4
|
280
280
|
summary: SCSS lint tool
|