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.
192 lines (147 loc) • 5.06 kB
JavaScript
exports.id = 165;
exports.ids = [165];
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;
}
/***/ }),
/***/ 1837:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ tapFormatter)
/* harmony export */ });
/* harmony import */ var _utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(579);
/* harmony import */ var _preprocessWarnings_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1823);
/** @import {Warning, Formatter} from 'stylelint' */
/** @typedef {Array<Omit<Warning, 'rule'>>} Warnings */
/** @type {Formatter} */
function tapFormatter(results) {
const lines = ['TAP version 14', `1..${results.length}`];
for (const [index, result] of results.entries()) {
(0,_preprocessWarnings_mjs__WEBPACK_IMPORTED_MODULE_1__["default"])(result);
// SKIP indicates "that a test was not run, or if it was,
// that its success or failure is being temporarily ignored."
// skipped tests must not be treated as test failures though
// if a file is ignored, errored is currently always false
const ignored = result.ignored ? ' # SKIP ignored' : '';
const error = result.errored ? 'not ' : '';
lines.push(`${error}ok ${index + 1} - ${getEscapedSource(result.source)}${ignored}`);
if (error) {
lines.push(' ---');
/** @type {Record<string, Warnings>} */
const rules = {};
for (const { rule, ...rest } of result.warnings) {
const name = rule || 'unknown';
const warnings = (rules[name] ??= []);
warnings.push(rest);
}
for (const [ruleName, warnings] of Object.entries(rules)) {
lines.push(` ${ruleName}:`);
for (const { text, severity, line, column, endLine, endColumn } of warnings) {
lines.push(
` - message: ${JSON.stringify(text)}`,
` severity: ${severity}`,
` line: ${line}`,
` column: ${column}`,
);
if ((0,_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__.isNumber)(endLine)) lines.push(` endLine: ${endLine}`);
if ((0,_utils_validateTypes_mjs__WEBPACK_IMPORTED_MODULE_0__.isNumber)(endColumn)) lines.push(` endColumn: ${endColumn}`);
}
}
lines.push(' ...');
}
}
lines.push('');
return lines.join('\n');
}
/**
* Apply TAP escaping to the source that is part of the test point description
* @see {@link https://testanything.org/tap-version-14-specification.html#escaping TAP 14 specification}
* @param {string} [source]
*/
function getEscapedSource(source) {
if (!source) return source;
let output = '';
for (const char of source) {
switch (char.codePointAt(0)) {
case 0x005c: // `\`
case 0x0023: // `#`
output += '\\';
output += char;
break;
default:
output += char;
break;
}
}
return output;
}
/***/ })
};
;
//# sourceMappingURL=165.extension.js.map
;