Comparing version 0.5.1 to 0.6.0
# Changelog | ||
## 0.6.0 (2015-05-27) | ||
* Added the following linters: | ||
* `qualifyingElement` | ||
* `spaceAfterPropertyValue` | ||
* Fixed an issue where `trailingSemicolon` would fail when a space was preceding the semicolon. | ||
* Fixed an issue where hexNotation would incorrectly report colors with only numbers. | ||
* Fixed an issue in idSelector due to a changed AST from `gonzales-pe`. | ||
* The `detached rulesets` feature of Less is now supported thanks to a upstream patch in `gonzales-pe`. | ||
* Increased test coverage. | ||
## 0.5.1 (2015-05-19) | ||
* Fixed issues with `hexLength`, `hexNotation`, and `hexValidation` where they wouldn't check for hex colors outside declarations (for example variables). | ||
* Fixed issues with `hexLength`, `hexNotation`, and `hexValidation` where they wouldn't check for hex colors outside declarations (in variables for example) ([#28](https://github.com/jwilsson/lesshint/issues/28)). | ||
@@ -65,16 +75,16 @@ ## 0.5.0 (2015-05-17) | ||
### 0.1.4 (2015-04-20) | ||
## 0.1.4 (2015-04-20) | ||
* Fixed incorrect dependency name. | ||
### 0.1.3 (2015-04-20) | ||
## 0.1.3 (2015-04-20) | ||
* Fixed some issues where the default config wasn't properly loaded. | ||
* Fixed an issue when the CLI was passed multiple directories and files, they weren't all linted. | ||
### 0.1.2 (2015-04-19) | ||
## 0.1.2 (2015-04-19) | ||
* Another version bump for npm. | ||
### 0.1.1 (2015-04-19) | ||
## 0.1.1 (2015-04-19) | ||
* Version bump for npm after some old files were deleted. | ||
### 0.1.0 (2015-04-19) | ||
## 0.1.0 (2015-04-19) | ||
* Initial release |
@@ -58,2 +58,9 @@ { | ||
"qualifyingElement": { | ||
"enabled": true, | ||
"allowWithId": false, | ||
"allowWithClass": false, | ||
"allowWithAttribute": false | ||
}, | ||
"spaceAfterPropertyColon": { | ||
@@ -69,2 +76,7 @@ "enabled": true, | ||
"spaceAfterPropertyValue": { | ||
"enabled": true, | ||
"style": "no_space" | ||
}, | ||
"spaceBeforeBrace": { | ||
@@ -71,0 +83,0 @@ "enabled": true, |
@@ -22,3 +22,3 @@ 'use strict'; | ||
if (file.substr(0, 1) === '.') { | ||
return; | ||
return []; | ||
} | ||
@@ -25,0 +25,0 @@ |
@@ -21,4 +21,6 @@ 'use strict'; | ||
require('./linters/leading_zero'), | ||
require('./linters/qualifying_element'), | ||
require('./linters/space_after_property_colon'), | ||
require('./linters/space_after_property_name'), | ||
require('./linters/space_after_property_value'), | ||
require('./linters/space_before_brace'), | ||
@@ -25,0 +27,0 @@ require('./linters/string_quotes'), |
@@ -31,3 +31,3 @@ 'use strict'; | ||
linter: 'comment', | ||
message: 'There shouldn\'t be any multiline comments.' | ||
message: 'There shouldn\'t be any multi-line comments.' | ||
}; | ||
@@ -34,0 +34,0 @@ } |
@@ -28,7 +28,3 @@ 'use strict'; | ||
if (property && property.type !== 'ident') { | ||
return; | ||
} | ||
if (properties.indexOf(property.content) !== -1) { | ||
if ((property && property.type === 'ident') && properties.indexOf(property.content) !== -1) { | ||
errors.push({ | ||
@@ -35,0 +31,0 @@ message: 'Duplicate property: "' + property.content + '".', |
@@ -21,10 +21,5 @@ 'use strict'; | ||
block = node.first('block'); | ||
block = node.first('block') || {}; | ||
// Nothing to lint found, bail | ||
if (!block) { | ||
return null; | ||
} | ||
if (!block.content.length || (block.content.length === 1 && block.content[0].type === 'space')) { | ||
if (block.content && (!block.content.length || (block.content.length === 1 && block.content[0].type === 'space'))) { | ||
return { | ||
@@ -31,0 +26,0 @@ column: node.start.column, |
@@ -23,2 +23,5 @@ 'use strict'; | ||
color = '#' + node.content; | ||
if (/^#\d+$/.test(color)) { | ||
return null; | ||
} | ||
@@ -25,0 +28,0 @@ switch (config.hexNotation.style) { |
@@ -30,3 +30,3 @@ 'use strict'; | ||
selector.content.some(function (selector) { | ||
var name = selector.content[0]; | ||
var name = selector.first('ident').content; | ||
@@ -33,0 +33,0 @@ if (selector.type === 'id' && excludes.indexOf(name) === -1) { |
@@ -19,4 +19,6 @@ # Available linters | ||
* [leadingZero](#leadingzero) | ||
* [qualifyingElement](#qualifyingelement) | ||
* [spaceAfterPropertyColon](#spaceafterpropertycolon) | ||
* [spaceAfterPropertyName](#spaceafterpropertyname) | ||
* [spaceAfterPropertyValue](#spaceafterpropertyvalue) | ||
* [spaceBeforeBrace](#spacebeforebrace) | ||
@@ -78,3 +80,3 @@ * [stringQuotes](#stringquotes) | ||
## Comment | ||
Prefer single-line comments (`//`) over multiline (`/* ... */`) since they're not rendered in the final CSS. | ||
Prefer single-line comments (`//`) over multi-line (`/* ... */`) since they're not rendered in the final CSS. | ||
@@ -100,5 +102,4 @@ Option | Description | ||
However, sometimes, there might be valid reasons such as a fallback for older browsers. | ||
In these cases `lesshint` won't be able to know your intentions and will still report it, | ||
if this is undesired the best option right now is to disable this linter altogether until we have a better solution in place. | ||
However, sometimes, there might be valid reasons such as a fallback for older browsers. | ||
In those cases, it's best to set the `exclude` option to stop `lesshint` from reporting those properties. | ||
@@ -130,3 +131,3 @@ Option | Description | ||
.foo { | ||
} | ||
@@ -226,3 +227,3 @@ ``` | ||
---------- | ---------- | ||
`exclude` | Array of IDs to exclude (with our without "#"). | ||
`exclude` | Array of IDs to exclude (with or without "#"). | ||
@@ -282,2 +283,41 @@ ### invalid | ||
## qualifyingElement | ||
Selectors should not include a qualifying element since this will just add unnecessary specificity. | ||
Option | Description | ||
-------------------- | ---------- | ||
`allowWithAttribute` | `false` (**default**), `true` | ||
`allowWithClass` | `false` (**default**), `true` | ||
`allowWithId` | `false` (**default**), `true` | ||
### invalid | ||
```css | ||
div[foo=bar] { | ||
color: red; | ||
} | ||
div.foo { | ||
color: red; | ||
} | ||
div#foo { | ||
color: red; | ||
} | ||
``` | ||
### valid | ||
```css | ||
[foo=bar] { | ||
color: red; | ||
} | ||
.foo { | ||
color: red; | ||
} | ||
#foo { | ||
color: red; | ||
} | ||
``` | ||
## spaceAfterPropertyColon | ||
@@ -325,2 +365,23 @@ Each colon in property declarations should be followed by a space to aid readability. | ||
## spaceAfterPropertyValue | ||
The semicolon in property declarations shouldn't be preceded by any space. | ||
Option | Description | ||
---------- | ---------- | ||
`style` | `no_space` (**default**), `one_space` | ||
### no_space | ||
```css | ||
.foo { | ||
margin: 0; | ||
} | ||
``` | ||
### one_space | ||
```css | ||
.foo { | ||
margin: 0 ; | ||
} | ||
``` | ||
## spaceBeforeBrace | ||
@@ -327,0 +388,0 @@ A space should be present before opening braces to aid readability. |
@@ -26,18 +26,9 @@ 'use strict'; | ||
checkIndex = findIndex(node.content, function (element) { | ||
if (element.type === 'propertyDelimiter' && element.content === ':') { | ||
return true; | ||
} | ||
return false; | ||
return (element.type === 'propertyDelimiter' && element.content === ':'); | ||
}); | ||
// No colon found, bail | ||
if (checkIndex === -1) { | ||
return null; | ||
} | ||
maybeSpace = node.content[checkIndex + 1]; | ||
switch (config.spaceAfterPropertyColon.style) { | ||
case 'no_space': | ||
if (maybeSpace.type === 'space') { | ||
if (maybeSpace && maybeSpace.type === 'space') { | ||
message = 'Colon after property name should not be followed by any spaces.'; | ||
@@ -48,3 +39,3 @@ } | ||
case 'one_space': | ||
if (maybeSpace.type !== 'space' || (maybeSpace.type === 'space' && maybeSpace.content !== ' ')) { | ||
if (maybeSpace && (maybeSpace.type !== 'space' || (maybeSpace.type === 'space' && maybeSpace.content !== ' '))) { | ||
message = 'Colon after property name should be followed by one space.'; | ||
@@ -51,0 +42,0 @@ } |
@@ -26,18 +26,9 @@ 'use strict'; | ||
checkIndex = findIndex(node.content, function (element) { | ||
if (element.type === 'property') { | ||
return true; | ||
} | ||
return false; | ||
return (element.type === 'property'); | ||
}); | ||
// No colon found, bail | ||
if (checkIndex === -1) { | ||
return null; | ||
} | ||
maybeSpace = node.content[checkIndex + 1]; | ||
switch (config.spaceAfterPropertyName.style) { | ||
case 'no_space': | ||
if (maybeSpace.type === 'space') { | ||
if (maybeSpace && maybeSpace.type === 'space') { | ||
message = 'Colon after property should not be preceded by any space.'; | ||
@@ -48,3 +39,3 @@ } | ||
case 'one_space': | ||
if (maybeSpace.type !== 'space' || (maybeSpace.type === 'space' && maybeSpace.content !== ' ')) { | ||
if (maybeSpace && (maybeSpace.type !== 'space' || (maybeSpace.type === 'space' && maybeSpace.content !== ' '))) { | ||
message = 'Colon after property should be preceded by one space.'; | ||
@@ -51,0 +42,0 @@ } |
@@ -34,3 +34,3 @@ 'use strict'; | ||
if (node.content[checkIndex + 1].type !== 'declarationDelimiter') { | ||
if (!node.first('declarationDelimiter')) { | ||
start = node.content[node.content.length - 1].start; | ||
@@ -37,0 +37,0 @@ |
{ | ||
"name": "lesshint", | ||
"description": "A tool to aid you in writing clean and consistent Less.", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"main": "./lib/lesshint.js", | ||
@@ -23,6 +23,6 @@ "author": { | ||
"exit": "^0.1.2", | ||
"gonzales-pe": "^3.0.0-28", | ||
"lodash.findindex": "^3.2.0", | ||
"gonzales-pe": "^3.0.0-29", | ||
"lodash.findindex": "^3.2.1", | ||
"lodash.flatten": "^3.0.2", | ||
"lodash.merge": "^3.2.0", | ||
"lodash.merge": "^3.3.1", | ||
"rcfinder": "^0.1.8", | ||
@@ -34,7 +34,9 @@ "strip-json-comments": "^1.0.2", | ||
"devDependencies": { | ||
"jscs": "^1.12.0", | ||
"jshint": "^2.6.3", | ||
"mocha": "^2.2.1", | ||
"mock-fs": "^2.5.0", | ||
"rewire": "^2.3.1", | ||
"coveralls": "^2.11.2", | ||
"istanbul": "^0.3.14", | ||
"jscs": "^1.13.1", | ||
"jshint": "^2.7.0", | ||
"mocha": "^2.2.5", | ||
"mock-fs": "^2.7.0", | ||
"rewire": "^2.3.3", | ||
"sinon": "^1.14.1" | ||
@@ -46,2 +48,3 @@ }, | ||
"scripts": { | ||
"cover": "istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec test/specs && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", | ||
"pretest": "jshint lib && jscs lib", | ||
@@ -48,0 +51,0 @@ "test": "mocha" |
@@ -5,2 +5,3 @@ # lesshint | ||
[![Windows CI](https://ci.appveyor.com/api/projects/status/github/jwilsson/lesshint?svg=true)](https://ci.appveyor.com/project/jwilsson/lesshint/branch/master) | ||
[![Coverage Status](https://coveralls.io/repos/jwilsson/lesshint/badge.svg?branch=master)](https://coveralls.io/r/jwilsson/lesshint?branch=master) | ||
[![Dependency Status](https://david-dm.org/jwilsson/lesshint.svg?theme=shields.io&style=flat)](https://david-dm.org/jwilsson/lesshint) | ||
@@ -58,2 +59,1 @@ [![devDependency Status](https://david-dm.org/jwilsson/lesshint/dev-status.svg?theme=shields.io&style=flat)](https://david-dm.org/jwilsson/lesshint#info=devDependencies) | ||
* Using variables in `@media` directives are not supported. Related [issue](https://github.com/tonyganch/gonzales-pe/issues/17). | ||
* Passing Rulesets to Mixins, i.e. [detached rulesets](http://lesscss.org/features/#detached-rulesets-feature) are not supported. Related [issue](https://github.com/tonyganch/gonzales-pe/issues/22). |
@@ -16,2 +16,11 @@ var assert = require('assert'); | ||
}); | ||
it('should ignore dotfiles', function () { | ||
var lesshint = new Lesshint(); | ||
var testPath = path.dirname(__dirname) + '/data/ignored-files'; | ||
return lesshint.checkDirectory(testPath).then(function (errors) { | ||
assert.ok(errors.length === 0); | ||
}); | ||
}); | ||
}); | ||
@@ -18,0 +27,0 @@ |
@@ -8,3 +8,3 @@ var assert = require('assert'); | ||
describe('#borderZero()', function () { | ||
it('should allow "none" as a value when style is "none" and the property is "border"', function () { | ||
it('should allow "none" as a value when "style" is "none" and the property is "border"', function () { | ||
var source = '.foo { border: none; }'; | ||
@@ -29,3 +29,3 @@ var ast; | ||
it('should allow 0 as a value when style is "zero" and the property is "border"', function () { | ||
it('should allow 0 as a value when "style" is "zero" and the property is "border"', function () { | ||
var source = '.foo { border: 0; }'; | ||
@@ -50,3 +50,3 @@ var ast; | ||
it('should not allow 0 as a value when style is "none" and the property is "border"', function () { | ||
it('should not allow 0 as a value when "style" is "none" and the property is "border"', function () { | ||
var source = '.foo { border: 0; }'; | ||
@@ -83,3 +83,3 @@ var actual; | ||
it('should not allow "none" as a value when style is "zero" and the property is "border"', function () { | ||
it('should not allow "none" as a value when "style" is "zero" and the property is "border"', function () { | ||
var source = '.foo { border: none; }'; | ||
@@ -116,3 +116,3 @@ var actual; | ||
it('should allow "none" as a value when style is "none" and the property is "border-bottom"', function () { | ||
it('should allow "none" as a value when "style" is "none" and the property is "border-bottom"', function () { | ||
var source = '.foo { border-bottom: none; }'; | ||
@@ -137,3 +137,3 @@ var ast; | ||
it('should allow "none" as a value when style is "none" and the property is "border-left"', function () { | ||
it('should allow "none" as a value when "style" is "none" and the property is "border-left"', function () { | ||
var source = '.foo { border-left: none; }'; | ||
@@ -158,3 +158,3 @@ var ast; | ||
it('should allow "none" as a value when style is "none" and the property is "border-right"', function () { | ||
it('should allow "none" as a value when "style" is "none" and the property is "border-right"', function () { | ||
var source = '.foo { border-right: none; }'; | ||
@@ -179,3 +179,3 @@ var ast; | ||
it('should allow "none" as a value when style is "none" and the property is "border-top"', function () { | ||
it('should allow "none" as a value when "style" is "none" and the property is "border-top"', function () { | ||
var source = '.foo { border-top: none; }'; | ||
@@ -182,0 +182,0 @@ var ast; |
@@ -26,3 +26,3 @@ var assert = require('assert'); | ||
it('should not allow multiline comments', function () { | ||
it('should not allow multi-line comments', function () { | ||
var source = '/* Hello world */'; | ||
@@ -37,3 +37,3 @@ var actual; | ||
linter: 'comment', | ||
message: 'There shouldn\'t be any multiline comments.' | ||
message: 'There shouldn\'t be any multi-line comments.' | ||
}; | ||
@@ -40,0 +40,0 @@ |
@@ -207,2 +207,22 @@ var assert = require('assert'); | ||
it('should ignore colors with only numbers', function () { | ||
var source = 'color: #123456;'; | ||
var ast; | ||
var options = { | ||
hexNotation: { | ||
enabled: true, | ||
style: 'lowercase' | ||
} | ||
}; | ||
ast = linter.parseAST(source); | ||
ast = ast.first('declaration').first('value').first('color'); | ||
assert.strictEqual(null, hexNotation({ | ||
config: options, | ||
node: ast | ||
})); | ||
}) | ||
it('should return null when disabled', function () { | ||
@@ -209,0 +229,0 @@ var source = 'color: #abc;'; |
@@ -8,3 +8,3 @@ var assert = require('assert'); | ||
describe('#spaceAfterPropertyColon()', function () { | ||
it('should allow one space when style is "one_space"', function () { | ||
it('should allow one space when "style" is "one_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -29,3 +29,3 @@ var ast; | ||
it('should not tolerate missing space when style is "one_space"', function () { | ||
it('should not tolerate missing space when "style" is "one_space"', function () { | ||
var source = '.foo { color:red; }'; | ||
@@ -62,3 +62,3 @@ var actual; | ||
it('should not tolerate more than one space when style is "one_space"', function () { | ||
it('should not tolerate more than one space when "style" is "one_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -95,3 +95,3 @@ var actual; | ||
it('should not allow any space when style is "no_space"', function () { | ||
it('should not allow any space when "style" is "no_space"', function () { | ||
var source = '.foo { color:red; }'; | ||
@@ -116,3 +116,3 @@ var ast; | ||
it('should not tolerate one space when style is "no_space"', function () { | ||
it('should not tolerate one space when "style" is "no_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -149,3 +149,3 @@ var actual; | ||
it('should not tolerate any space when style is "no_space"', function () { | ||
it('should not tolerate any space when "style" is "no_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -182,3 +182,3 @@ var actual; | ||
it('should throw on invalid "style" value', function () { | ||
it('should return null when disabled', function () { | ||
var source = '.foo { color:red; }'; | ||
@@ -188,4 +188,3 @@ var ast; | ||
spaceAfterPropertyColon: { | ||
enabled: true, | ||
style: "invalid" | ||
enabled: false | ||
} | ||
@@ -197,15 +196,13 @@ }; | ||
assert.throws(spaceAfterPropertyColon.bind(null, { | ||
assert.equal(null, spaceAfterPropertyColon({ | ||
config: options, | ||
node: ast | ||
}), Error); | ||
})); | ||
}); | ||
it('should return null when disabled', function () { | ||
it('should return null when disabled via shorthand', function () { | ||
var source = '.foo { color:red; }'; | ||
var ast; | ||
var options = { | ||
spaceAfterPropertyColon: { | ||
enabled: false | ||
} | ||
spaceAfterPropertyColon: false | ||
}; | ||
@@ -222,7 +219,10 @@ | ||
it('should return null when disabled via shorthand', function () { | ||
it('should throw on invalid "style" value', function () { | ||
var source = '.foo { color:red; }'; | ||
var ast; | ||
var options = { | ||
spaceAfterPropertyColon: false | ||
spaceAfterPropertyColon: { | ||
enabled: true, | ||
style: "invalid" | ||
} | ||
}; | ||
@@ -233,8 +233,8 @@ | ||
assert.equal(null, spaceAfterPropertyColon({ | ||
assert.throws(spaceAfterPropertyColon.bind(null, { | ||
config: options, | ||
node: ast | ||
})); | ||
}), Error); | ||
}); | ||
}); | ||
}); |
@@ -8,3 +8,3 @@ var assert = require('assert'); | ||
describe('#spaceAfterPropertyName()', function () { | ||
it('should allow a missing space when style is "no_space"', function () { | ||
it('should allow a missing space when "style" is "no_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -29,3 +29,3 @@ var ast; | ||
it('should not allow any space when style is "no_space"', function () { | ||
it('should not allow any space when "style" is "no_space"', function () { | ||
var source = '.foo { color : red; }'; | ||
@@ -62,3 +62,3 @@ var actual; | ||
it('should allow one space when style is "one_space"', function () { | ||
it('should allow one space when "style" is "one_space"', function () { | ||
var source = '.foo { color : red; }'; | ||
@@ -83,3 +83,3 @@ var ast; | ||
it('should not allow a missing space when style is "one_space"', function () { | ||
it('should not allow a missing space when "style" is "one_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -116,3 +116,3 @@ var actual; | ||
it('should throw on invalid style value', function () { | ||
it('should return null when disabled', function () { | ||
var source = '.foo { color:red; }'; | ||
@@ -122,4 +122,3 @@ var ast; | ||
spaceAfterPropertyName: { | ||
enabled: true, | ||
style: "invalid" | ||
enabled: false | ||
} | ||
@@ -131,15 +130,13 @@ }; | ||
assert.throws(spaceAfterPropertyName.bind(null, { | ||
assert.equal(null, spaceAfterPropertyName({ | ||
config: options, | ||
node: ast | ||
}), Error); | ||
})); | ||
}); | ||
it('should return null when disabled', function () { | ||
it('should return null when disabled via shorthand', function () { | ||
var source = '.foo { color:red; }'; | ||
var ast; | ||
var options = { | ||
spaceAfterPropertyName: { | ||
enabled: false | ||
} | ||
spaceAfterPropertyName: false | ||
}; | ||
@@ -156,7 +153,10 @@ | ||
it('should return null when disabled via shorthand', function () { | ||
it('should throw on invalid "style" value', function () { | ||
var source = '.foo { color:red; }'; | ||
var ast; | ||
var options = { | ||
spaceAfterPropertyName: false | ||
spaceAfterPropertyName: { | ||
enabled: true, | ||
style: "invalid" | ||
} | ||
}; | ||
@@ -167,8 +167,8 @@ | ||
assert.equal(null, spaceAfterPropertyName({ | ||
assert.throws(spaceAfterPropertyName.bind(null, { | ||
config: options, | ||
node: ast | ||
})); | ||
}), Error); | ||
}); | ||
}); | ||
}); |
@@ -8,3 +8,3 @@ var assert = require('assert'); | ||
describe('#spaceBeforeBrace()', function () { | ||
it('should allow no space when style is "no_space"', function () { | ||
it('should allow no space when "style" is "no_space"', function () { | ||
var source = '.foo{ color: red; }'; | ||
@@ -29,3 +29,3 @@ var ast; | ||
it('should not allow one space when style is "no_space"', function () { | ||
it('should not allow one space when "style" is "no_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -61,3 +61,3 @@ var actual; | ||
it('should not allow multiple spaces when style is "no_space"', function () { | ||
it('should not allow multiple spaces when "style" is "no_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -93,3 +93,3 @@ var actual; | ||
it('should not allow one new line when style is "no_space"', function () { | ||
it('should not allow one new line when "style" is "no_space"', function () { | ||
var source = '.foo\n{ color: red; }'; | ||
@@ -125,3 +125,3 @@ var actual; | ||
it('should not allow multiple new lines when style is "no_space"', function () { | ||
it('should not allow multiple new lines when "style" is "no_space"', function () { | ||
var source = '.foo\n\n{ color: red; }'; | ||
@@ -157,3 +157,3 @@ var actual; | ||
it('should allow one space when style is "one_space"', function () { | ||
it('should allow one space when "style" is "one_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -178,3 +178,3 @@ var ast; | ||
it('should not allow missing space when style option is "one_space"', function () { | ||
it('should not allow missing space when "style" option is "one_space"', function () { | ||
var source = '.foo{ color: red; }'; | ||
@@ -210,3 +210,3 @@ var actual; | ||
it('should allow one space when multiple simple selectors are used and style is "one_space"', function () { | ||
it('should allow one space when multiple simple selectors are used and "style" is "one_space"', function () { | ||
var source = '.foo, .bar { color: red; }'; | ||
@@ -231,3 +231,3 @@ var ast; | ||
it('should not allow missing space when multiple simple selectors are used and style is "one_space"', function () { | ||
it('should not allow missing space when multiple simple selectors are used and "style" is "one_space"', function () { | ||
var source = '.foo, .bar{ color: red; }'; | ||
@@ -263,3 +263,3 @@ var actual; | ||
it('should not allow multiple spaces when style is "one_space"', function () { | ||
it('should not allow multiple spaces when "style" is "one_space"', function () { | ||
var source = '.foo { color: red; }'; | ||
@@ -295,3 +295,3 @@ var actual; | ||
it('should not allow multiple spaces when multiple simple selectors are used and style is "one_space"', function () { | ||
it('should not allow multiple spaces when multiple simple selectors are used and "style" is "one_space"', function () { | ||
var source = '.foo, .bar { color: red; }'; | ||
@@ -327,3 +327,3 @@ var actual; | ||
it('should allow one new line when style is "new_line"', function () { | ||
it('should allow one new line when "style" is "new_line"', function () { | ||
var source = '.foo\n{ color: red; }'; | ||
@@ -348,3 +348,3 @@ var ast; | ||
it('should allow one new line when multiple simple selectors are used and style is "new_line"', function () { | ||
it('should allow one new line when a selector group is used and "style" is "new_line"', function () { | ||
var source = '.foo, .bar\n{ color: red; }'; | ||
@@ -369,3 +369,3 @@ var ast; | ||
it('should not allow multiple new lines when style is "new_line"', function () { | ||
it('should not allow multiple new lines when "style" is "new_line"', function () { | ||
var source = '.foo\n\n{ color: red; }'; | ||
@@ -401,3 +401,3 @@ var actual; | ||
it('should not allow multiple new lines when multiple simple selectors are used and style is "new_line"', function () { | ||
it('should not allow multiple new lines when a selector group is used and "style" is "new_line"', function () { | ||
var source = '.foo, .bar\n\n{ color: red; }'; | ||
@@ -433,9 +433,10 @@ var actual; | ||
it('should throw on invalid "style" value', function () { | ||
var source = '.foo{ color: red; }'; | ||
it('should handle mixins', function () { | ||
var source = '.foo() { color: red; }'; | ||
var ast; | ||
var options = { | ||
spaceBeforeBrace: { | ||
enabled: true, | ||
style: "invalid" | ||
style: 'one_space' | ||
} | ||
@@ -447,6 +448,6 @@ }; | ||
assert.throws(spaceBeforeBrace.bind(null, { | ||
assert.strictEqual(true, spaceBeforeBrace({ | ||
config: options, | ||
node: ast | ||
}), Error); | ||
})); | ||
}); | ||
@@ -487,3 +488,22 @@ | ||
}); | ||
it('should throw on invalid "style" value', function () { | ||
var source = '.foo{ color: red; }'; | ||
var ast; | ||
var options = { | ||
spaceBeforeBrace: { | ||
enabled: true, | ||
style: "invalid" | ||
} | ||
}; | ||
ast = linter.parseAST(source); | ||
ast = ast.first().first('selector'); | ||
assert.throws(spaceBeforeBrace.bind(null, { | ||
config: options, | ||
node: ast | ||
}), Error); | ||
}); | ||
}); | ||
}); |
@@ -111,2 +111,20 @@ var assert = require('assert'); | ||
it('should not report a missing when there\'s a space before the semicolon', function () { | ||
var source = '.foo { color: red ; }'; | ||
var ast; | ||
var options = { | ||
trailingSemicolon: { | ||
enabled: true | ||
} | ||
}; | ||
ast = linter.parseAST(source); | ||
ast = ast.first().first('block'); | ||
assert.equal(true, trailingSemicolon({ | ||
config: options, | ||
node: ast | ||
})); | ||
}); | ||
it('should return null when disabled', function () { | ||
@@ -113,0 +131,0 @@ var source = '.foo { color: red }'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
209982
75
5509
8
Updatedgonzales-pe@^3.0.0-29
Updatedlodash.findindex@^3.2.1
Updatedlodash.merge@^3.3.1