Comparing version 0.3.0 to 0.3.1
# Changelog | ||
### 0.3.0 (2015-05-01) | ||
## 0.3.1 (2015-05-03) | ||
* When running from the CLI and a line or column is `null`, it's no longer printed. | ||
* Fixed an issue where the only error reported was a missing final newline. | ||
* Fixed an issue that prevented errors on the last ruleset from being shown when a final newline was missing. | ||
* Fixed an issue where `emptyRule` would incorrectly report errors on rules that only contain a mixin ([#16](https://github.com/jwilsson/lesshint/issues/16)). | ||
* Fixed an issue where `trailingSemicolon` would fail on an empty rule. | ||
* Fixed an issue where `trailingSemicolon` would incorrectly report errors in rules containing variables inside `@media` directives ([#15](https://github.com/jwilsson/lesshint/issues/15)). | ||
## 0.3.0 (2015-05-01) | ||
* Added the following linters: | ||
* `duplicateProperty` | ||
* `emptyRule` | ||
@@ -9,4 +18,2 @@ * `finalNewline` | ||
* `trailingSemicolon` | ||
* `urlFormat` | ||
* `urlQuotes` | ||
* Better error messages, the property or value that caused the error are now more clearly described. | ||
@@ -13,0 +20,0 @@ * Internal code cleanup. |
@@ -54,10 +54,18 @@ 'use strict'; | ||
errors.forEach(function (error) { | ||
console.log( | ||
'%s: %s, %s, %s: %s', | ||
chalk.cyan(error.file), | ||
chalk.magenta('line ' + error.line), | ||
chalk.magenta('col ' + error.column), | ||
chalk.green(error.linter), | ||
error.message | ||
); | ||
var output = ''; | ||
output += chalk.cyan(error.file) + ': '; | ||
if (error.line) { | ||
output += chalk.magenta('line ' + error.line) + ', '; | ||
} | ||
if (error.column) { | ||
output += chalk.magenta('col ' + error.column) + ', '; | ||
} | ||
output += chalk.green(error.linter) + ': '; | ||
output += error.message; | ||
console.log(output); | ||
}); | ||
@@ -64,0 +72,0 @@ |
@@ -9,3 +9,2 @@ 'use strict'; | ||
var node = options.node; | ||
var result; | ||
var block; | ||
@@ -30,7 +29,3 @@ | ||
result = block.content.some(function (element) { | ||
return element.type === 'declaration'; | ||
}); | ||
if (!result) { | ||
if (!block.content.length || (block.content.length === 1 && block.content[0].type === 'space')) { | ||
return { | ||
@@ -37,0 +32,0 @@ column: node.start.column, |
'use strict'; | ||
var clone = require('lodash.clone'); | ||
var path = require('path'); | ||
@@ -8,3 +9,3 @@ | ||
var config = options.config; | ||
var node = options.node; | ||
var node = clone(options.node, true); // We need to break the object reference since we modify the node below | ||
var maybeLine; | ||
@@ -11,0 +12,0 @@ |
'use strict'; | ||
var findIndex = require('lodash.findindex'); | ||
var path = require('path'); | ||
@@ -9,4 +10,4 @@ | ||
var node = options.node; | ||
var checkIndex; | ||
var property; | ||
var message; | ||
var start; | ||
@@ -24,17 +25,15 @@ | ||
property = node.content.splice(-2, 1)[0]; | ||
// Find declarations | ||
checkIndex = findIndex(node.content, function (element) { | ||
return element.type === 'declaration'; | ||
}); | ||
// No declarations found, bail | ||
if (!property) { | ||
if (checkIndex === -1) { | ||
return null; | ||
} | ||
if (property.type !== 'declarationDelimiter') { | ||
message = 'All property declarations should end with a semicolon.'; | ||
if (node.content[checkIndex + 1].type !== 'declarationDelimiter') { | ||
start = node.content.pop().start; | ||
} | ||
if (message) { | ||
return { | ||
@@ -45,3 +44,3 @@ column: start.column, | ||
linter: 'trailingSemicolon', | ||
message: message | ||
message: 'All property declarations should end with a semicolon.' | ||
}; | ||
@@ -48,0 +47,0 @@ } |
{ | ||
"name": "lesshint", | ||
"description": "A tool to aid you in writing clean and consistent Less.", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"main": "./lib/lesshint.js", | ||
@@ -24,2 +24,3 @@ "author": { | ||
"gonzales-pe": "^3.0.0-26", | ||
"lodash.clone": "^3.0.1", | ||
"lodash.findindex": "^3.2.0", | ||
@@ -26,0 +27,0 @@ "lodash.flatten": "^3.0.2", |
@@ -40,3 +40,3 @@ var assert = require('assert'); | ||
it('should check a string', function () { | ||
var string = '.foo{ color: red; }'; | ||
var string = '.foo{ color: red; }\n'; | ||
var lesshint = new LessHint(); | ||
@@ -43,0 +43,0 @@ var errors = lesshint.checkString(string); |
@@ -58,2 +58,21 @@ var assert = require('assert'); | ||
it('should allow rules with only mixins (#16)', function () { | ||
var source = '.foo { .mixin(); }'; | ||
var ast; | ||
var options = { | ||
emptyRule: { | ||
enabled: true | ||
} | ||
}; | ||
ast = linter.parseAST(source); | ||
ast = ast.first(); | ||
assert.strictEqual(true, emptyRule({ | ||
config: options, | ||
node: ast | ||
})); | ||
}); | ||
it('should return null run when disabled', function () { | ||
@@ -60,0 +79,0 @@ var source = '.foo {}'; |
@@ -75,2 +75,38 @@ var assert = require('assert'); | ||
it('should ignore empty rules but with new lines', function () { | ||
var source = '.foo {\n}'; | ||
var ast; | ||
var options = { | ||
trailingSemicolon: { | ||
enabled: true | ||
} | ||
}; | ||
ast = linter.parseAST(source); | ||
ast = ast.first().first('block'); | ||
assert.equal(null, trailingSemicolon({ | ||
config: options, | ||
node: ast | ||
})); | ||
}); | ||
it('should allow semicolons in rulesets in @media declarations (#15)', function () { | ||
var source = '@media screen and (max-width: 768px) { @color: red; .div { color: @color; } }'; | ||
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 run when disabled', function () { | ||
@@ -77,0 +113,0 @@ var source = '.foo { color: red }'; |
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
102597
2641
12
+ Addedlodash.clone@^3.0.1
+ Addedlodash._baseassign@3.2.0(transitive)
+ Addedlodash._baseclone@3.3.0(transitive)
+ Addedlodash.clone@3.0.3(transitive)