@html-validate/stylish 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{LICENCE → LICENSE} +1 -1
- package/dist/{index.js → index.cjs.js} +55 -29
- package/dist/index.cjs.js.map +7 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.esm.js +220 -0
- package/dist/index.esm.js.map +7 -0
- package/package.json +11 -2
- package/dist/index.js.map +0 -7
package/{LICENCE → LICENSE}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2020-2022 David Sveningsson <ext@sidvind.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -19,7 +20,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
20
|
}
|
|
20
21
|
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
23
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
32
|
|
|
25
33
|
// node_modules/text-table/index.js
|
|
@@ -110,13 +118,24 @@ var require_text_table = __commonJS({
|
|
|
110
118
|
// src/index.ts
|
|
111
119
|
var src_exports = {};
|
|
112
120
|
__export(src_exports, {
|
|
113
|
-
|
|
121
|
+
Severity: () => Severity,
|
|
122
|
+
stylish: () => stylish
|
|
114
123
|
});
|
|
115
124
|
module.exports = __toCommonJS(src_exports);
|
|
116
125
|
|
|
117
126
|
// src/stylish.ts
|
|
118
127
|
var kleur = __toESM(require("kleur/colors"));
|
|
119
128
|
var import_text_table = __toESM(require_text_table());
|
|
129
|
+
|
|
130
|
+
// src/severity.ts
|
|
131
|
+
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
132
|
+
Severity2[Severity2["OFF"] = 0] = "OFF";
|
|
133
|
+
Severity2[Severity2["WARN"] = 1] = "WARN";
|
|
134
|
+
Severity2[Severity2["ERROR"] = 2] = "ERROR";
|
|
135
|
+
return Severity2;
|
|
136
|
+
})(Severity || {});
|
|
137
|
+
|
|
138
|
+
// src/stylish.ts
|
|
120
139
|
function pluralize(word, count) {
|
|
121
140
|
return count === 1 ? word : `${word}s`;
|
|
122
141
|
}
|
|
@@ -174,36 +193,43 @@ function stylish(results) {
|
|
|
174
193
|
});
|
|
175
194
|
const total = errorCount + warningCount;
|
|
176
195
|
if (total > 0) {
|
|
177
|
-
output += summaryColor(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
196
|
+
output += summaryColor(
|
|
197
|
+
kleur.bold(
|
|
198
|
+
[
|
|
199
|
+
"\u2716 ",
|
|
200
|
+
total,
|
|
201
|
+
pluralize(" problem", total),
|
|
202
|
+
" (",
|
|
203
|
+
errorCount,
|
|
204
|
+
pluralize(" error", errorCount),
|
|
205
|
+
", ",
|
|
206
|
+
warningCount,
|
|
207
|
+
pluralize(" warning", warningCount),
|
|
208
|
+
")\n"
|
|
209
|
+
].join("")
|
|
210
|
+
)
|
|
211
|
+
);
|
|
189
212
|
if (fixableErrorCount > 0 || fixableWarningCount > 0) {
|
|
190
|
-
output += summaryColor(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
213
|
+
output += summaryColor(
|
|
214
|
+
kleur.bold(
|
|
215
|
+
[
|
|
216
|
+
" ",
|
|
217
|
+
fixableErrorCount,
|
|
218
|
+
pluralize(" error", fixableErrorCount),
|
|
219
|
+
" and ",
|
|
220
|
+
fixableWarningCount,
|
|
221
|
+
pluralize(" warning", fixableWarningCount),
|
|
222
|
+
" potentially fixable with the `--fix` option.\n"
|
|
223
|
+
].join("")
|
|
224
|
+
)
|
|
225
|
+
);
|
|
199
226
|
}
|
|
200
227
|
}
|
|
201
228
|
return total > 0 ? kleur.reset(output) : "";
|
|
202
229
|
}
|
|
203
|
-
var stylish_default = stylish;
|
|
204
|
-
|
|
205
|
-
// src/index.ts
|
|
206
|
-
var src_default = stylish_default;
|
|
207
230
|
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
-
0 && (module.exports = {
|
|
209
|
-
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
Severity,
|
|
233
|
+
stylish
|
|
234
|
+
});
|
|
235
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../node_modules/text-table/index.js", "../src/index.ts", "../src/stylish.ts", "../src/severity.ts"],
|
|
4
|
+
"sourcesContent": ["module.exports = function (rows_, opts) {\n if (!opts) opts = {};\n var hsep = opts.hsep === undefined ? ' ' : opts.hsep;\n var align = opts.align || [];\n var stringLength = opts.stringLength\n || function (s) { return String(s).length; }\n ;\n \n var dotsizes = reduce(rows_, function (acc, row) {\n forEach(row, function (c, ix) {\n var n = dotindex(c);\n if (!acc[ix] || n > acc[ix]) acc[ix] = n;\n });\n return acc;\n }, []);\n \n var rows = map(rows_, function (row) {\n return map(row, function (c_, ix) {\n var c = String(c_);\n if (align[ix] === '.') {\n var index = dotindex(c);\n var size = dotsizes[ix] + (/\\./.test(c) ? 1 : 2)\n - (stringLength(c) - index)\n ;\n return c + Array(size).join(' ');\n }\n else return c;\n });\n });\n \n var sizes = reduce(rows, function (acc, row) {\n forEach(row, function (c, ix) {\n var n = stringLength(c);\n if (!acc[ix] || n > acc[ix]) acc[ix] = n;\n });\n return acc;\n }, []);\n \n return map(rows, function (row) {\n return map(row, function (c, ix) {\n var n = (sizes[ix] - stringLength(c)) || 0;\n var s = Array(Math.max(n + 1, 1)).join(' ');\n if (align[ix] === 'r' || align[ix] === '.') {\n return s + c;\n }\n if (align[ix] === 'c') {\n return Array(Math.ceil(n / 2 + 1)).join(' ')\n + c + Array(Math.floor(n / 2 + 1)).join(' ')\n ;\n }\n \n return c + s;\n }).join(hsep).replace(/\\s+$/, '');\n }).join('\\n');\n};\n\nfunction dotindex (c) {\n var m = /\\.[^.]*$/.exec(c);\n return m ? m.index + 1 : c.length;\n}\n\nfunction reduce (xs, f, init) {\n if (xs.reduce) return xs.reduce(f, init);\n var i = 0;\n var acc = arguments.length >= 3 ? init : xs[i++];\n for (; i < xs.length; i++) {\n f(acc, xs[i], i);\n }\n return acc;\n}\n\nfunction forEach (xs, f) {\n if (xs.forEach) return xs.forEach(f);\n for (var i = 0; i < xs.length; i++) {\n f.call(xs, xs[i], i);\n }\n}\n\nfunction map (xs, f) {\n if (xs.map) return xs.map(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n res.push(f.call(xs, xs[i], i));\n }\n return res;\n}\n", "export { stylish } from \"./stylish\";\nexport { Severity } from \"./severity\";\n", "import * as kleur from \"kleur/colors\";\nimport table, { type Options } from \"text-table\";\nimport { type Result } from \"./result\";\nimport { Severity } from \"./severity\";\n\n/**\n * Given a word and a count, append an s if count is not one.\n * @param word - A word in its singular form.\n * @param count - A number controlling whether word should be pluralized.\n * @returns - The original word with an s on the end if count is not one.\n */\nfunction pluralize(word: string, count: number): string {\n\treturn count === 1 ? word : `${word}s`;\n}\n\n/**\n * Given a line with \" $\\{line\\} $\\{column\\} \" where line is right-aligned and\n * column is left-aligned it replaces the delimiter with a colon.\n */\nfunction centerLineColumn(el: string): string {\n\treturn el.replace(/(\\d+)\\s+(\\d+)/u, (_m, p1: string, p2: string) => kleur.dim(`${p1}:${p2}`));\n}\n\n/**\n * Strip ANSI color escape sequences from text.\n */\nfunction stripAnsi(text: string): string {\n\t/* eslint-disable-next-line no-control-regex -- expected to match control characters */\n\treturn text.replace(/\\u001B\\[[0-9;]*m/g, \"\");\n}\n\n/* eslint-disable-next-line sonarjs/cognitive-complexity -- technical debt */\nexport function stylish(results: Result[]): string {\n\tlet output = \"\\n\";\n\tlet errorCount = 0;\n\tlet warningCount = 0;\n\tlet fixableErrorCount = 0;\n\tlet fixableWarningCount = 0;\n\tlet summaryColor: kleur.Colorize = kleur.yellow;\n\n\tresults.forEach((result) => {\n\t\tconst messages = result.messages;\n\n\t\tif (messages.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\terrorCount += result.errorCount;\n\t\twarningCount += result.warningCount;\n\t\tfixableErrorCount += result.fixableErrorCount;\n\t\tfixableWarningCount += result.fixableWarningCount;\n\n\t\tconst rows = messages.map((message) => {\n\t\t\tlet messageType;\n\n\t\t\tif (message.fatal || message.severity === Severity.ERROR) {\n\t\t\t\tmessageType = kleur.red(\"error\");\n\t\t\t\tsummaryColor = kleur.red;\n\t\t\t} else {\n\t\t\t\tmessageType = kleur.yellow(\"warning\");\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t\"\",\n\t\t\t\tmessage.line || 0,\n\t\t\t\tmessage.column || 0,\n\t\t\t\tmessageType,\n\t\t\t\tmessage.message.replace(/([^ ])\\.$/u, \"$1\"),\n\t\t\t\tmessage.ruleId ? kleur.dim(message.ruleId) : \"\",\n\t\t\t];\n\t\t});\n\n\t\tconst options: Options = {\n\t\t\talign: [\"l\", \"r\", \"l\"],\n\t\t\tstringLength(str: string): number {\n\t\t\t\treturn stripAnsi(str).length;\n\t\t\t},\n\t\t};\n\t\tconst formattedTable = table(rows, options).split(\"\\n\").map(centerLineColumn).join(\"\\n\");\n\n\t\toutput += `${kleur.underline(result.filePath)}\\n`;\n\t\toutput += `${formattedTable}\\n\\n`;\n\t});\n\n\tconst total = errorCount + warningCount;\n\n\tif (total > 0) {\n\t\toutput += summaryColor(\n\t\t\tkleur.bold(\n\t\t\t\t[\n\t\t\t\t\t\"\\u2716 \",\n\t\t\t\t\ttotal,\n\t\t\t\t\tpluralize(\" problem\", total),\n\t\t\t\t\t\" (\",\n\t\t\t\t\terrorCount,\n\t\t\t\t\tpluralize(\" error\", errorCount),\n\t\t\t\t\t\", \",\n\t\t\t\t\twarningCount,\n\t\t\t\t\tpluralize(\" warning\", warningCount),\n\t\t\t\t\t\")\\n\",\n\t\t\t\t].join(\"\")\n\t\t\t)\n\t\t);\n\n\t\tif (fixableErrorCount > 0 || fixableWarningCount > 0) {\n\t\t\toutput += summaryColor(\n\t\t\t\tkleur.bold(\n\t\t\t\t\t[\n\t\t\t\t\t\t\" \",\n\t\t\t\t\t\tfixableErrorCount,\n\t\t\t\t\t\tpluralize(\" error\", fixableErrorCount),\n\t\t\t\t\t\t\" and \",\n\t\t\t\t\t\tfixableWarningCount,\n\t\t\t\t\t\tpluralize(\" warning\", fixableWarningCount),\n\t\t\t\t\t\t\" potentially fixable with the `--fix` option.\\n\",\n\t\t\t\t\t].join(\"\")\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\t// Resets output color, for prevent change on top level\n\treturn total > 0 ? kleur.reset(output) : \"\";\n}\n", "export enum Severity {\n\tOFF = 0,\n\tWARN = 1,\n\tERROR = 2,\n}\n"],
|
|
5
|
+
"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severity", "table"]
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare enum Severity {
|
|
1
|
+
export declare enum Severity {
|
|
2
2
|
OFF = 0,
|
|
3
3
|
WARN = 1,
|
|
4
4
|
ERROR = 2
|
|
@@ -19,7 +19,6 @@ export interface Result {
|
|
|
19
19
|
fixableErrorCount: number;
|
|
20
20
|
fixableWarningCount: number;
|
|
21
21
|
}
|
|
22
|
-
declare function stylish(results: Result[]): string;
|
|
23
|
-
export default stylish;
|
|
22
|
+
export declare function stylish(results: Result[]): string;
|
|
24
23
|
|
|
25
24
|
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// node_modules/text-table/index.js
|
|
28
|
+
var require_text_table = __commonJS({
|
|
29
|
+
"node_modules/text-table/index.js"(exports, module) {
|
|
30
|
+
module.exports = function(rows_, opts) {
|
|
31
|
+
if (!opts)
|
|
32
|
+
opts = {};
|
|
33
|
+
var hsep = opts.hsep === void 0 ? " " : opts.hsep;
|
|
34
|
+
var align = opts.align || [];
|
|
35
|
+
var stringLength = opts.stringLength || function(s) {
|
|
36
|
+
return String(s).length;
|
|
37
|
+
};
|
|
38
|
+
var dotsizes = reduce(rows_, function(acc, row) {
|
|
39
|
+
forEach(row, function(c, ix) {
|
|
40
|
+
var n = dotindex(c);
|
|
41
|
+
if (!acc[ix] || n > acc[ix])
|
|
42
|
+
acc[ix] = n;
|
|
43
|
+
});
|
|
44
|
+
return acc;
|
|
45
|
+
}, []);
|
|
46
|
+
var rows = map(rows_, function(row) {
|
|
47
|
+
return map(row, function(c_, ix) {
|
|
48
|
+
var c = String(c_);
|
|
49
|
+
if (align[ix] === ".") {
|
|
50
|
+
var index = dotindex(c);
|
|
51
|
+
var size = dotsizes[ix] + (/\./.test(c) ? 1 : 2) - (stringLength(c) - index);
|
|
52
|
+
return c + Array(size).join(" ");
|
|
53
|
+
} else
|
|
54
|
+
return c;
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
var sizes = reduce(rows, function(acc, row) {
|
|
58
|
+
forEach(row, function(c, ix) {
|
|
59
|
+
var n = stringLength(c);
|
|
60
|
+
if (!acc[ix] || n > acc[ix])
|
|
61
|
+
acc[ix] = n;
|
|
62
|
+
});
|
|
63
|
+
return acc;
|
|
64
|
+
}, []);
|
|
65
|
+
return map(rows, function(row) {
|
|
66
|
+
return map(row, function(c, ix) {
|
|
67
|
+
var n = sizes[ix] - stringLength(c) || 0;
|
|
68
|
+
var s = Array(Math.max(n + 1, 1)).join(" ");
|
|
69
|
+
if (align[ix] === "r" || align[ix] === ".") {
|
|
70
|
+
return s + c;
|
|
71
|
+
}
|
|
72
|
+
if (align[ix] === "c") {
|
|
73
|
+
return Array(Math.ceil(n / 2 + 1)).join(" ") + c + Array(Math.floor(n / 2 + 1)).join(" ");
|
|
74
|
+
}
|
|
75
|
+
return c + s;
|
|
76
|
+
}).join(hsep).replace(/\s+$/, "");
|
|
77
|
+
}).join("\n");
|
|
78
|
+
};
|
|
79
|
+
function dotindex(c) {
|
|
80
|
+
var m = /\.[^.]*$/.exec(c);
|
|
81
|
+
return m ? m.index + 1 : c.length;
|
|
82
|
+
}
|
|
83
|
+
function reduce(xs, f, init) {
|
|
84
|
+
if (xs.reduce)
|
|
85
|
+
return xs.reduce(f, init);
|
|
86
|
+
var i = 0;
|
|
87
|
+
var acc = arguments.length >= 3 ? init : xs[i++];
|
|
88
|
+
for (; i < xs.length; i++) {
|
|
89
|
+
f(acc, xs[i], i);
|
|
90
|
+
}
|
|
91
|
+
return acc;
|
|
92
|
+
}
|
|
93
|
+
function forEach(xs, f) {
|
|
94
|
+
if (xs.forEach)
|
|
95
|
+
return xs.forEach(f);
|
|
96
|
+
for (var i = 0; i < xs.length; i++) {
|
|
97
|
+
f.call(xs, xs[i], i);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function map(xs, f) {
|
|
101
|
+
if (xs.map)
|
|
102
|
+
return xs.map(f);
|
|
103
|
+
var res = [];
|
|
104
|
+
for (var i = 0; i < xs.length; i++) {
|
|
105
|
+
res.push(f.call(xs, xs[i], i));
|
|
106
|
+
}
|
|
107
|
+
return res;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// src/stylish.ts
|
|
113
|
+
var import_text_table = __toESM(require_text_table());
|
|
114
|
+
import * as kleur from "kleur/colors";
|
|
115
|
+
|
|
116
|
+
// src/severity.ts
|
|
117
|
+
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
118
|
+
Severity2[Severity2["OFF"] = 0] = "OFF";
|
|
119
|
+
Severity2[Severity2["WARN"] = 1] = "WARN";
|
|
120
|
+
Severity2[Severity2["ERROR"] = 2] = "ERROR";
|
|
121
|
+
return Severity2;
|
|
122
|
+
})(Severity || {});
|
|
123
|
+
|
|
124
|
+
// src/stylish.ts
|
|
125
|
+
function pluralize(word, count) {
|
|
126
|
+
return count === 1 ? word : `${word}s`;
|
|
127
|
+
}
|
|
128
|
+
function centerLineColumn(el) {
|
|
129
|
+
return el.replace(/(\d+)\s+(\d+)/u, (_m, p1, p2) => kleur.dim(`${p1}:${p2}`));
|
|
130
|
+
}
|
|
131
|
+
function stripAnsi(text) {
|
|
132
|
+
return text.replace(/\u001B\[[0-9;]*m/g, "");
|
|
133
|
+
}
|
|
134
|
+
function stylish(results) {
|
|
135
|
+
let output = "\n";
|
|
136
|
+
let errorCount = 0;
|
|
137
|
+
let warningCount = 0;
|
|
138
|
+
let fixableErrorCount = 0;
|
|
139
|
+
let fixableWarningCount = 0;
|
|
140
|
+
let summaryColor = kleur.yellow;
|
|
141
|
+
results.forEach((result) => {
|
|
142
|
+
const messages = result.messages;
|
|
143
|
+
if (messages.length === 0) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
errorCount += result.errorCount;
|
|
147
|
+
warningCount += result.warningCount;
|
|
148
|
+
fixableErrorCount += result.fixableErrorCount;
|
|
149
|
+
fixableWarningCount += result.fixableWarningCount;
|
|
150
|
+
const rows = messages.map((message) => {
|
|
151
|
+
let messageType;
|
|
152
|
+
if (message.fatal || message.severity === 2 /* ERROR */) {
|
|
153
|
+
messageType = kleur.red("error");
|
|
154
|
+
summaryColor = kleur.red;
|
|
155
|
+
} else {
|
|
156
|
+
messageType = kleur.yellow("warning");
|
|
157
|
+
}
|
|
158
|
+
return [
|
|
159
|
+
"",
|
|
160
|
+
message.line || 0,
|
|
161
|
+
message.column || 0,
|
|
162
|
+
messageType,
|
|
163
|
+
message.message.replace(/([^ ])\.$/u, "$1"),
|
|
164
|
+
message.ruleId ? kleur.dim(message.ruleId) : ""
|
|
165
|
+
];
|
|
166
|
+
});
|
|
167
|
+
const options = {
|
|
168
|
+
align: ["l", "r", "l"],
|
|
169
|
+
stringLength(str) {
|
|
170
|
+
return stripAnsi(str).length;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const formattedTable = (0, import_text_table.default)(rows, options).split("\n").map(centerLineColumn).join("\n");
|
|
174
|
+
output += `${kleur.underline(result.filePath)}
|
|
175
|
+
`;
|
|
176
|
+
output += `${formattedTable}
|
|
177
|
+
|
|
178
|
+
`;
|
|
179
|
+
});
|
|
180
|
+
const total = errorCount + warningCount;
|
|
181
|
+
if (total > 0) {
|
|
182
|
+
output += summaryColor(
|
|
183
|
+
kleur.bold(
|
|
184
|
+
[
|
|
185
|
+
"\u2716 ",
|
|
186
|
+
total,
|
|
187
|
+
pluralize(" problem", total),
|
|
188
|
+
" (",
|
|
189
|
+
errorCount,
|
|
190
|
+
pluralize(" error", errorCount),
|
|
191
|
+
", ",
|
|
192
|
+
warningCount,
|
|
193
|
+
pluralize(" warning", warningCount),
|
|
194
|
+
")\n"
|
|
195
|
+
].join("")
|
|
196
|
+
)
|
|
197
|
+
);
|
|
198
|
+
if (fixableErrorCount > 0 || fixableWarningCount > 0) {
|
|
199
|
+
output += summaryColor(
|
|
200
|
+
kleur.bold(
|
|
201
|
+
[
|
|
202
|
+
" ",
|
|
203
|
+
fixableErrorCount,
|
|
204
|
+
pluralize(" error", fixableErrorCount),
|
|
205
|
+
" and ",
|
|
206
|
+
fixableWarningCount,
|
|
207
|
+
pluralize(" warning", fixableWarningCount),
|
|
208
|
+
" potentially fixable with the `--fix` option.\n"
|
|
209
|
+
].join("")
|
|
210
|
+
)
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return total > 0 ? kleur.reset(output) : "";
|
|
215
|
+
}
|
|
216
|
+
export {
|
|
217
|
+
Severity,
|
|
218
|
+
stylish
|
|
219
|
+
};
|
|
220
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../node_modules/text-table/index.js", "../src/stylish.ts", "../src/severity.ts"],
|
|
4
|
+
"sourcesContent": ["module.exports = function (rows_, opts) {\n if (!opts) opts = {};\n var hsep = opts.hsep === undefined ? ' ' : opts.hsep;\n var align = opts.align || [];\n var stringLength = opts.stringLength\n || function (s) { return String(s).length; }\n ;\n \n var dotsizes = reduce(rows_, function (acc, row) {\n forEach(row, function (c, ix) {\n var n = dotindex(c);\n if (!acc[ix] || n > acc[ix]) acc[ix] = n;\n });\n return acc;\n }, []);\n \n var rows = map(rows_, function (row) {\n return map(row, function (c_, ix) {\n var c = String(c_);\n if (align[ix] === '.') {\n var index = dotindex(c);\n var size = dotsizes[ix] + (/\\./.test(c) ? 1 : 2)\n - (stringLength(c) - index)\n ;\n return c + Array(size).join(' ');\n }\n else return c;\n });\n });\n \n var sizes = reduce(rows, function (acc, row) {\n forEach(row, function (c, ix) {\n var n = stringLength(c);\n if (!acc[ix] || n > acc[ix]) acc[ix] = n;\n });\n return acc;\n }, []);\n \n return map(rows, function (row) {\n return map(row, function (c, ix) {\n var n = (sizes[ix] - stringLength(c)) || 0;\n var s = Array(Math.max(n + 1, 1)).join(' ');\n if (align[ix] === 'r' || align[ix] === '.') {\n return s + c;\n }\n if (align[ix] === 'c') {\n return Array(Math.ceil(n / 2 + 1)).join(' ')\n + c + Array(Math.floor(n / 2 + 1)).join(' ')\n ;\n }\n \n return c + s;\n }).join(hsep).replace(/\\s+$/, '');\n }).join('\\n');\n};\n\nfunction dotindex (c) {\n var m = /\\.[^.]*$/.exec(c);\n return m ? m.index + 1 : c.length;\n}\n\nfunction reduce (xs, f, init) {\n if (xs.reduce) return xs.reduce(f, init);\n var i = 0;\n var acc = arguments.length >= 3 ? init : xs[i++];\n for (; i < xs.length; i++) {\n f(acc, xs[i], i);\n }\n return acc;\n}\n\nfunction forEach (xs, f) {\n if (xs.forEach) return xs.forEach(f);\n for (var i = 0; i < xs.length; i++) {\n f.call(xs, xs[i], i);\n }\n}\n\nfunction map (xs, f) {\n if (xs.map) return xs.map(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n res.push(f.call(xs, xs[i], i));\n }\n return res;\n}\n", "import * as kleur from \"kleur/colors\";\nimport table, { type Options } from \"text-table\";\nimport { type Result } from \"./result\";\nimport { Severity } from \"./severity\";\n\n/**\n * Given a word and a count, append an s if count is not one.\n * @param word - A word in its singular form.\n * @param count - A number controlling whether word should be pluralized.\n * @returns - The original word with an s on the end if count is not one.\n */\nfunction pluralize(word: string, count: number): string {\n\treturn count === 1 ? word : `${word}s`;\n}\n\n/**\n * Given a line with \" $\\{line\\} $\\{column\\} \" where line is right-aligned and\n * column is left-aligned it replaces the delimiter with a colon.\n */\nfunction centerLineColumn(el: string): string {\n\treturn el.replace(/(\\d+)\\s+(\\d+)/u, (_m, p1: string, p2: string) => kleur.dim(`${p1}:${p2}`));\n}\n\n/**\n * Strip ANSI color escape sequences from text.\n */\nfunction stripAnsi(text: string): string {\n\t/* eslint-disable-next-line no-control-regex -- expected to match control characters */\n\treturn text.replace(/\\u001B\\[[0-9;]*m/g, \"\");\n}\n\n/* eslint-disable-next-line sonarjs/cognitive-complexity -- technical debt */\nexport function stylish(results: Result[]): string {\n\tlet output = \"\\n\";\n\tlet errorCount = 0;\n\tlet warningCount = 0;\n\tlet fixableErrorCount = 0;\n\tlet fixableWarningCount = 0;\n\tlet summaryColor: kleur.Colorize = kleur.yellow;\n\n\tresults.forEach((result) => {\n\t\tconst messages = result.messages;\n\n\t\tif (messages.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\terrorCount += result.errorCount;\n\t\twarningCount += result.warningCount;\n\t\tfixableErrorCount += result.fixableErrorCount;\n\t\tfixableWarningCount += result.fixableWarningCount;\n\n\t\tconst rows = messages.map((message) => {\n\t\t\tlet messageType;\n\n\t\t\tif (message.fatal || message.severity === Severity.ERROR) {\n\t\t\t\tmessageType = kleur.red(\"error\");\n\t\t\t\tsummaryColor = kleur.red;\n\t\t\t} else {\n\t\t\t\tmessageType = kleur.yellow(\"warning\");\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t\"\",\n\t\t\t\tmessage.line || 0,\n\t\t\t\tmessage.column || 0,\n\t\t\t\tmessageType,\n\t\t\t\tmessage.message.replace(/([^ ])\\.$/u, \"$1\"),\n\t\t\t\tmessage.ruleId ? kleur.dim(message.ruleId) : \"\",\n\t\t\t];\n\t\t});\n\n\t\tconst options: Options = {\n\t\t\talign: [\"l\", \"r\", \"l\"],\n\t\t\tstringLength(str: string): number {\n\t\t\t\treturn stripAnsi(str).length;\n\t\t\t},\n\t\t};\n\t\tconst formattedTable = table(rows, options).split(\"\\n\").map(centerLineColumn).join(\"\\n\");\n\n\t\toutput += `${kleur.underline(result.filePath)}\\n`;\n\t\toutput += `${formattedTable}\\n\\n`;\n\t});\n\n\tconst total = errorCount + warningCount;\n\n\tif (total > 0) {\n\t\toutput += summaryColor(\n\t\t\tkleur.bold(\n\t\t\t\t[\n\t\t\t\t\t\"\\u2716 \",\n\t\t\t\t\ttotal,\n\t\t\t\t\tpluralize(\" problem\", total),\n\t\t\t\t\t\" (\",\n\t\t\t\t\terrorCount,\n\t\t\t\t\tpluralize(\" error\", errorCount),\n\t\t\t\t\t\", \",\n\t\t\t\t\twarningCount,\n\t\t\t\t\tpluralize(\" warning\", warningCount),\n\t\t\t\t\t\")\\n\",\n\t\t\t\t].join(\"\")\n\t\t\t)\n\t\t);\n\n\t\tif (fixableErrorCount > 0 || fixableWarningCount > 0) {\n\t\t\toutput += summaryColor(\n\t\t\t\tkleur.bold(\n\t\t\t\t\t[\n\t\t\t\t\t\t\" \",\n\t\t\t\t\t\tfixableErrorCount,\n\t\t\t\t\t\tpluralize(\" error\", fixableErrorCount),\n\t\t\t\t\t\t\" and \",\n\t\t\t\t\t\tfixableWarningCount,\n\t\t\t\t\t\tpluralize(\" warning\", fixableWarningCount),\n\t\t\t\t\t\t\" potentially fixable with the `--fix` option.\\n\",\n\t\t\t\t\t].join(\"\")\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\t// Resets output color, for prevent change on top level\n\treturn total > 0 ? kleur.reset(output) : \"\";\n}\n", "export enum Severity {\n\tOFF = 0,\n\tWARN = 1,\n\tERROR = 2,\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,WAAO,UAAU,SAAU,OAAO,MAAM;AACpC,UAAI,CAAC;AAAM,eAAO,CAAC;AACnB,UAAI,OAAO,KAAK,SAAS,SAAY,OAAO,KAAK;AACjD,UAAI,QAAQ,KAAK,SAAS,CAAC;AAC3B,UAAI,eAAe,KAAK,gBACjB,SAAU,GAAG;AAAE,eAAO,OAAO,CAAC,EAAE;AAAA,MAAQ;AAG/C,UAAI,WAAW,OAAO,OAAO,SAAU,KAAK,KAAK;AAC7C,gBAAQ,KAAK,SAAU,GAAG,IAAI;AAC1B,cAAI,IAAI,SAAS,CAAC;AAClB,cAAI,CAAC,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE;AAAG,gBAAI,EAAE,IAAI;AAAA,QAC3C,CAAC;AACD,eAAO;AAAA,MACX,GAAG,CAAC,CAAC;AAEL,UAAI,OAAO,IAAI,OAAO,SAAU,KAAK;AACjC,eAAO,IAAI,KAAK,SAAU,IAAI,IAAI;AAC9B,cAAI,IAAI,OAAO,EAAE;AACjB,cAAI,MAAM,EAAE,MAAM,KAAK;AACnB,gBAAI,QAAQ,SAAS,CAAC;AACtB,gBAAI,OAAO,SAAS,EAAE,KAAK,KAAK,KAAK,CAAC,IAAI,IAAI,MACvC,aAAa,CAAC,IAAI;AAEzB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I,oBAAoB,KAAK,sBAAsB,GAAG;AACrD,gBAAU;AAAA,QACH;AAAA,UACL;AAAA,YACC;AAAA,YACA;AAAA,YACA,UAAU,UAAU,iBAAiB;AAAA,YACrC;AAAA,YACA;AAAA,YACA,UAAU,YAAY,mBAAmB;AAAA,YACzC;AAAA,UACD,EAAE,KAAK,EAAE;AAAA,QACV;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAGA,SAAO,QAAQ,IAAU,YAAM,MAAM,IAAI;AAC1C;",
|
|
6
|
+
"names": ["Severity", "table"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@html-validate/stylish",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "ESLint compatible stylish formatter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stylish",
|
|
@@ -17,7 +17,16 @@
|
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"author": "David Sveningsson <ext@sidvind.com>",
|
|
19
19
|
"sideEffects": false,
|
|
20
|
-
"main": "dist/index.js",
|
|
20
|
+
"main": "dist/index.cjs.js",
|
|
21
|
+
"module": "dist/index.esm.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"require": "./dist/index.cjs.js",
|
|
27
|
+
"import": "./dist/index.esm.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
21
30
|
"files": [
|
|
22
31
|
"dist"
|
|
23
32
|
],
|
package/dist/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../node_modules/text-table/index.js", "../src/index.ts", "../src/stylish.ts"],
|
|
4
|
-
"sourcesContent": ["module.exports = function (rows_, opts) {\n if (!opts) opts = {};\n var hsep = opts.hsep === undefined ? ' ' : opts.hsep;\n var align = opts.align || [];\n var stringLength = opts.stringLength\n || function (s) { return String(s).length; }\n ;\n \n var dotsizes = reduce(rows_, function (acc, row) {\n forEach(row, function (c, ix) {\n var n = dotindex(c);\n if (!acc[ix] || n > acc[ix]) acc[ix] = n;\n });\n return acc;\n }, []);\n \n var rows = map(rows_, function (row) {\n return map(row, function (c_, ix) {\n var c = String(c_);\n if (align[ix] === '.') {\n var index = dotindex(c);\n var size = dotsizes[ix] + (/\\./.test(c) ? 1 : 2)\n - (stringLength(c) - index)\n ;\n return c + Array(size).join(' ');\n }\n else return c;\n });\n });\n \n var sizes = reduce(rows, function (acc, row) {\n forEach(row, function (c, ix) {\n var n = stringLength(c);\n if (!acc[ix] || n > acc[ix]) acc[ix] = n;\n });\n return acc;\n }, []);\n \n return map(rows, function (row) {\n return map(row, function (c, ix) {\n var n = (sizes[ix] - stringLength(c)) || 0;\n var s = Array(Math.max(n + 1, 1)).join(' ');\n if (align[ix] === 'r' || align[ix] === '.') {\n return s + c;\n }\n if (align[ix] === 'c') {\n return Array(Math.ceil(n / 2 + 1)).join(' ')\n + c + Array(Math.floor(n / 2 + 1)).join(' ')\n ;\n }\n \n return c + s;\n }).join(hsep).replace(/\\s+$/, '');\n }).join('\\n');\n};\n\nfunction dotindex (c) {\n var m = /\\.[^.]*$/.exec(c);\n return m ? m.index + 1 : c.length;\n}\n\nfunction reduce (xs, f, init) {\n if (xs.reduce) return xs.reduce(f, init);\n var i = 0;\n var acc = arguments.length >= 3 ? init : xs[i++];\n for (; i < xs.length; i++) {\n f(acc, xs[i], i);\n }\n return acc;\n}\n\nfunction forEach (xs, f) {\n if (xs.forEach) return xs.forEach(f);\n for (var i = 0; i < xs.length; i++) {\n f.call(xs, xs[i], i);\n }\n}\n\nfunction map (xs, f) {\n if (xs.map) return xs.map(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n res.push(f.call(xs, xs[i], i));\n }\n return res;\n}\n", "import stylish from \"./stylish\";\n\nexport default stylish;\n", "import * as kleur from \"kleur/colors\";\nimport table, { type Options } from \"text-table\";\nimport { type Result } from \"./result\";\nimport { Severity } from \"./severity\";\n\n/**\n * Given a word and a count, append an s if count is not one.\n * @param word - A word in its singular form.\n * @param count - A number controlling whether word should be pluralized.\n * @returns - The original word with an s on the end if count is not one.\n */\nfunction pluralize(word: string, count: number): string {\n\treturn count === 1 ? word : `${word}s`;\n}\n\n/**\n * Given a line with \" $\\{line\\} $\\{column\\} \" where line is right-aligned and\n * column is left-aligned it replaces the delimiter with a colon.\n */\nfunction centerLineColumn(el: string): string {\n\treturn el.replace(/(\\d+)\\s+(\\d+)/u, (_m, p1: string, p2: string) => kleur.dim(`${p1}:${p2}`));\n}\n\n/**\n * Strip ANSI color escape sequences from text.\n */\nfunction stripAnsi(text: string): string {\n\t/* eslint-disable-next-line no-control-regex */\n\treturn text.replace(/\\u001B\\[[0-9;]*m/g, \"\");\n}\n\n/* eslint-disable-next-line sonarjs/cognitive-complexity */\nfunction stylish(results: Result[]): string {\n\tlet output = \"\\n\";\n\tlet errorCount = 0;\n\tlet warningCount = 0;\n\tlet fixableErrorCount = 0;\n\tlet fixableWarningCount = 0;\n\tlet summaryColor: kleur.Colorize = kleur.yellow;\n\n\tresults.forEach((result) => {\n\t\tconst messages = result.messages;\n\n\t\tif (messages.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\terrorCount += result.errorCount;\n\t\twarningCount += result.warningCount;\n\t\tfixableErrorCount += result.fixableErrorCount;\n\t\tfixableWarningCount += result.fixableWarningCount;\n\n\t\tconst rows = messages.map((message) => {\n\t\t\tlet messageType;\n\n\t\t\tif (message.fatal || message.severity === Severity.ERROR) {\n\t\t\t\tmessageType = kleur.red(\"error\");\n\t\t\t\tsummaryColor = kleur.red;\n\t\t\t} else {\n\t\t\t\tmessageType = kleur.yellow(\"warning\");\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t\"\",\n\t\t\t\tmessage.line || 0,\n\t\t\t\tmessage.column || 0,\n\t\t\t\tmessageType,\n\t\t\t\tmessage.message.replace(/([^ ])\\.$/u, \"$1\"),\n\t\t\t\tmessage.ruleId ? kleur.dim(message.ruleId) : \"\",\n\t\t\t];\n\t\t});\n\n\t\tconst options: Options = {\n\t\t\talign: [\"l\", \"r\", \"l\"],\n\t\t\tstringLength(str: string): number {\n\t\t\t\treturn stripAnsi(str).length;\n\t\t\t},\n\t\t};\n\t\tconst formattedTable = table(rows, options).split(\"\\n\").map(centerLineColumn).join(\"\\n\");\n\n\t\toutput += `${kleur.underline(result.filePath)}\\n`;\n\t\toutput += `${formattedTable}\\n\\n`;\n\t});\n\n\tconst total = errorCount + warningCount;\n\n\tif (total > 0) {\n\t\toutput += summaryColor(\n\t\t\tkleur.bold(\n\t\t\t\t[\n\t\t\t\t\t\"\\u2716 \",\n\t\t\t\t\ttotal,\n\t\t\t\t\tpluralize(\" problem\", total),\n\t\t\t\t\t\" (\",\n\t\t\t\t\terrorCount,\n\t\t\t\t\tpluralize(\" error\", errorCount),\n\t\t\t\t\t\", \",\n\t\t\t\t\twarningCount,\n\t\t\t\t\tpluralize(\" warning\", warningCount),\n\t\t\t\t\t\")\\n\",\n\t\t\t\t].join(\"\")\n\t\t\t)\n\t\t);\n\n\t\tif (fixableErrorCount > 0 || fixableWarningCount > 0) {\n\t\t\toutput += summaryColor(\n\t\t\t\tkleur.bold(\n\t\t\t\t\t[\n\t\t\t\t\t\t\" \",\n\t\t\t\t\t\tfixableErrorCount,\n\t\t\t\t\t\tpluralize(\" error\", fixableErrorCount),\n\t\t\t\t\t\t\" and \",\n\t\t\t\t\t\tfixableWarningCount,\n\t\t\t\t\t\tpluralize(\" warning\", fixableWarningCount),\n\t\t\t\t\t\t\" potentially fixable with the `--fix` option.\\n\",\n\t\t\t\t\t].join(\"\")\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\t// Resets output color, for prevent change on top level\n\treturn total > 0 ? kleur.reset(output) : \"\";\n}\n\nexport default stylish;\n"],
|
|
5
|
-
"mapp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