Skip to content

Commit

Permalink
Merge pull request #10 from harryxu/main
Browse files Browse the repository at this point in the history
Do not downgrade fatal error(2) to warn(1).
  • Loading branch information
bfanger authored Dec 1, 2022
2 parents 21dde30 + 52b74f6 commit 1f161b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/only-warn.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function patch(LinterPrototype) {
LinterPrototype.verify = function () {
const messages = LinterPrototype[unpatchedVerify].apply(this, arguments)
messages.forEach((message) => {
if (message.severity === 2) {
if (!message.fatal && message.severity === 2) {
message.severity = 1
}
})
Expand Down
7 changes: 7 additions & 0 deletions tests/only-warn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ describe('eslint-plugin-only-warn', () => {
expect(messages[0].severity).toBe(1)
})

const sourceCodeFatalError = 'var foo = ( => {}'
it('should not downgrade fatal error(2)', () => {
const messages = linter.verify(sourceCodeFatalError, config)
expect(messages[0].fatal).toBe(true)
expect(messages[0].severity).toBe(2)
})

it('can be temporarly disabled', () => {
disable()
const messages1 = linter.verify(sourceCode, config)
Expand Down

0 comments on commit 1f161b2

Please sign in to comment.