Skip to content

Commit

Permalink
Merge pull request #948 from sasstools/release/1.10.2
Browse files Browse the repository at this point in the history
Prepare 1.10.2
  • Loading branch information
DanPurdy authored Nov 9, 2016
2 parents 5da0c04 + 1ecf34d commit f998ec7
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 16 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# Sass Lint Changelog

## v1.10.2

**November 9th, 2016**

**Changes**
* Reverted back to ESlint v2.x to prevent a breaking change in Node < v4

**Fixes**
* Fixed an exception for partial idents in `space-around-operator` [#940](https://github.com/sasstools/sass-lint/pull/940)
* Fixed an issue with negative numbers in `space-around-operator` [#945](https://github.com/sasstools/sass-lint/pull/945)


## v1.10.1

**November 7th, 2016**

**Fixes**

* Fixed an issue with the `--no-exit` `-q` flag not being respected and unhandled errors/exceptions being thrown by the CLI
* Fixed an issue with the `--no-exit` `-q` flag not being respected and unhandled errors/exceptions being thrown by the CLI
* Fixed an issue with variable declarations showing as properties in the `no-duplicate-properties` rule [#937](https://github.com/sasstools/sass-lint/pull/936)
* Fixed an issue with variable declarations showing as properties in the `declarations-before-nesting` rule [#937](https://github.com/sasstools/sass-lint/pull/936)

Expand Down
41 changes: 36 additions & 5 deletions lib/rules/space-around-operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,27 @@ var isNegativeNumber = function (operator, next, previous, doublePrevious) {

// Catch the following:
// $foo: -20;
if (!previous && !next.is('space')) {
return true;
// $foo: -#{$foo}
// $foo: -($foo * 2)
// $foo: -$foo
if (next) {
if (!previous || (previous.is('space') && doublePrevious && !doublePrevious.is('number'))) {
if (
next.is('number') ||
next.is('interpolation') ||
next.is('variable') ||
next.is('parentheses')
) {
return true;
}
}
}

// Catch the following:
// .foo {
// property: -16px;
// }
if (next.is('dimension') || next.is('percentage')) {
if (next && (next.is('dimension') || next.is('percentage'))) {
return true;
}

Expand Down Expand Up @@ -106,7 +118,7 @@ var isUnicode = function (operator, previous) {
// @font-face {
// unicode-range: U+26;
// }
if (previous.is('ident') && previous.content === 'U') {
if (previous && previous.is('ident') && previous.content === 'U') {
return true;
}
}
Expand All @@ -124,7 +136,7 @@ var isUnicode = function (operator, previous) {
var isImport = function (operator, parent) {
if (operator === '/') {

if (parent.is('atrule') && parent.contains('atkeyword')) {
if (parent && parent.is('atrule') && parent.contains('atkeyword')) {
var keyword = parent.first('atkeyword');

if (keyword.contains('ident')) {
Expand All @@ -140,6 +152,21 @@ var isImport = function (operator, parent) {
return false;
};

/**
* Determine if operator is part an ident
*
* @param {string} operator - The operator
* @param {Object} next - The next node
* @param {Object} previous - The previous node
* @returns {bool} true / false
*/
var isPartialIdent = function (operator, next, previous) {
if (operator === '-') {
return next && previous && previous.is('interpolation');
}
return false;
};

/**
* Determine if operator is exception
*
Expand Down Expand Up @@ -169,6 +196,10 @@ var isException = function (operator, parent, i) {
return true;
}

if (isPartialIdent(operator, next, previous)) {
return true;
}

return false;
};

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sass-lint",
"version": "1.10.1",
"version": "1.10.2",
"description": "All Node Sass linter!",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"homepage": "https://github.com/sasstools/sass-lint",
"dependencies": {
"commander": "^2.8.1",
"eslint": "^3.9.1",
"eslint": "^2.7.0",
"front-matter": "2.1.0",
"fs-extra": "^1.0.0",
"glob": "^7.0.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/rules/space-around-operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('space around operator - scss', function () {
}
]
}, function (data) {
lint.assert.equal(92, data.warningCount);
lint.assert.equal(94, data.warningCount);
done();
});
});
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('space around operator - sass', function () {
}
]
}, function (data) {
lint.assert.equal(86, data.warningCount);
lint.assert.equal(88, data.warningCount);
done();
});
});
Expand Down
32 changes: 29 additions & 3 deletions tests/sass/space-around-operator.sass
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ $qux: (2 +1)
$foo: scale-color($foo, $lightness: -14%)

$foobar: #{$foo}-#{$bar}
$foobar: #{$foo}-4

.foo
top: -10px

Expand Down Expand Up @@ -474,13 +477,36 @@ h1
unicode-range: U+26
unicode-range: U+0-7F
unicode-range: U+0025-00FF
// TODO: Wildcard currently causes gonzales to fail
// unicode-range: U+4??;
// unicode-range: U+0025-00FF, U+4??;
unicode-range: U+4??
unicode-range: U+0025-00FF, U+4??

// Negative numbers
.foo
bottom: $var / -2

// Imports
@import bar/foo

@if -1
$bar: 1

@if -$foo
$bar: 1

@if -#{$foo}
$bar: 1

@if -($foo * 2)
$bar: 1

@for $i from 0 through -1
$bar: 1

@for $i from 0 through -$foo
$bar: 1

@for $i from 0 through -#{$foo}
$bar: 1

@for $i from 0 through -($foo * 2)
$bar: 1
40 changes: 37 additions & 3 deletions tests/sass/space-around-operator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ $norf: (5 % 2);

$foo: scale-color($foo, $lightness: -14%);

$foobar: #{$foo}-#{$bar};
$foobar: #{$foo}-4;

.foo {
top: -10px;
}
Expand Down Expand Up @@ -492,9 +495,8 @@ $norf: (5 % 2);
unicode-range: U+26;
unicode-range: U+0-7F;
unicode-range: U+0025-00FF;
// TODO: Wildcard currently causes gonzales to fail
// unicode-range: U+4??;
// unicode-range: U+0025-00FF, U+4??;
unicode-range: U+4??;
unicode-range: U+0025-00FF, U+4??;
}

// Negative numbers
Expand All @@ -504,3 +506,35 @@ $norf: (5 % 2);

// Imports
@import 'bar/foo';

@if -1 {
$bar: 1;
}

@if -$foo {
$bar: 1;
}

@if -#{$foo} {
$bar: 1;
}

@if -($foo * 2) {
$bar: 1;
}

@for $i from 0 through -1 {
$bar: 1;
}

@for $i from 0 through -$foo {
$bar: 1;
}

@for $i from 0 through -#{$foo} {
$bar: 1;
}

@for $i from 0 through -($foo * 2) {
$bar: 1;
}

0 comments on commit f998ec7

Please sign in to comment.