UNPKG

5.53 kBJavaScriptView Raw
1/******/ (() => { // webpackBootstrap
2/******/ "use strict";
3/******/ var __webpack_modules__ = ({
4
5/***/ 429:
6/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
7
8/**
9 * @fileoverview Stylish reporter
10 * @author Sindre Sorhus
11 */
12
13
14const chalk = __nccwpck_require__(744),
15 stripAnsi = __nccwpck_require__(916),
16 table = __nccwpck_require__(495);
17
18//------------------------------------------------------------------------------
19// Helpers
20//------------------------------------------------------------------------------
21
22/**
23 * Given a word and a count, append an s if count is not one.
24 * @param {string} word A word in its singular form.
25 * @param {int} count A number controlling whether word should be pluralized.
26 * @returns {string} The original word with an s on the end if count is not one.
27 */
28function pluralize(word, count) {
29 return (count === 1 ? word : `${word}s`);
30}
31
32//------------------------------------------------------------------------------
33// Public Interface
34//------------------------------------------------------------------------------
35
36module.exports = function(results) {
37
38 let output = "\n",
39 errorCount = 0,
40 warningCount = 0,
41 fixableErrorCount = 0,
42 fixableWarningCount = 0,
43 summaryColor = "yellow";
44
45 results.forEach(result => {
46 const messages = result.messages;
47
48 if (messages.length === 0) {
49 return;
50 }
51
52 errorCount += result.errorCount;
53 warningCount += result.warningCount;
54 fixableErrorCount += result.fixableErrorCount;
55 fixableWarningCount += result.fixableWarningCount;
56
57 output += `${chalk.underline(result.filePath)}\n`;
58
59 output += `${table(
60 messages.map(message => {
61 let messageType;
62
63 if (message.fatal || message.severity === 2) {
64 messageType = chalk.red("error");
65 summaryColor = "red";
66 } else {
67 messageType = chalk.yellow("warning");
68 }
69
70 return [
71 "",
72 message.line || 0,
73 message.column || 0,
74 messageType,
75 message.message.replace(/([^ ])\.$/u, "$1"),
76 chalk.dim(message.ruleId || "")
77 ];
78 }),
79 {
80 align: ["", "r", "l"],
81 stringLength(str) {
82 return stripAnsi(str).length;
83 }
84 }
85 ).split("\n").map(el => el.replace(/(\d+)\s+(\d+)/u, (m, p1, p2) => chalk.dim(`${p1}:${p2}`))).join("\n")}\n\n`;
86 });
87
88 const total = errorCount + warningCount;
89
90 if (total > 0) {
91 output += chalk[summaryColor].bold([
92 "\u2716 ", total, pluralize(" problem", total),
93 " (", errorCount, pluralize(" error", errorCount), ", ",
94 warningCount, pluralize(" warning", warningCount), ")\n"
95 ].join(""));
96
97 if (fixableErrorCount > 0 || fixableWarningCount > 0) {
98 output += chalk[summaryColor].bold([
99 " ", fixableErrorCount, pluralize(" error", fixableErrorCount), " and ",
100 fixableWarningCount, pluralize(" warning", fixableWarningCount),
101 " potentially fixable with the `--fix` option.\n"
102 ].join(""));
103 }
104 }
105
106 // Resets output color, for prevent change on top level
107 return total > 0 ? chalk.reset(output) : "";
108};
109
110
111/***/ }),
112
113/***/ 744:
114/***/ ((module) => {
115
116module.exports = require("chalk");
117
118/***/ }),
119
120/***/ 916:
121/***/ ((module) => {
122
123module.exports = require("strip-ansi");
124
125/***/ }),
126
127/***/ 495:
128/***/ ((module) => {
129
130module.exports = require("text-table");
131
132/***/ })
133
134/******/ });
135/************************************************************************/
136/******/ // The module cache
137/******/ var __webpack_module_cache__ = {};
138/******/
139/******/ // The require function
140/******/ function __nccwpck_require__(moduleId) {
141/******/ // Check if module is in cache
142/******/ var cachedModule = __webpack_module_cache__[moduleId];
143/******/ if (cachedModule !== undefined) {
144/******/ return cachedModule.exports;
145/******/ }
146/******/ // Create a new module (and put it into the cache)
147/******/ var module = __webpack_module_cache__[moduleId] = {
148/******/ // no module.id needed
149/******/ // no module.loaded needed
150/******/ exports: {}
151/******/ };
152/******/
153/******/ // Execute the module function
154/******/ var threw = true;
155/******/ try {
156/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
157/******/ threw = false;
158/******/ } finally {
159/******/ if(threw) delete __webpack_module_cache__[moduleId];
160/******/ }
161/******/
162/******/ // Return the exports of the module
163/******/ return module.exports;
164/******/ }
165/******/
166/************************************************************************/
167/******/ /* webpack/runtime/compat */
168/******/
169/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
170/******/
171/************************************************************************/
172/******/
173/******/ // startup
174/******/ // Load entry module and return exports
175/******/ // This entry module is referenced by other modules so it can't be inlined
176/******/ var __webpack_exports__ = __nccwpck_require__(429);
177/******/ module.exports = __webpack_exports__;
178/******/
179/******/ })()
180;
\No newline at end of file