Skip to content

Commit

Permalink
Merge pull request #1122 from sasstools/feature_fix-custom-var-misspe…
Browse files Browse the repository at this point in the history
…lled

Fix custom properties in declarations
  • Loading branch information
DanPurdy authored Aug 30, 2017
2 parents cca399c + 56ca1df commit 373d345
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/rules/no-misspelled-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var buildPartialProperty = function (valBlock, currentProperty) {
var value = node.first('value');
skipProps++;

if (prop.first().is('ident')) {
if (prop && prop.first().is('ident')) {
if (value.contains('block')) {
propList = propList.concat(
buildPartialProperty(value.first('block'),
Expand Down Expand Up @@ -77,7 +77,10 @@ module.exports = {

ast.traverseByType('declaration', function (node) {
var prop = node.first('property');
var containsInterp = prop.contains('interpolation');
// declaration may include custom properties etc, check that prop is defined here
if (!prop) {
return false;
}
// If we've already checked declarations in a multiline we can skip those decs here
if (skipProps) {
skipProps -= 1;
Expand Down Expand Up @@ -123,7 +126,7 @@ module.exports = {
* If our property name contains interpolation we need to make a best guess by using a
* partial string match as we can't be 100% on the context
*/
if (containsInterp) {
if (prop.contains('interpolation')) {
if (!helpers.isPartialStringMatch(curProperty, propertyList)) {
result = helpers.addUnique(result, {
'ruleId': parser.rule.name,
Expand Down
3 changes: 3 additions & 0 deletions tests/sass/no-misspelled-properties.sass
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ $red: #ff0000
color: red
background-colr: blue
font-size: 12rem

.element
--main-bg-color: brown
4 changes: 4 additions & 0 deletions tests/sass/no-misspelled-properties.scss
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ $red: #ff0000;
background-colr: blue; // 14
font-size: 12rem;
}

.element {
--main-bg-color: brown;
}

0 comments on commit 373d345

Please sign in to comment.