Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Keep the original line number if no source map #226

Merged
merged 1 commit into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports = options => ({
// Replace "brace" with "backtick" in warnings, e.g.
// "Unexpected empty line before closing backtick" (instead of "brace")
text: warning.text.replace(/brace/, 'backtick'),
line: lineCorrection[warning.line]
line: lineCorrection[warning.line] || warning.line
})
)

Expand Down
46 changes: 46 additions & 0 deletions test/emptycode.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const stylelint = require('stylelint')
const path = require('path')

const processor = path.join(__dirname, '../lib/index.js')
const rules = {
'no-empty-source': true
}

describe('empty source', () => {
let data

beforeAll(done => {
stylelint
.lint({
code: '',
config: {
processors: [processor],
rules
}
})
.then(result => {
data = result
done()
})
.catch(err => {
data = err
done()
})
})

it('should have one result', () => {
expect(data.results.length).toEqual(1)
})

it('should have errored', () => {
expect(data.errored).toEqual(true)
})

it('should have one warning', () => {
expect(data.results[0].warnings.length).toEqual(1)
})

it('should have the right line number', () => {
expect(data.results[0].warnings[0].line).toEqual(1)
})
})