Skip to content

Commit

Permalink
Fix line reporting in selectorNaming
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilsson committed Feb 4, 2017
1 parent 70a1a95 commit 40f1251
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/linters/selector_naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
) {
results.push({
column: node.source.start.column + selector.source.start.column - 1,
line: node.source.start.line,
line: node.source.start.line + selector.source.start.line - 1,
message: util.format(this.message, name)
});
}
Expand Down
28 changes: 28 additions & 0 deletions test/specs/linters/selector_naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,33 @@ describe('lesshint', function () {
expect(result).to.deep.equal(expected);
});
});

it('should report the correct line', function () {
const source = [
'.Foo,',
'.Bar {}'
].join('\n');

const expected = [{
column: 1,
line: 1,
message: 'Selector "Foo" should follow naming conventions.'
},
{
column: 1,
line: 2,
message: 'Selector "Bar" should follow naming conventions.'
}];

const options = {
disallowUppercase: true
};

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

expect(result).to.deep.equal(expected);
});
});
});
});

0 comments on commit 40f1251

Please sign in to comment.