Skip to content

Commit

Permalink
Merge pull request #844 from sasstools/release/1.9.1
Browse files Browse the repository at this point in the history
Release/1.9.1
  • Loading branch information
DanPurdy authored Aug 25, 2016
2 parents 38d43ad + a6db796 commit 01bdb5a
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 61 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Sass Lint Changelog

## v1.9.1

**August 25, 2016**

**Fixes**
* Fixed an issue with nth selectors in the `no-mergeable-selectors` rule [#834](https://github.com/sasstools/sass-lint/issues/834)
* Fixed an issue with atrule arguments containing functions in the `no-mergeable-selectors` rule [#826](https://github.com/sasstools/sass-lint/issues/826)
* Fixed an issue with hex colors being ignored in the `shorthand-values` rule [#836](https://github.com/sasstools/sass-lint/pull/836)

## v1.9.0

**August 18, 2016**

**Fixes**
* Fixed an issue with teh indentation rule when it encountered at-rules with no block immediately preceeding a map [#779](https://github.com/sasstools/sass-lint/issues/779) [#783](https://github.com/sasstools/sass-lint/issues/783)
* Fixed an issue with the indentation rule when it encountered at-rules with no block immediately preceding a map [#779](https://github.com/sasstools/sass-lint/issues/779) [#783](https://github.com/sasstools/sass-lint/issues/783)
* Fixed an issue in `single-lint-per-selector` where inline comments were seen as selectors [#789](https://github.com/sasstools/sass-lint/issues/789)
* Fixed an issue with interpolation in placeholders within the `bem-depth` rule [#782](https://github.com/sasstools/sass-lint/issues/782)
* Removed duplicated code from `no-mergeable-selectors` to helper methods
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,4 @@ Our AST is [Gonzales-PE](https://github.com/tonyganch/gonzales-pe/tree/dev). Eac
* [Brackets](https://github.com/petetnt/brackets-sass-lint)
* [IntelliJ IDEA, RubyMine, WebStorm, PhpStorm, PyCharm](https://github.com/idok/sass-lint-plugin)
* [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=glen-84.sass-lint)
* [Vim](https://github.com/gcorne/vim-sass-lint)
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
66 changes: 38 additions & 28 deletions lib/selector-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ var simpleIdents = [
'attributeMatch'
];

var subSelectors = [
'parentSelectorExtension',
'attributeName',
'attributeValue',
'dimension',
'selector',
'function'
];

/**
* Adds grammar around our content blocks to construct selectors with
* more readable formats.
Expand Down Expand Up @@ -61,36 +70,44 @@ var constructSubSelector = function (val, prefix, suffix, constructSelector) {
var constructSelector = function (val) {
var content = null;

if (val.is('id')) {
content = addGrammar(val, '#', '');
if (val.is('arguments')) {
content = constructSubSelector(val, '(', ')', constructSelector);
}

else if (val.is('atkeyword')) {
content = constructSubSelector(val, '@', '', constructSelector);
}

else if (val.is('attributeSelector')) {
content = constructSubSelector(val, '[', ']', constructSelector);
}

else if (val.is('class')) {
content = addGrammar(val, '.', '');
}

else if (simpleIdents.indexOf(val.type) !== -1) {
content = val.content;
else if (val.is('id')) {
content = addGrammar(val, '#', '');
}

else if (val.is('arguments')) {
content = constructSubSelector(val, '(', ')', constructSelector);
else if (val.is('interpolation')) {
content = constructSubSelector(val, '#{', '}', constructSelector);
}

else if (val.is('attributeSelector')) {
content = constructSubSelector(val, '[', ']', constructSelector);
else if (val.is('nth')) {
content = addGrammar(val, '(', ')');
}

else if (val.is('atkeyword')) {
content = constructSubSelector(val, '@', '', constructSelector);
else if (val.is('nthSelector')) {
content = constructSubSelector(val, ':', '', constructSelector);
}

else if (val.is('placeholder')) {
content = constructSubSelector(val, '%', '', constructSelector);
else if (val.is('parentheses')) {
content = constructSubSelector(val, '(', ')', constructSelector);
}

else if (val.is('variable')) {
content = constructSubSelector(val, '$', '', constructSelector);
else if (val.is('placeholder')) {
content = constructSubSelector(val, '%', '', constructSelector);
}

else if (val.is('pseudoClass')) {
Expand All @@ -101,29 +118,22 @@ var constructSelector = function (val) {
content = addGrammar(val, '::', '');
}

else if (val.is('nth')) {
content = addGrammar(val, '(', ')');
}

else if (val.is('nthSelector')) {
content = constructSubSelector(val, ':', '', constructSelector);
else if (val.is('space')) {
content = ' ';
}

else if (val.is('parentheses')) {
content = constructSubSelector(val, '(', ')', constructSelector);
else if (val.is('variable')) {
content = constructSubSelector(val, '$', '', constructSelector);
}

else if (val.is('space')) {
content = ' ';
else if (simpleIdents.indexOf(val.type) !== -1) {
content = val.content;
}

else if (val.is('parentSelectorExtension') || val.is('attributeName') || val.is('attributeValue') || val.is('dimension')) {
else if (subSelectors.indexOf(val.type) !== -1) {
content = constructSubSelector(val, '', '', constructSelector);
}

else if (val.is('interpolation')) {
content = constructSubSelector(val, '#{', '}', constructSelector);
}
return content;
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sass-lint",
"version": "1.9.0",
"version": "1.9.1",
"description": "All Node Sass linter!",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions tests/rules/no-mergeable-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('no mergeable selectors - scss', function () {
lint.test(file, {
'no-mergeable-selectors': 1
}, function (data) {
lint.assert.equal(22, data.warningCount);
lint.assert.equal(24, data.warningCount);
done();
});
});
Expand All @@ -25,7 +25,7 @@ describe('no mergeable selectors - scss', function () {
}
]
}, function (data) {
lint.assert.equal(21, data.warningCount);
lint.assert.equal(23, data.warningCount);
done();
});
});
Expand All @@ -40,7 +40,7 @@ describe('no mergeable selectors - sass', function () {
lint.test(file, {
'no-mergeable-selectors': 1
}, function (data) {
lint.assert.equal(20, data.warningCount);
lint.assert.equal(21, data.warningCount);
done();
});
});
Expand All @@ -57,7 +57,7 @@ describe('no mergeable selectors - sass', function () {
}
]
}, function (data) {
lint.assert.equal(19, data.warningCount);
lint.assert.equal(20, data.warningCount);
done();
});
});
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
26 changes: 14 additions & 12 deletions tests/sass/no-mergeable-selectors.sass
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ ul ~ p
.bar
content: ''

// Issue #834 - selectors/typeselectors not properly recognised
.fake-field
tbody
tr:nth-child(even)
background: lighten($theme-color-primary, 50%)
tr:nth-child(odd)
background: #FFFFFF

.not-test
&:not(:first-child)
border-left: none

&:not(:first-child)
border-left: 2px

.bar
@media (max-width: 40em) and (min-width: 20em) and (orientation: landscape)
Expand Down Expand Up @@ -237,15 +251,3 @@ ul ~ p
// opacity: 1
// Issue #703 - Interpolation in selector - ignored in Sass syntax for now due to gonzales issue
.navigation
@media #{$media-query-lg-up}
.nav-item
display: inline-block
@media #{$media-query-md-down}
// should not merge with the media query above
.nav-item
display: block
// should merge with the ruleset directly above
.nav-item
color: $blue
Loading

0 comments on commit 01bdb5a

Please sign in to comment.