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

Commit

Permalink
Merge bb33946 into af54d5f
Browse files Browse the repository at this point in the history
  • Loading branch information
chinesedfan authored Sep 28, 2018
2 parents af54d5f + bb33946 commit d5208bf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
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)
})
})

0 comments on commit d5208bf

Please sign in to comment.