Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
fix: check result object (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza authored Dec 6, 2019
1 parent 7793ccf commit 6bb1fa6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export default class Linter {

static skipIgnoredFileWarning(res) {
return (
res &&
res.warningCount === 1 &&
res.results &&
res.results[0] &&
res.results[0].messages[0] &&
res.results[0].messages[0].message &&
res.results[0].messages[0].message.indexOf('ignore') > 1
Expand All @@ -96,7 +99,13 @@ export default class Linter {
// quiet filter done now
// eslint allow rules to be specified in the input between comments
// so we can found warnings defined in the input itself
if (this.options.quiet && res.warningCount) {
if (
this.options.quiet &&
res &&
res.warningCount &&
res.results &&
res.results[0]
) {
res.warningCount = 0;
res.results[0].warningCount = 0;
res.results[0].messages = res.results[0].messages.filter(
Expand All @@ -109,9 +118,12 @@ export default class Linter {

autoFix(res) {
if (
res.results[0].output !== res.src ||
res.results[0].fixableErrorCount > 0 ||
res.results[0].fixableWarningCount > 0
res &&
res.results &&
res.results[0] &&
(res.results[0].output !== res.src ||
res.results[0].fixableErrorCount > 0 ||
res.results[0].fixableWarningCount > 0)
) {
this.CLIEngine.outputFixes(res);
}
Expand Down

0 comments on commit 6bb1fa6

Please sign in to comment.