1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 'use strict';
- module.exports = function preprocessWarnings(result) {
- for (const error of result.parseErrors || []) {
- result.warnings.push(parseErrorToWarning(error));
- }
- for (const warning of result.warnings) {
- warning.severity = normalizeSeverity(warning);
- }
- result.warnings.sort(byLocationOrder);
- return result;
- };
- function parseErrorToWarning(error) {
- return {
- line: error.line,
- column: error.column,
- rule: error.stylelintType,
- severity: 'error',
- text: `${error.text} (${error.stylelintType})`,
- };
- }
- function normalizeSeverity(warning) {
-
-
- return warning.severity || 'error';
- }
- function byLocationOrder(a, b) {
-
- if (!a.line && b.line) return -1;
-
- if (a.line && !b.line) return 1;
- if (a.line < b.line) return -1;
- if (a.line > b.line) return 1;
- if (a.column < b.column) return -1;
- if (a.column > b.column) return 1;
- return 0;
- }
|