Comparing version 2.1.0 to 2.1.1
# Changelog | ||
## 2.1.1 (2016-09-11) | ||
* Fixed a false positive in `newlineAfterBlock` with nested blocks. ([e64c360](https://github.com/lesshint/lesshint/commit/e64c3600abcaef740d04c3154d074accc39395af)) | ||
* Fixed an issue where `singleLinePerSelector` would report the same selector multiple times. ([507e89](https://github.com/lesshint/lesshint/commit/507e89a3bb02e5789126221cd1cbca24a037b18b)) | ||
* Fixed an issue in `spaceBeforeBrace` where indented blocks would be erroneously reported with the `new_line` setting. ([45d166e](https://github.com/lesshint/lesshint/commit/45d166e250a81338ce0aeb0d36c3d9cf589d72df)) | ||
* Fixed an issue in `spaceBeforeBrace` where the `one_space` option would erroneously allow other spaces than just a single one. ([45d166e](https://github.com/lesshint/lesshint/commit/45d166e250a81338ce0aeb0d36c3d9cf589d72df)) | ||
* Removed old `spaceBeforeComma` setting in the default config. ([d7bb4f6](https://github.com/lesshint/lesshint/commit/d7bb4f6a0021aa6c1d9e83edacd261519d9a3b97)) | ||
## 2.1.0 (2016-09-02) | ||
@@ -3,0 +10,0 @@ * Added `maxCharPerLine` linter. ([af69e95](https://github.com/lesshint/lesshint/commit/af69e9545ac8fc89ff508064741d77e21e29c926)) |
@@ -159,7 +159,2 @@ { | ||
"spaceBeforeComma": { | ||
"enabled": true, | ||
"style": "no_space" | ||
}, | ||
"spaceBetweenParens": { | ||
@@ -166,0 +161,0 @@ "enabled": true, |
@@ -38,3 +38,3 @@ 'use strict'; | ||
if (prev.type === 'comment') { | ||
if (Object.is(prev, parent.first) || prev.raws.before === '\n\n') { | ||
if (Object.is(prev, parent.first) || prev.raws.before.indexOf('\n\n') !== -1) { | ||
return; | ||
@@ -44,3 +44,3 @@ } | ||
if (node.raws.before !== '\n\n') { | ||
if (node.raws.before.indexOf('\n\n') === -1) { | ||
return [{ | ||
@@ -47,0 +47,0 @@ message: this.message |
@@ -22,5 +22,12 @@ 'use strict'; | ||
tree.each(function (selector) { | ||
var reported = false; | ||
selector.each(function (thing) { | ||
var value = thing.toString().trim(); | ||
// This selector is already reported, bail | ||
if (reported) { | ||
return; | ||
} | ||
switch (config.style) { | ||
@@ -39,2 +46,4 @@ case '18f': | ||
if (!valid && tree.nodes.length > 1 && node.selector.indexOf('\n') === -1) { | ||
reported = true; | ||
results.push({ | ||
@@ -41,0 +50,0 @@ column: node.source.start.column + thing.source.start.column - 1, |
@@ -15,5 +15,5 @@ 'use strict'; | ||
var styles = { | ||
'new_line': /^\n$/, | ||
'new_line': /^\n *\t*$/, | ||
'no_space': /^$/, | ||
'one_space': /^\s$/ | ||
'one_space': /^ $/ | ||
}; | ||
@@ -20,0 +20,0 @@ |
{ | ||
"name": "lesshint", | ||
"description": "A tool to aid you in writing clean and consistent Less.", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"main": "./lib/lesshint.js", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -119,3 +119,21 @@ 'use strict'; | ||
}); | ||
it('should not report nested blocks with a preceding new line', function () { | ||
var source = ''; | ||
source += '.foo {'; | ||
source += ' color: red;'; | ||
source += '\n\n'; | ||
source += ' .bar {'; | ||
source += ' color: red;'; | ||
source += ' }'; | ||
source += '}'; | ||
return spec.parse(source, function (ast) { | ||
var result = spec.linter.lint({}, ast.root.last); | ||
expect(result).to.be.undefined; | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -99,3 +99,25 @@ 'use strict'; | ||
}); | ||
it('should not report the same selector multiple times. #239', function () { | ||
var source = '.foo .bar, .bar .foo {}'; | ||
var expected = [ | ||
{ | ||
column: 1, | ||
line: 1, | ||
message: 'Each selector should be on its own line.' | ||
}, | ||
{ | ||
column: 12, | ||
line: 1, | ||
message: 'Each selector should be on its own line.' | ||
} | ||
]; | ||
return spec.parse(source, function (ast) { | ||
var result = spec.linter.lint({}, ast.root.first); | ||
expect(result).to.deep.equal(expected); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -188,2 +188,59 @@ 'use strict'; | ||
it('should not allow multiple spaces when "style" is "one_space"', function () { | ||
var source = '.foo {}'; | ||
var expected = [{ | ||
column: 5, | ||
line: 1, | ||
message: 'Opening curly brace should be preceded by one space.' | ||
}]; | ||
var options = { | ||
style: 'one_space' | ||
}; | ||
return spec.parse(source, function (ast) { | ||
var result = spec.linter.lint(options, ast.root.first); | ||
expect(result).to.deep.equal(expected); | ||
}); | ||
}); | ||
it('should not allow new line when "style" is "one_space"', function () { | ||
var source = '.foo, .bar\n{}'; | ||
var expected = [{ | ||
column: 11, | ||
line: 1, | ||
message: 'Opening curly brace should be preceded by one space.' | ||
}]; | ||
var options = { | ||
style: 'one_space' | ||
}; | ||
return spec.parse(source, function (ast) { | ||
var result = spec.linter.lint(options, ast.root.first); | ||
expect(result).to.deep.equal(expected); | ||
}); | ||
}); | ||
it('should not allow tab when "style" is "one_space"', function () { | ||
var source = '.foo, .bar\t{}'; | ||
var expected = [{ | ||
column: 11, | ||
line: 1, | ||
message: 'Opening curly brace should be preceded by one space.' | ||
}]; | ||
var options = { | ||
style: 'one_space' | ||
}; | ||
return spec.parse(source, function (ast) { | ||
var result = spec.linter.lint(options, ast.root.first); | ||
expect(result).to.deep.equal(expected); | ||
}); | ||
}); | ||
it('should not allow multiple spaces when multiple simple selectors are used and "style" is "one_space"', function () { | ||
@@ -234,2 +291,28 @@ var source = '.foo, .bar {}'; | ||
it('should allow one new line followed by spaces when "style" is "new_line"', function () { | ||
var source = '.foo\n {}'; | ||
var options = { | ||
style: 'new_line' | ||
}; | ||
return spec.parse(source, function (ast) { | ||
var result = spec.linter.lint(options, ast.root.first); | ||
expect(result).to.be.undefined; | ||
}); | ||
}); | ||
it('should allow one new line followed by tabs when "style" is "new_line"', function () { | ||
var source = '.foo\n\t\t{}'; | ||
var options = { | ||
style: 'new_line' | ||
}; | ||
return spec.parse(source, function (ast) { | ||
var result = spec.linter.lint(options, ast.root.first); | ||
expect(result).to.be.undefined; | ||
}); | ||
}); | ||
it('should not allow multiple new lines when "style" is "new_line"', function () { | ||
@@ -236,0 +319,0 @@ var source = '.foo\n\n{}'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
393643
8448