Comparing version 0.1.4 to 0.1.5
# Changelog | ||
## 0.1.5 (2015-04-24) | ||
* The default options are now always loaded, regardless if `lesshint` is running from the CLI or another module. | ||
* If no files are passed via the CLI, an error is now printed. | ||
* When something's wrong with a passed config file, the error message from `JSON.parse()` is also shown. | ||
### 0.1.4 (2015-04-20) | ||
@@ -4,0 +9,0 @@ * Fixed incorrect dependency name. |
@@ -12,6 +12,12 @@ 'use strict'; | ||
if (!program.args.length) { | ||
console.error('No files to lint were passed. See lesshint -h'); | ||
return; | ||
} | ||
try { | ||
config = configLoader(program.config); | ||
} catch (e) { | ||
console.error('Something\'s wrong with the config file.'); | ||
console.error('Something\'s wrong with the config file. Error: ' + e.message); | ||
@@ -18,0 +24,0 @@ return; |
@@ -5,3 +5,2 @@ 'use strict'; | ||
var RcFinder = require('rcfinder'); | ||
var merge = require('lodash.merge'); | ||
var stripJsonComments = require('strip-json-comments'); | ||
@@ -18,3 +17,2 @@ | ||
module.exports = function (config) { | ||
var defaults = loadConfig(__dirname + '/config/defaults.json'); | ||
var rcfinder; | ||
@@ -33,3 +31,3 @@ | ||
return merge(defaults, config); | ||
return config; | ||
}; |
@@ -13,3 +13,3 @@ 'use strict'; | ||
return fs.listDir(path).then(function (files) { | ||
return Vow.all(files.map(function (file) { | ||
files = files.map(function (file) { | ||
var fullPath = path + '/' + file; | ||
@@ -28,3 +28,5 @@ | ||
}, this); | ||
}, this)).then(function (errors) { | ||
}, this); | ||
return Vow.all(files).then(function (errors) { | ||
return [].concat.apply([], errors); | ||
@@ -31,0 +33,0 @@ }); |
'use strict'; | ||
var configLoader = require('./config-loader'); | ||
var gonzales = require('gonzales-pe'); | ||
var merge = require('lodash.merge'); | ||
var linters = [ | ||
@@ -10,5 +13,8 @@ require('./linters/space_after_property_colon'), | ||
exports.lint = function (input, path, config) { | ||
var defaultConfig = configLoader(__dirname + '/config/defaults.json'); | ||
var ast = this.parseAST(input); | ||
var errors = []; | ||
config = merge(defaultConfig, config); | ||
ast.map(function (node) { | ||
@@ -15,0 +21,0 @@ var i; |
@@ -8,6 +8,18 @@ # Available linters | ||
## spaceAfterPropertyColon | ||
Each colon in property declarations should be followed by a space. For example: | ||
Each colon in property declarations should be followed by a space. | ||
Option | Description | ||
---------- | ---------- | ||
`style` | `no_space`, `one_space` (**default**) | ||
### no_space | ||
```css | ||
.foo { | ||
margin:0; | ||
} | ||
``` | ||
### one_space | ||
```css | ||
.foo { | ||
margin: 0; | ||
@@ -17,9 +29,17 @@ } | ||
## spaceBeforeBrace | ||
A space should be present before opening braces. | ||
Option | Description | ||
---------- | ---------- | ||
`style` | `no_space`, `one_space` (**default**) | ||
`style` | `no_space`, `one_space` (**default**), `new_line` | ||
## spaceBeforeBrace | ||
A space should be present before opening braces. For example: | ||
### no_space | ||
```css | ||
.foo{ | ||
color: red; | ||
} | ||
``` | ||
### one_space | ||
```css | ||
@@ -31,4 +51,8 @@ .foo { | ||
Option | Description | ||
---------- | ---------- | ||
`style` | `no_space`, `one_space` (**default**), `new_line` | ||
## new_line | ||
```css | ||
.foo | ||
{ | ||
color: red; | ||
} | ||
``` |
{ | ||
"name": "lesshint", | ||
"description": "A tool to aid you in writing clean and consistent Less.", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"main": "./lib/lesshint.js", | ||
@@ -33,2 +33,3 @@ "author": { | ||
"mocha": "^2.2.1", | ||
"mock-fs": "^2.5.0", | ||
"sinon": "^1.14.1" | ||
@@ -35,0 +36,0 @@ }, |
@@ -22,8 +22,21 @@ var assert = require('assert'); | ||
cli({ | ||
config: path.resolve(process.cwd() + './test/data/config/invalid.json') | ||
args: ['test.less'], | ||
config: path.resolve(process.cwd() + '/test/data/config/invalid.json') | ||
}); | ||
assert(console.error.getCall(0).args[0] === 'Something\'s wrong with the config file.'); | ||
// We can't really be sure of the JSON.parse() error message, so we'll just check that the beginning is correct | ||
assert(console.error.getCall(0).args[0].indexOf('Something\'s wrong with the config file. Error: ') === 0); | ||
console.error.restore(); | ||
}); | ||
it('should print error when no files are passed', function () { | ||
sinon.spy(console, 'error'); | ||
cli({ | ||
args: [] | ||
}); | ||
assert(console.error.getCall(0).args[0] === 'No files to lint were passed. See lesshint -h'); | ||
console.error.restore(); | ||
}); | ||
}); |
var assert = require('assert'); | ||
var mock = require('mock-fs'); | ||
var path = require('path'); | ||
@@ -6,3 +7,13 @@ | ||
var configLoader = require('../../lib/config-loader'); | ||
var expectedMock = { | ||
spaceBeforeBrace: { | ||
enabled: true, | ||
style: 'no_space' | ||
} | ||
}; | ||
after(function () { | ||
mock.restore(); | ||
}); | ||
it('should load the specified config file', function () { | ||
@@ -26,8 +37,13 @@ var config = path.resolve(process.cwd() + '/test/data/config/config.json'); | ||
it('should just use the defaults if no other config file is specified', function () { | ||
var expected = require(path.resolve(process.cwd() + '/lib/config/defaults.json')); | ||
var actual = configLoader(); | ||
it('should load .lesshintrc if no config file is passed', function () { | ||
var actual; | ||
assert.deepEqual(actual, expected); | ||
mock({ | ||
'/.lesshintrc': JSON.stringify(expectedMock) | ||
}); | ||
actual = configLoader(); | ||
assert.deepEqual(actual, expectedMock); | ||
}); | ||
}); |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
40131
911
1
5