Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with parenthesis values in shorthand values #751

Merged
merged 1 commit into from
Jun 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/rules/shorthand-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ var scanValue = function (node) {
fullVal = func + '(' + args + ')';
}

else if (val.is('parentheses')) {
fullVal += '(' + scanValue(val).join(' ') + ')';
}

else if (val.is('space')) {
// This is a non value character such as a space
// We want to start another value here
Expand Down
32 changes: 16 additions & 16 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(64, data.warningCount);
lint.assert.equal(76, data.warningCount);
done();
});
});
Expand All @@ -28,7 +28,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(27, data.warningCount);
lint.assert.equal(32, data.warningCount);
done();
});
});
Expand All @@ -44,7 +44,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(32, data.warningCount);
lint.assert.equal(38, data.warningCount);
done();
});
});
Expand All @@ -60,7 +60,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(38, data.warningCount);
lint.assert.equal(45, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(48, data.warningCount);
lint.assert.equal(57, data.warningCount);
done();
});
});
Expand All @@ -109,7 +109,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(54, data.warningCount);
lint.assert.equal(64, data.warningCount);
done();
});
});
Expand All @@ -126,7 +126,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(48, data.warningCount);
lint.assert.equal(57, data.warningCount);
done();
});
});
Expand All @@ -144,7 +144,7 @@ describe('shorthand values - scss', function () {
}
]
}, function (data) {
lint.assert.equal(64, data.warningCount);
lint.assert.equal(76, 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(64, data.warningCount);
lint.assert.equal(76, data.warningCount);
done();
});
});
Expand All @@ -177,7 +177,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(27, data.warningCount);
lint.assert.equal(32, data.warningCount);
done();
});
});
Expand All @@ -193,7 +193,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(32, data.warningCount);
lint.assert.equal(38, data.warningCount);
done();
});
});
Expand All @@ -209,7 +209,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(38, data.warningCount);
lint.assert.equal(45, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(48, data.warningCount);
lint.assert.equal(57, data.warningCount);
done();
});
});
Expand All @@ -258,7 +258,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(54, data.warningCount);
lint.assert.equal(64, data.warningCount);
done();
});
});
Expand All @@ -275,7 +275,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(48, data.warningCount);
lint.assert.equal(57, data.warningCount);
done();
});
});
Expand All @@ -293,7 +293,7 @@ describe('shorthand values - sass', function () {
}
]
}, function (data) {
lint.assert.equal(64, data.warningCount);
lint.assert.equal(76, data.warningCount);
done();
});
});
Expand Down
28 changes: 28 additions & 0 deletions tests/sass/shorthand-values.sass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
border-width: inherit
margin: 1rem
padding: 1px
padding: ($gutter / 2);

.value-two-ident
border-color: red red
Expand All @@ -13,6 +14,7 @@
border-width: inherit inherit
margin: 1rem 1rem
padding: 1px 1px
padding: ($gutter / 2) ($gutter / 2)

.value-two-diff
border-color: red blue
Expand All @@ -21,6 +23,7 @@
border-width: inherit 2em
margin: 1rem 2rem
padding: 1px 2px
padding: ($gutter / 2) ($gutter / 3)

.value-three-ident
border-color: red red red
Expand All @@ -29,6 +32,7 @@
border-width: inherit inherit inherit
margin: 1rem 1rem 1rem
padding: 1px 1px 1px
padding: ($gutter / 2) ($gutter / 2) ($gutter / 2)

.value-three-diff-one
border-color: blue red red
Expand All @@ -37,6 +41,7 @@
border-width: 10px inherit inherit
margin: 2rem 1rem 1rem
padding: 2px 1px 1px
padding: ($gutter / 3) ($gutter / 2) ($gutter / 2)

.value-three-diff-two
border-color: red blue red
Expand All @@ -45,6 +50,7 @@
border-width: inherit 10px inherit
margin: 1rem 2rem 1rem
padding: 1px 2px 1px
padding: ($gutter / 2) ($gutter / 3) ($gutter / 2)

.value-three-diff-three
border-color: red red blue
Expand All @@ -53,6 +59,7 @@
border-width: inherit inherit 10px
margin: 1rem 1rem 2rem
padding: 1px 1px 2px
padding: ($gutter / 2) ($gutter / 2) ($gutter / 3)

.value-three-diff-four
border-color: red blue orange
Expand All @@ -61,6 +68,7 @@
border-width: inherit 10px 20px
margin: 1rem 2rem 3rem
padding: 1px 2px 3px
padding: ($gutter / 2) ($gutter / 3) ($gutter / 4)

.value-four-ident
border-color: red red red red
Expand All @@ -69,6 +77,7 @@
border-width: inherit inherit inherit inherit
margin: 1rem 1rem 1rem 1rem
padding: 1px 1px 1px 1px
padding: ($gutter / 2) ($gutter / 2) ($gutter / 2) ($gutter / 2)

.value-four-diff-one
border-color: blue red red red
Expand All @@ -77,6 +86,7 @@
border-width: 10px inherit inherit inherit
margin: 2rem 1rem 1rem 1rem
padding: 2px 1px 1px 1px
padding: ($gutter / 3) ($gutter / 2) ($gutter / 2) ($gutter / 2)

.value-four-diff-two
border-color: red blue red red
Expand All @@ -85,6 +95,7 @@
border-width: inherit 10px inherit inherit
margin: 1rem 2rem 1rem 1rem
padding: 1px 2px 1px 1px
padding: ($gutter / 2) ($gutter / 3) ($gutter / 2) ($gutter / 2)

.value-four-diff-three
border-color: red red blue red
Expand All @@ -93,6 +104,7 @@
border-width: inherit inherit 10px inherit
margin: 1rem 1rem 2rem 1rem
padding: 1px 1px 2px 1px
padding: ($gutter / 2) ($gutter / 2) ($gutter / 3) ($gutter / 2)

.value-four-diff-four
border-color: red red red blue
Expand All @@ -101,6 +113,7 @@
border-width: inherit inherit inherit 10px
margin: 1rem 1rem 1rem 2rem
padding: 1px 1px 1px 2px
padding: ($gutter / 2) ($gutter / 2) ($gutter / 2) ($gutter / 3)

.value-four-diff-five
border-color: red blue red blue
Expand All @@ -109,6 +122,7 @@
border-width: inherit 10px inherit 10px
margin: 1rem 2rem 1rem 2rem
padding: 1px 2px 1px 2px
padding: ($gutter / 2) ($gutter / 3) ($gutter / 2) ($gutter / 3)

.value-four-diff-six
border-color: red blue orange green
Expand All @@ -117,6 +131,7 @@
border-width: inherit 10px 20px 30px
margin: 1rem 2rem 3rem 4rem
padding: 1px 2px 3px 4px
padding: ($gutter / 2) ($gutter / 3) ($gutter / 4) ($gutter / 5)

.value-four-ident
border-color: $red $red $red $red
Expand All @@ -131,45 +146,58 @@
border-width: none
margin: 0 0px
padding: 1px 0
padding: ($gutter / 2) 0

.value-mixed
border-color: $red 1px red 1rem
border-radius: 1px 1pc 1rem
border-style: $red red
border-width: 1px 1pc
padding: ($gutter / 2) 1px

.value-negative
margin: -1px
padding: -($gutter / 2)

.value-two-negative
margin: -1px -1px
padding: -($gutter / 2) -($gutter / 2)

.value-two-diff-negative
margin: -1px 1px
padding: -($gutter / 2) ($gutter / 2)

.value-three-diff-one-negative
margin: -1px -2px -1px
padding: -($gutter / 2) -($gutter / 3) -($gutter / 2)

.value-three-diff-two-negative
margin: -1px -2px 1px
padding: -($gutter / 2) -($gutter / 3) ($gutter / 2)

.value-four-negative
margin: -1px -1px -1px -1px
padding: -($gutter / 2) -($gutter / 2) -($gutter / 2) -($gutter / 2)

.value-four-diff-one-negative
margin: -1px -1px -1px 1px
padding: -($gutter / 2) -($gutter / 2) -($gutter / 2) ($gutter / 2)

.value-four-diff-two-negative
margin: -1px 1px -1px 1px
padding: -($gutter / 2) ($gutter / 2) -($gutter / 2) ($gutter / 2)

.value-four-diff-three-negative
margin: -1px 1px 1px 1px
padding: -($gutter / 2) ($gutter / 2) ($gutter / 2) ($gutter / 2)

.value-four-diff-four-negative
margin: -1px 2px 3px -4px
padding: -($gutter / 2) ($gutter / 3) ($gutter / 4) -($gutter / 5)

.value-four-diff-four-negative-mixed
margin: -1px 1px -1rem -1rem
padding: -($gutter / 2) ($gutter / 2) -($gutter-ex / 2) -($gutter-ex / 2)

.value-percentage
margin: 1%
Expand Down
Loading