diff --git a/lib/linters/selector_naming.js b/lib/linters/selector_naming.js index fc4f1018..a5ab7c4d 100644 --- a/lib/linters/selector_naming.js +++ b/lib/linters/selector_naming.js @@ -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) }); } diff --git a/test/specs/linters/selector_naming.js b/test/specs/linters/selector_naming.js index dfaee2a0..c1eb57cd 100644 --- a/test/specs/linters/selector_naming.js +++ b/test/specs/linters/selector_naming.js @@ -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); + }); + }); }); });