Skip to content

Commit

Permalink
Merge pull request #938 from DanPurdy/release/1.10.1
Browse files Browse the repository at this point in the history
Prepare 1.10.1
  • Loading branch information
DanPurdy authored Nov 7, 2016
2 parents 3797a71 + 65f4a3f commit 5da0c04
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 11 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Sass Lint Changelog

## 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 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)

## v1.10.0

**November 6th, 2016**
Expand Down
34 changes: 26 additions & 8 deletions bin/sass-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@ var program = require('commander'),
lint = require('../index');

var configPath,
configOptions = {};
config,
configOptions = {},
exitCode = 0;

var detectPattern = function (pattern) {
var detects;
var tooManyWarnings = function (detects, userConfig) {
var warningCount = lint.warningCount(detects).count;

detects = lint.lintFiles(pattern, configOptions, configPath);
return warningCount > 0 && warningCount > userConfig.options['max-warnings'];
};

var detectPattern = function (pattern, userConfig) {
var detects = lint.lintFiles(pattern, configOptions, configPath);

if (program.verbose) {
lint.outputResults(detects, configOptions, configPath);
}

lint.failOnError(detects, configOptions, configPath);
if (lint.errorCount(detects).count || tooManyWarnings(detects, userConfig)) {
exitCode = 1;
}

if (program.exit) {
lint.failOnError(detects, configOptions, configPath);
}
};

program
Expand All @@ -33,7 +45,6 @@ program
.option('--max-warnings [integer]', 'Number of warnings to trigger nonzero exit code')
.parse(process.argv);

// Create "options" and "files" dictionaries if they don't exist
configOptions.files = configOptions.files || {};
configOptions.options = configOptions.options || {};

Expand Down Expand Up @@ -61,11 +72,18 @@ if (program.maxWarnings && program.maxWarnings !== true) {
configOptions.options['max-warnings'] = program.maxWarnings;
}

// load our config here so we only load it once for each file
config = lint.getConfig(configOptions, configPath);

if (program.args.length === 0) {
detectPattern(null);
detectPattern(null, config);
}
else {
program.args.forEach(function (path) {
detectPattern(path);
detectPattern(path, config);
});
}

process.on('exit', function () {
process.exit(exitCode); // eslint-disable-line no-process-exit
});
3 changes: 2 additions & 1 deletion docs/options/max-warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

An error will be thrown if the total number of warnings exceeds the `max-warnings` setting.

> Please note, if you're using this option with the sass-lint CLI and you're specifying the `--no-exit / -q` option too, you will not see an error but an error code of 1 will still be thrown.
## Examples

This can be set as a command-line option:
Expand All @@ -26,4 +28,3 @@ var sassLint = require('sass-lint'),
results = sassLint.lintFiles('sass/**/*.scss', config)
sassLint.failOnError(results, config);
```

8 changes: 8 additions & 0 deletions lib/rules/declarations-before-nesting.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ module.exports = {
}

if (item.is('declaration')) {
var property = item.content[0];

if (property && property.is('property')) {
if (property.content[0] && property.content[0].is('variable')) {
return;
}
}

declarationIndex = j;
declaration = item;
}
Expand Down
9 changes: 8 additions & 1 deletion lib/rules/no-duplicate-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ module.exports = {

declaration.eachFor('property', function (item) {
var property = '';
item.content.forEach(function (subItem) {

// Check if declaration is actually a variable declaration
if (item.content[0] && item.content[0].is('variable')) {
return;
}

item.forEach(function (subItem) {
// Although not a selector the method here helps us construct the proper property name
// taking into account any interpolation etc
property += selectorHelpers.constructSelector(subItem);
});

if (properties.indexOf(property) !== -1 && properties.length >= 1) {
if (parser.options.exclude.indexOf(property) !== -1 && properties[properties.length - 1] !== property) {
warnMessage = 'Excluded duplicate properties must directly follow each other.';
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.10.0",
"version": "1.10.1",
"description": "All Node Sass linter!",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions tests/sass/declarations-before-nesting.sass
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@
content: 'baz'

content: 'baz'

// issue #935 - ignore variables
+foo
#{$bar}
content: 'foobar'

$baz: 'qux'
9 changes: 9 additions & 0 deletions tests/sass/declarations-before-nesting.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@

content: 'baz';
}

// issue #935 - ignore variables
@mixin foo {
#{$bar} {
content: 'foobar';
}

$baz: 'qux';
}
5 changes: 5 additions & 0 deletions tests/sass/no-duplicate-properties.sass
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ $paint-border-2: left
border-#{$paint-border-1}: $size solid $color
border-#{$paint-border-2}: $size solid $color
border-#{$paint-border-2}: $size solid $color

// issue #935 - ignore variables
+foo
$i: 0
$i: 1
6 changes: 6 additions & 0 deletions tests/sass/no-duplicate-properties.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ $paint-border-2: left;
border-#{$paint-border-2}: $size solid $color;
border-#{$paint-border-2}: $size solid $color;
}

// issue #935 - ignore variables
@mixin foo {
$i: 0;
$i: 1;
}

0 comments on commit 5da0c04

Please sign in to comment.