scss_lint 0.42.0 → 0.42.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84412ffcfbcad02e1d135dae52e56c33c0f42c19
4
- data.tar.gz: af6e1f97f4755ab0b69cf7b4162412571aa42704
3
+ metadata.gz: 1f22ef7a1e5735cdd001ff93b7fe1dff595dc609
4
+ data.tar.gz: 1af1a879ec132f70a04fc3b9cc794e0f8dd9a94b
5
5
  SHA512:
6
- metadata.gz: 1fe04a0e8578d96cb59af5ea52bb4ca274d386153bbe9cb47541bb6f04905ff5e47062237bb7956dfcbdf860fde3c3814344321a62e1d3d3f21cb92a99939ebf
7
- data.tar.gz: cefba0a8a5a0ab3b7c19e706efaaac38fbde69fabcd2ae813f4fc363ce2e42babd5fbca2261cf5db9c964a05d35dc2a262d756db45e88c5ced577a5b76b8a4c5
6
+ metadata.gz: 23cb255d2401258655eb94a88c41a7c639ec1d45bc3dae0a413e3fdd68fe2f7bc8d900066673a60c35e4a862c5e3499354328b1547f2a445b0abdbb6acfe8c00
7
+ data.tar.gz: 0ccd62fd3f715cf3ce291e240e22be5bdbfb4ef5d483cf52c4339ff3baa0296cb625182d48abefbef557e37f2a13e7381cdb6f6e17aab591469cbd7865e9994b
@@ -5,9 +5,28 @@ module SCSSLint
5
5
 
6
6
  STOPPING_CHARACTERS = ['!', "'", '"', nil]
7
7
 
8
+ def visit_extend(node)
9
+ check_bang(node)
10
+ end
11
+
8
12
  def visit_prop(node)
9
- return unless source_from_range(node.source_range).include?('!')
10
- return unless check_spacing(node)
13
+ check_bang(node)
14
+ end
15
+
16
+ def visit_variable(node)
17
+ check_bang(node)
18
+ end
19
+
20
+ private
21
+
22
+ def check_bang(node)
23
+ range = if node.respond_to?(:value_source_range)
24
+ node.value_source_range
25
+ else
26
+ node.source_range
27
+ end
28
+ return unless source_from_range(range).include?('!')
29
+ return unless check_spacing(range)
11
30
 
12
31
  before_qualifier = config['space_before_bang'] ? '' : 'not '
13
32
  after_qualifier = config['space_after_bang'] ? '' : 'not '
@@ -16,8 +35,6 @@ module SCSSLint
16
35
  "and should #{after_qualifier}be followed by a space")
17
36
  end
18
37
 
19
- private
20
-
21
38
  # Start from the back and move towards the front so that any !important or
22
39
  # !default !'s will be found *before* quotation marks. Then we can
23
40
  # stop at quotation marks to protect against linting !'s within strings
@@ -40,8 +57,7 @@ module SCSSLint
40
57
  (after_actual =~ after_expected).nil?
41
58
  end
42
59
 
43
- def check_spacing(node)
44
- range = node.value_source_range
60
+ def check_spacing(range)
45
61
  offset = find_bang_offset(range)
46
62
 
47
63
  return if character_at(range.end_pos, offset) != '!'
@@ -8,6 +8,13 @@ module SCSSLint
8
8
  end
9
9
 
10
10
  def visit_variable(node)
11
+ # If the variable is using `!default` or `!global` (e.g. `$foo: bar
12
+ # !default;`) then `node.expr` will give us the source range just for the
13
+ # value (e.g. `bar`). In these cases, we want to use the source range of
14
+ # `node`, which will give us most of the entire line (e.g. `foo: bar
15
+ # !default`.
16
+ return check_semicolon(node) if node.global || node.guarded
17
+
11
18
  check_semicolon(node.expr)
12
19
  end
13
20
 
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module SCSSLint
3
- VERSION = '0.42.0'
3
+ VERSION = '0.42.1'
4
4
  end
@@ -77,6 +77,64 @@ describe SCSSLint::Linter::BangFormat do
77
77
  it { should_not report_lint }
78
78
  end
79
79
 
80
+ context 'with a !default variable declaration' do
81
+ context 'and !default is used correctly' do
82
+ let(:scss) { <<-SCSS }
83
+ $foo: bar !default;
84
+ SCSS
85
+
86
+ it { should_not report_lint }
87
+ end
88
+
89
+ context 'and there is no space before' do
90
+ let(:scss) { <<-SCSS }
91
+ $foo: bar!default;
92
+ SCSS
93
+
94
+ it { should report_lint line: 1 }
95
+ end
96
+ end
97
+
98
+ context 'with a !global variable declaration' do
99
+ context 'and !global is used correctly' do
100
+ let(:scss) { <<-SCSS }
101
+ $foo: bar !global;
102
+ SCSS
103
+
104
+ it { should_not report_lint }
105
+ end
106
+
107
+ context 'and there is no space before' do
108
+ let(:scss) { <<-SCSS }
109
+ $foo: bar!global;
110
+ SCSS
111
+
112
+ it { should report_lint line: 1 }
113
+ end
114
+ end
115
+
116
+ context 'with an !optional @extend directive' do
117
+ context 'and !optional is used correctly' do
118
+ let(:scss) { <<-SCSS }
119
+ .foo {
120
+ @extend .bar !optional;
121
+ }
122
+ SCSS
123
+
124
+ it { should_not report_lint }
125
+ end
126
+
127
+ context 'and there is no space before' do
128
+ let(:scss) { <<-SCSS }
129
+ .foo {
130
+ @extend .bar!optional;
131
+ }
132
+ SCSS
133
+
134
+ it { should report_lint line: 2 }
135
+ end
136
+ end
137
+
80
138
  context 'when ! appears within a string' do
81
139
  let(:scss) { <<-SCSS }
82
140
  p:before { content: "!important"; }
@@ -23,6 +23,48 @@ describe SCSSLint::Linter::TrailingSemicolon do
23
23
  it { should_not report_lint }
24
24
  end
25
25
 
26
+ context 'when an !important property' do
27
+ context 'ends with a semicolon' do
28
+ let(:scss) { <<-SCSS }
29
+ p {
30
+ margin: 0 !important;
31
+ }
32
+ SCSS
33
+
34
+ it { should_not report_lint }
35
+ end
36
+
37
+ context 'ends with two semicolons' do
38
+ let(:scss) { <<-SCSS }
39
+ p {
40
+ margin: 0 !important;;
41
+ }
42
+ SCSS
43
+
44
+ it { should report_lint line: 2 }
45
+ end
46
+
47
+ context 'has a space before the semicolon' do
48
+ let(:scss) { <<-SCSS }
49
+ p {
50
+ margin: 0 !important ;
51
+ }
52
+ SCSS
53
+
54
+ it { should report_lint line: 2 }
55
+ end
56
+
57
+ context 'is missing a semicolon' do
58
+ let(:scss) { <<-SCSS }
59
+ p {
60
+ margin: 0 !important
61
+ }
62
+ SCSS
63
+
64
+ it { should report_lint line: 2 }
65
+ end
66
+ end
67
+
26
68
  context 'when a property ends with a space followed by a semicolon' do
27
69
  let(:scss) { <<-SCSS }
28
70
  p {
@@ -302,6 +344,84 @@ describe SCSSLint::Linter::TrailingSemicolon do
302
344
  it { should_not report_lint }
303
345
  end
304
346
 
347
+ context 'when a !default variable declaration' do
348
+ context 'ends with a semicolon' do
349
+ let(:scss) { '$foo: bar !default;' }
350
+
351
+ it { should_not report_lint }
352
+ end
353
+
354
+ context 'ends with two semicolons' do
355
+ let(:scss) { '$foo: bar !default;;' }
356
+
357
+ it { should report_lint }
358
+ end
359
+
360
+ context 'has a space before the semicolon' do
361
+ let(:scss) { '$foo: bar !default ;' }
362
+
363
+ it { should report_lint }
364
+ end
365
+
366
+ context 'is missing a semicolon' do
367
+ let(:scss) { '$foo: bar !default' }
368
+
369
+ it { should report_lint }
370
+ end
371
+ end
372
+
373
+ context 'when a !global variable declaration' do
374
+ context 'ends with a semicolon' do
375
+ let(:scss) { '$foo: bar !global;' }
376
+
377
+ it { should_not report_lint }
378
+ end
379
+
380
+ context 'ends with two semicolons' do
381
+ let(:scss) { '$foo: bar !global;;' }
382
+
383
+ it { should report_lint }
384
+ end
385
+
386
+ context 'has a space before the semicolon' do
387
+ let(:scss) { '$foo: bar !global ;' }
388
+
389
+ it { should report_lint }
390
+ end
391
+
392
+ context 'is missing a semicolon' do
393
+ let(:scss) { '$foo: bar !global' }
394
+
395
+ it { should report_lint }
396
+ end
397
+ end
398
+
399
+ context 'when the value of the variable is !important' do
400
+ context 'ends with a semicolon' do
401
+ let(:scss) { '$foo: bar !important;' }
402
+
403
+ it { should_not report_lint }
404
+ end
405
+
406
+ context 'ends with two semicolons' do
407
+ let(:scss) { '$foo: bar !important;;' }
408
+
409
+ it { should report_lint }
410
+ end
411
+
412
+ context 'has a space before the semicolon' do
413
+ let(:scss) { '$foo: bar !important ;' }
414
+
415
+ it { should report_lint }
416
+ end
417
+
418
+ context 'is missing a semicolon' do
419
+ let(:scss) { '$foo: bar !important' }
420
+
421
+ it { should report_lint }
422
+ end
423
+ end
424
+
305
425
  context 'when variable declaration is followed by a comment and semicolon' do
306
426
  let(:scss) { '$foo: bar // comment;' }
307
427
 
@@ -351,4 +471,88 @@ describe SCSSLint::Linter::TrailingSemicolon do
351
471
  end
352
472
  end
353
473
  end
474
+
475
+ context 'with an @extend directive' do
476
+ context 'that ends with a semicolon' do
477
+ let(:scss) { <<-SCSS }
478
+ .foo {
479
+ @extend .bar;
480
+ }
481
+ SCSS
482
+
483
+ it { should_not report_lint }
484
+ end
485
+
486
+ context 'with two semicolons' do
487
+ let(:scss) { <<-SCSS }
488
+ .foo {
489
+ @extend .bar;;
490
+ }
491
+ SCSS
492
+
493
+ it { should report_lint line: 2 }
494
+ end
495
+
496
+ context 'with a space before the semicolon' do
497
+ let(:scss) { <<-SCSS }
498
+ .foo {
499
+ @extend .bar ;
500
+ }
501
+ SCSS
502
+
503
+ it { should report_lint line: 2 }
504
+ end
505
+
506
+ context 'that does not have a semicolon' do
507
+ let(:scss) { <<-SCSS }
508
+ .foo {
509
+ @extend .bar
510
+ }
511
+ SCSS
512
+
513
+ it { should report_lint line: 2 }
514
+ end
515
+
516
+ context 'with the !optional flag' do
517
+ context 'that ends with a semicolon' do
518
+ let(:scss) { <<-SCSS }
519
+ .foo {
520
+ @extend .bar !optional;
521
+ }
522
+ SCSS
523
+
524
+ it { should_not report_lint }
525
+ end
526
+
527
+ context 'with two semicolons' do
528
+ let(:scss) { <<-SCSS }
529
+ .foo {
530
+ @extend .bar !optional;;
531
+ }
532
+ SCSS
533
+
534
+ it { should report_lint line: 2 }
535
+ end
536
+
537
+ context 'with a space before the semicolon' do
538
+ let(:scss) { <<-SCSS }
539
+ .foo {
540
+ @extend .bar !optional ;
541
+ }
542
+ SCSS
543
+
544
+ it { should report_lint line: 2 }
545
+ end
546
+
547
+ context 'that does not have a semicolon' do
548
+ let(:scss) { <<-SCSS }
549
+ .foo {
550
+ @extend .bar !optional
551
+ }
552
+ SCSS
553
+
554
+ it { should report_lint line: 2 }
555
+ end
556
+ end
557
+ end
354
558
  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.42.0
4
+ version: 0.42.1
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-09-24 00:00:00.000000000 Z
12
+ date: 2015-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow