Skip to content

Commit

Permalink
Merge pull request #836 from DanPurdy/feature/shorthand-value-fixes
Browse files Browse the repository at this point in the history
Issue with hex colours in shorthand values
  • Loading branch information
DanPurdy authored Aug 25, 2016
2 parents 0002ea7 + d7e92b3 commit 69efff8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/rules/shorthand-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ var scanValue = function (node) {
fullVal += '#{' + scanValue(val.content) + '}';
}

else if (val.is('color')) {
fullVal += '#' + val.content + '';
}

else if (val.is('operator') || val.is('ident') || val.is('number') || val.is('unaryOperator')) {
fullVal += val.content;
}
Expand Down
28 changes: 14 additions & 14 deletions tests/rules/shorthand-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('shorthand values - scss', function () {
lint.test(file, {
'shorthand-values': 1
}, function (data) {
lint.assert.equal(76, data.warningCount);
lint.assert.equal(77, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(38, data.warningCount);
lint.assert.equal(39, data.warningCount);
done();
});
});
Expand All @@ -60,7 +60,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(45, data.warningCount);
lint.assert.equal(46, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(57, data.warningCount);
lint.assert.equal(58, data.warningCount);
done();
});
});
Expand All @@ -109,7 +109,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(64, data.warningCount);
lint.assert.equal(65, data.warningCount);
done();
});
});
Expand All @@ -126,7 +126,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(57, data.warningCount);
lint.assert.equal(58, data.warningCount);
done();
});
});
Expand All @@ -144,7 +144,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(76, data.warningCount);
lint.assert.equal(77, data.warningCount);
done();
});
});
Expand All @@ -161,7 +161,7 @@ describe('shorthand values - sass', function () {
lint.test(file, {
'shorthand-values': 1
}, function (data) {
lint.assert.equal(76, data.warningCount);
lint.assert.equal(77, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -193,7 +193,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(38, data.warningCount);
lint.assert.equal(39, data.warningCount);
done();
});
});
Expand All @@ -209,7 +209,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(45, data.warningCount);
lint.assert.equal(46, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(57, data.warningCount);
lint.assert.equal(58, data.warningCount);
done();
});
});
Expand All @@ -258,7 +258,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(64, data.warningCount);
lint.assert.equal(65, data.warningCount);
done();
});
});
Expand All @@ -275,7 +275,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(57, data.warningCount);
lint.assert.equal(58, data.warningCount);
done();
});
});
Expand All @@ -293,7 +293,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(76, data.warningCount);
lint.assert.equal(77, data.warningCount);
done();
});
});
Expand Down
8 changes: 8 additions & 0 deletions tests/sass/shorthand-values.sass
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,11 @@

.value-four-diff-four-interp-function-mixed
margin: calc(#{$doc-header-height} + #{$global-whitespace--regular}) calc(#{$doc-header-height} + #{$global-whitespace--regular}) calc(#{$doc-header-height} - #{$global-whitespace--regular}) calc(#{$doc-header-height} - #{$global-whitespace--regular})

// issue #772 - Issue with colours not being correctly interpreted
// should be ignored;
.test
border-color: transparent transparent transparent #095b97

.test
border-color: transparent #095b97 transparent #095b97
10 changes: 10 additions & 0 deletions tests/sass/shorthand-values.scss
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,13 @@
.value-four-diff-four-interp-function-mixed {
margin: calc(#{$doc-header-height} + #{$global-whitespace--regular}) calc(#{$doc-header-height} + #{$global-whitespace--regular}) calc(#{$doc-header-height} - #{$global-whitespace--regular}) calc(#{$doc-header-height} - #{$global-whitespace--regular});
}

// issue #772 - Issue with colours not being correctly interpreted
// should be ignored;
.test {
border-color: transparent transparent transparent #095b97;
}

.test {
border-color: transparent #095b97 transparent #095b97;
}

0 comments on commit 69efff8

Please sign in to comment.