Skip to content

Commit

Permalink
🐛 Fix operators in variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPurdy committed Oct 22, 2016
1 parent a66c707 commit 36b3b8f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
4 changes: 3 additions & 1 deletion lib/rules/variable-name-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ module.exports = {
ast.traverseByType('variable', function (variable) {
var strippedName,
violationMessage = false,
name = variable.first().content;
// Gonzales would parse variable names with operators without this regex i.e. '$mobile-site-gutter*1'
name = variable.first().content.split(/(\*|\+|\/)/)[0];


strippedName = name;

Expand Down
16 changes: 8 additions & 8 deletions tests/rules/variable-name-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('variable name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(15, data.warningCount);
lint.assert.equal(16, data.warningCount);
done();
});
});
Expand All @@ -41,7 +41,7 @@ describe('variable name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(16, data.warningCount);
lint.assert.equal(17, data.warningCount);
done();
});
});
Expand All @@ -55,7 +55,7 @@ describe('variable name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(10, data.warningCount);
lint.assert.equal(11, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -98,7 +98,7 @@ describe('variable name format - scss', function () {
}
]
}, function (data) {
lint.assert.equal(16, data.warningCount);
lint.assert.equal(17, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('variable name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(15, data.warningCount);
lint.assert.equal(16, data.warningCount);
done();
});
});
Expand All @@ -157,7 +157,7 @@ describe('variable name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(10, data.warningCount);
lint.assert.equal(11, data.warningCount);
done();
});
});
Expand All @@ -171,7 +171,7 @@ describe('variable name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(16, data.warningCount);
lint.assert.equal(17, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -214,7 +214,7 @@ describe('variable name format - sass', function () {
}
]
}, function (data) {
lint.assert.equal(16, data.warningCount);
lint.assert.equal(17, data.warningCount);
done();
});
});
Expand Down
4 changes: 4 additions & 0 deletions tests/sass/variable-name-format.sass
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ $_does_NOT-fitSTANDARD: 1

.class
width: $snake_case

// Issue #901 - operators not recognized as separate tokens by gonzales-pe
.content-main
padding: $mobile-site-gutter*1.5
5 changes: 5 additions & 0 deletions tests/sass/variable-name-format.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ $_does_NOT-fitSTANDARD: 1;
.class {
width: $snake_case;
}

// Issue #901 - operators not recognized as separate tokens by gonzales-pe
.content-main {
padding: $mobile-site-gutter*1.5;
}

0 comments on commit 36b3b8f

Please sign in to comment.