Skip to content

Commit cca399c

Browse files
authored
Merge pull request #1117 from bgriffith/release/1.11.1
Release/1.11.1
2 parents a7b0b40 + a677fc7 commit cca399c

File tree

6 files changed

+112
-36
lines changed

6 files changed

+112
-36
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Sass Lint Changelog
22

3+
## v1.11.1
4+
5+
**August 28th, 2017**
6+
7+
**Fixes**
8+
* Fixed an issue with the `misspelled-properties` rule incorrectly reporting nested properties [#1113](https://github.com/sasstools/sass-lint/pull/1113)
9+
310
## v1.11.0
411

512
**August 27th, 2017**

lib/rules/no-misspelled-properties.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
var helpers = require('../helpers');
44
var properties = require('known-css-properties').all;
5-
5+
// Keep track of our properties we need to skip from the gonzales loop
6+
var skipProps = 0;
67
/**
78
* Combine the valid property array and the array of extras into a new array
89
*
@@ -33,32 +34,30 @@ var generateName = function (baseName, name) {
3334
* @param {Number} propsCounted - The number of properties encountered in our multiline so far
3435
* @returns {Array} Array of objects containing our property and line/col info etc
3536
*/
36-
var buildPartialProperty = function (valBlock, currentProperty, propsCounted) {
37+
var buildPartialProperty = function (valBlock, currentProperty) {
3738
var propList = [];
38-
var propsEncountered = propsCounted;
39+
3940
if (valBlock.contains('declaration')) {
4041
valBlock.forEach('declaration', function (node) {
4142
var prop = node.first('property');
4243
var value = node.first('value');
43-
propsEncountered++;
44+
skipProps++;
4445

4546
if (prop.first().is('ident')) {
4647
if (value.contains('block')) {
4748
propList = propList.concat(
4849
buildPartialProperty(value.first('block'),
4950
{
5051
name: generateName(currentProperty.name, prop.first('ident').content)
51-
},
52-
propsEncountered
52+
}
5353
)
5454
);
5555
}
5656
else {
5757
propList.push({
5858
name: generateName(currentProperty.name, prop.first('ident').content),
5959
line: prop.first().start.line,
60-
col: prop.first().start.column,
61-
propsEncountered: propsEncountered
60+
col: prop.first().start.column
6261
});
6362
}
6463
}
@@ -74,16 +73,15 @@ module.exports = {
7473
},
7574
'detect': function (ast, parser) {
7675
var result = [];
77-
var toSkip = 0;
7876
var propertyList = getCombinedList(properties, parser.options['extra-properties']);
7977

8078
ast.traverseByType('declaration', function (node) {
8179
var prop = node.first('property');
8280
var containsInterp = prop.contains('interpolation');
8381
// If we've already checked declarations in a multiline we can skip those decs here
84-
if (toSkip) {
85-
toSkip--;
86-
return !toSkip;
82+
if (skipProps) {
83+
skipProps -= 1;
84+
return !skipProps;
8785
}
8886
// make sure our first node within our property is an ident
8987
if (!prop.first() || !prop.first().is('ident')) {
@@ -102,15 +100,12 @@ module.exports = {
102100
name: curProperty,
103101
line: prop.first('ident').start.line,
104102
col: prop.first('ident').start.column
105-
},
106-
0
103+
}
107104
);
108105
}
109106
// If we have multiline properties
110107
if (fullProperties.length) {
111108
fullProperties.forEach(function (constrProp) {
112-
// Add the number of property declarations we've already checked here so we can skip them
113-
toSkip += constrProp.propsEncountered;
114109
// Check if the property exists in our list
115110
if (propertyList.indexOf(constrProp.name) === -1) {
116111
result = helpers.addUnique(result, {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-lint",
3-
"version": "1.11.0",
3+
"version": "1.11.1",
44
"description": "All Node Sass linter!",
55
"main": "index.js",
66
"scripts": {

tests/rules/no-misspelled-properties.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('no misspelled properties - scss', function () {
1212
lint.test(file, {
1313
'no-misspelled-properties': 1
1414
}, function (data) {
15-
lint.assert.equal(9, data.warningCount);
15+
lint.assert.equal(14, data.warningCount);
1616
done();
1717
});
1818
});
@@ -28,7 +28,7 @@ describe('no misspelled properties - scss', function () {
2828
}
2929
]
3030
}, function (data) {
31-
lint.assert.equal(8, data.warningCount);
31+
lint.assert.equal(13, data.warningCount);
3232
done();
3333
});
3434
});
@@ -45,7 +45,7 @@ describe('no misspelled properties - scss', function () {
4545
}
4646
]
4747
}, function (data) {
48-
lint.assert.equal(7, data.warningCount);
48+
lint.assert.equal(12, data.warningCount);
4949
done();
5050
});
5151
});
@@ -61,7 +61,7 @@ describe('no misspelled properties - sass', function () {
6161
lint.test(file, {
6262
'no-misspelled-properties': 1
6363
}, function (data) {
64-
lint.assert.equal(9, data.warningCount);
64+
lint.assert.equal(14, data.warningCount);
6565
done();
6666
});
6767
});
@@ -77,7 +77,7 @@ describe('no misspelled properties - sass', function () {
7777
}
7878
]
7979
}, function (data) {
80-
lint.assert.equal(8, data.warningCount);
80+
lint.assert.equal(13, data.warningCount);
8181
done();
8282
});
8383
});
@@ -94,7 +94,7 @@ describe('no misspelled properties - sass', function () {
9494
}
9595
]
9696
}, function (data) {
97-
lint.assert.equal(7, data.warningCount);
97+
lint.assert.equal(12, data.warningCount);
9898
done();
9999
});
100100
});

tests/sass/no-misspelled-properties.sass

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
$red: #ff0000
22

33
.test-failure
4-
@include test
4+
+test
55
-webkit-transit1on: width 2s
66
background-sizer: contain
77
colors: $red
88
transit1on: width 2s
99

1010
.test-correct
11-
@include test
11+
+test
12+
1213
-webkit-transition: width 2s
1314
background-size: contain
1415
color: $red
@@ -21,7 +22,6 @@ $red: #ff0000
2122
.test-vendor
2223
-moz-osx-font-smoothing: auto
2324

24-
2525
.foo
2626
font:
2727
family: fantasy
@@ -46,3 +46,34 @@ $red: #ff0000
4646

4747
.foo
4848
margin-#{$property-y}: -2 * $hint-arrow-width
49+
50+
// https://github.com/sasstools/sass-lint/issues/1112
51+
=font-test1
52+
font:
53+
family: Arial, sans-serif
54+
style: normal
55+
weight: 300
56+
57+
=font-test2
58+
font:
59+
family: Arial, sans-serif
60+
style: normal
61+
weight: 400
62+
63+
=font-test2
64+
font:
65+
fazily: Arial, sans-serif
66+
style: normal
67+
weght: 400
68+
border:
69+
top:
70+
left:
71+
radius: 5px
72+
right: 6px solid #fff
73+
botom:
74+
right:
75+
radiu: 5px
76+
background:
77+
color: red
78+
background-colr: blue
79+
font-size: 12rem

tests/sass/no-misspelled-properties.scss

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ $red: #ff0000;
22

33
.test-failure {
44
@include test;
5-
-webkit-transit1on: width 2s;
6-
background-sizer: contain;
7-
colors: $red;
8-
transit1on: width 2s;
5+
-webkit-transit1on: width 2s; // 1
6+
background-sizer: contain; // 2
7+
colors: $red; // 3
8+
transit1on: width 2s; // 4
99
}
1010

1111
.test-correct {
@@ -33,9 +33,9 @@ $red: #ff0000;
3333
}
3434
border: {
3535
top: {
36-
right: 1px solid #fff;
36+
right: 1px solid #fff; // 5
3737
left: {
38-
color: red;
38+
color: red; // 6
3939
}
4040
}
4141
left: 2px solid #000;
@@ -44,20 +44,63 @@ $red: #ff0000;
4444

4545
.bar {
4646
font: {
47-
famizy: fantasy;
47+
famizy: fantasy; // 7
4848
size: 12px;
4949
}
5050
boder: {
5151
top: {
52-
rigt: 1px solid #fff;
52+
rigt: 1px solid #fff; // 8
5353
left: {
54-
color: red;
54+
color: red; // 9
5555
}
5656
}
57-
left: 2px solid #000;
57+
left: 2px solid #000; // 10
5858
}
5959
}
6060

6161
.foo {
6262
margin-#{$property-y}: -2 * $hint-arrow-width;
6363
}
64+
65+
// https://github.com/sasstools/sass-lint/issues/1112
66+
@mixin font-test1 {
67+
font: {
68+
family: Arial, sans-serif;
69+
style: normal;
70+
weight: 300;
71+
}
72+
}
73+
74+
@mixin font-test2 {
75+
font: {
76+
family: Arial, sans-serif;
77+
style: normal;
78+
weight: 400;
79+
}
80+
}
81+
82+
@mixin font-test2 {
83+
font: {
84+
fazily: Arial, sans-serif; // 11
85+
style: normal;
86+
weght: 400; // 12
87+
}
88+
border: {
89+
top: {
90+
left: {
91+
radius: 5px;
92+
}
93+
}
94+
right: 6px solid #fff;
95+
botom: {
96+
right: {
97+
radiu: 5px; // 13
98+
}
99+
}
100+
}
101+
background: {
102+
color: red;
103+
}
104+
background-colr: blue; // 14
105+
font-size: 12rem;
106+
}

0 commit comments

Comments
 (0)