Skip to content

Commit

Permalink
fix: display errors (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza committed Jun 24, 2021
1 parent 620ac1d commit e343427
Showing 1 changed file with 17 additions and 37 deletions.
54 changes: 17 additions & 37 deletions src/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,30 +187,26 @@ function parseResults(options, results) {
const warnings = [];

results.forEach((file) => {
if (fileHasErrors(file)) {
const messages = file.warnings.filter(
(message) => options.emitError && message.severity === 'error'
);

if (messages.length > 0) {
errors.push({
...file,
warnings: messages,
});
}
const fileErrors = file.warnings.filter(
(message) => options.emitError && message.severity === 'error'
);

if (fileErrors.length > 0) {
errors.push({
...file,
warnings: fileErrors,
});
}

if (fileHasWarnings(file)) {
const messages = file.warnings.filter(
(message) => options.emitWarning && message.severity === 'warning'
);
const fileWarnings = file.warnings.filter(
(message) => options.emitWarning && message.severity === 'warning'
);

if (messages.length > 0) {
warnings.push({
...file,
warnings: messages,
});
}
if (fileWarnings.length > 0) {
warnings.push({
...file,
warnings: fileWarnings,
});
}
});

Expand All @@ -220,22 +216,6 @@ function parseResults(options, results) {
};
}

/**
* @param {LintResult} file
* @returns {boolean}
*/
function fileHasErrors(file) {
return !!file.errored;
}

/**
* @param {LintResult} file
* @returns {boolean}
*/
function fileHasWarnings(file) {
return file.warnings && file.warnings.length > 0;
}

/**
* @param {Stylelint} stylelint
* @param {FormatterType=} formatter
Expand Down

0 comments on commit e343427

Please sign in to comment.