ocrmnav
Version:
DevStack - The Complete Developer Toolkit - Virtual file system, workflow automation, and more than 65+ other development tools / features in one seamless extension. Cutting down dev times never before seen.
158 lines (122 loc) • 4.19 kB
JavaScript
exports.id = 164;
exports.ids = [164];
exports.modules = {
/***/ 1823:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ preprocessWarnings)
/* harmony export */ });
/* harmony import */ var _constants_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(786);
/** @import {LintResult} from 'stylelint' */
/** @typedef {LintResult['parseErrors'][0]} ParseError */
/** @typedef {LintResult['warnings'][0]} Warning */
/** @typedef {Warning['severity']} Severity */
/**
* Preprocess warnings in a given lint result.
* Note that this function has a side-effect.
*
* @param {LintResult} result
* @returns {LintResult}
*/
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;
}
/**
* @param {ParseError} error
* @returns {Warning}
*/
function parseErrorToWarning(error) {
return {
line: error.line,
column: error.column,
rule: error.stylelintType,
severity: _constants_mjs__WEBPACK_IMPORTED_MODULE_0__.SEVERITY_ERROR,
text: `${error.text} (${error.stylelintType})`,
};
}
/**
* @param {Warning} warning
* @returns {Severity}
*/
function normalizeSeverity(warning) {
// NOTE: Plugins may add a warning without severity, for example,
// by directly using the PostCSS `Result#warn()` API.
return warning.severity || _constants_mjs__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_SEVERITY;
}
/**
* @param {Warning} a
* @param {Warning} b
* @returns {number}
*/
function byLocationOrder(a, b) {
// positionless first
if (!a.line && b.line) return -1;
// positionless first
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;
}
/***/ }),
/***/ 1824:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ githubFormatter)
/* harmony export */ });
/* harmony import */ var _preprocessWarnings_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1823);
/**
* @see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
*
* @type {import('stylelint').Formatter}
*
* @deprecated See https://stylelint.io/awesome-stylelint#formatters for alternative formatters.
*/
function githubFormatter(results, returnValue) {
const title = 'Stylelint problem';
const metadata = returnValue.ruleMetadata;
const lines = results.flatMap((result) => {
const { source, warnings } = (0,_preprocessWarnings_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])(result);
return warnings.map(({ line, column, endLine, endColumn, text, severity, rule }) => {
const msg = buildMessage(text, metadata[rule]);
return endLine === undefined
? `::${severity} file=${source},line=${line},col=${column},title=${title}::${msg}`
: `::${severity} file=${source},line=${line},col=${column},endLine=${endLine},endColumn=${endColumn},title=${title}::${msg}`;
});
});
lines.push(`::notice title=Stylelint deprecation::The github formatter is deprecated`);
lines.push('');
return lines.join('\n');
}
/**
* @param {string} msg
* @param {Partial<import('stylelint').RuleMeta> | undefined} metadata
* @returns {string}
*/
function buildMessage(msg, metadata) {
if (!metadata) return msg;
const url = metadata.url ? ` - ${metadata.url}` : '';
let additional = [
metadata.fixable ? 'maybe fixable' : '',
metadata.deprecated ? 'deprecated' : '',
]
.filter(Boolean)
.join(', ');
additional = additional ? ` [${additional}]` : '';
return `${msg}${additional}${url}`;
}
/***/ })
};
;
//# sourceMappingURL=164.extension.js.map
;