Skip to content

Commit

Permalink
Merge branch 'master' into linter-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilsson committed Mar 18, 2017
2 parents 94b0b09 + f30fc75 commit 9e6ed59
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/errors/lesshint-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LesshintError extends Error {

errorPath = errorPath || error.path;

this.message = error.message;
this.message = error.message || error;
this.name = this.constructor.name;
this.path = path.resolve(process.cwd(), errorPath);
this.stack = error.stack;
Expand Down
2 changes: 1 addition & 1 deletion lib/errors/runner-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class RunnerError extends Error {
constructor (error, status) {
super(error);

this.message = error.message;
this.message = error.message || error;
this.name = this.constructor.name;
this.status = status;
this.stack = error.stack;
Expand Down
5 changes: 5 additions & 0 deletions lib/linters/url_quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ module.exports = {
const uri = child.first.next();
const value = uri.value.trim();

// Ignore variables
if (value.substring(0, 1) === '@') {
return;
}

/**
* postcss-values-parser has a bug with url string params surrounded by
* spaces. So account for that here.
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"functions": 95,
"branches": 95,
"check-coverage": true,
"exclude": [
"gulpfile.js"
],
"reporter": [
"lcov",
"text-summary"
Expand Down
33 changes: 33 additions & 0 deletions test/specs/errors/lesshint-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

const LesshintError = require('../../../lib/errors/lesshint-error');
const expect = require('chai').expect;
const path = require('path');

describe('LesshintError', function () {
it('should handle an Error object', function () {
const message = 'Something went wrong';
const error = new Error(message);

const lesshintError = new LesshintError(error, '/path/to/file.less');

expect(lesshintError.message).to.equal(message);
});

it('should handle a a string', function () {
const message = 'Something went wrong';

const lesshintError = new LesshintError(message, '/path/to/file.less');

expect(lesshintError.message).to.equal(message);
});

it('should resolve paths', function () {
const file = 'file.less';
const errorPath = path.resolve(process.cwd(), file);

const lesshintError = new LesshintError('Something went wrong', file);

expect(lesshintError.path).to.equal(errorPath);
});
});
30 changes: 30 additions & 0 deletions test/specs/errors/runner-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

const RunnerError = require('../../../lib/errors/runner-error');
const expect = require('chai').expect;

describe('RunnerError', function () {
it('should handle an Error object', function () {
const message = 'Something went wrong';
const error = new Error(message);

const runnerError = new RunnerError(error, 1);

expect(runnerError.message).to.equal(message);
});

it('should handle a a string', function () {
const message = 'Something went wrong';

const runnerError = new RunnerError(message, 1);

expect(runnerError.message).to.equal(message);
});

it('should set the status', function () {
const status = 1;
const runnerError = new RunnerError('Something went wrong', status);

expect(runnerError.status).to.equal(status);
});
});
11 changes: 11 additions & 0 deletions test/specs/linters/url_quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,16 @@ describe('lesshint', function () {
expect(result).to.deep.equal(expected);
});
});

it('should ignore variables', function () {
const source = '.foo { background-image: url(@bar) }';

return spec.parse(source, function (ast) {
const result = spec.linter.lint({}, ast.root.first.first);

expect(result).to.be.undefined;
});
});

});
});

0 comments on commit 9e6ed59

Please sign in to comment.