Skip to content

Commit

Permalink
🐛 Allow custom properties as variables
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPurdy committed Sep 2, 2017
1 parent 31d8343 commit f142793
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/rules/variable-for-property.js
Expand Up @@ -14,10 +14,10 @@ var whitelistedValues = ['inherit', 'initial', 'transparent', 'none', 'currentCo
*/
var isValidProperty = function (propertyElem) {
if (propertyElem) {
if (propertyElem.type === 'variable') {
if (propertyElem.is('variable')) {
return true;
}
else if (propertyElem.type === 'ident' && whitelistedValues.indexOf(propertyElem.content) !== -1) {
else if (propertyElem.is('ident') && whitelistedValues.indexOf(propertyElem.content) !== -1) {
return true;
}
}
Expand Down Expand Up @@ -46,9 +46,14 @@ var isIgnoredType = function (propertyElem) {
* @returns {boolean} Whether the property is an ignored type or not
*/
var isIgnoredFunction = function (propertyElem, allowMap, functionWhitelist) {
if (propertyElem && propertyElem.type === 'function') {
if (propertyElem && propertyElem.is('function')) {
var funcIdent = propertyElem.first('ident');

// allow custom properties as values
if (funcIdent.content === 'var') {
return true;
}

if (allowMap && funcIdent.content === 'map-get') {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/sass/variable-for-property.sass
Expand Up @@ -46,3 +46,7 @@
.func-name-test
color: my-map-func(blue, light)

.custom-prop
// ensure custom properties are valid
color: var(--my-prop)
4 changes: 4 additions & 0 deletions tests/sass/variable-for-property.scss
Expand Up @@ -51,3 +51,7 @@
.func-name-test {
color: my-map-func(blue, light);
}

.custom-prop {
color: var(--my-prop); // ensure custom properties are valid
}

0 comments on commit f142793

Please sign in to comment.