@html-validate/stylish 1.0.1 → 3.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/dist/index.d.ts +25 -2
- package/dist/index.js +208 -5
- package/dist/index.js.map +7 -0
- package/package.json +5 -69
- package/CHANGELOG.md +0 -17
- package/dist/message.d.ts +0 -9
- package/dist/message.js +0 -2
- package/dist/result.d.ts +0 -9
- package/dist/result.js +0 -2
- package/dist/severity.d.ts +0 -5
- package/dist/severity.js +0 -9
- package/dist/stylish.d.ts +0 -3
- package/dist/stylish.js +0 -124
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare enum Severity {
|
|
2
|
+
OFF = 0,
|
|
3
|
+
WARN = 1,
|
|
4
|
+
ERROR = 2
|
|
5
|
+
}
|
|
6
|
+
export interface Message {
|
|
7
|
+
ruleId?: string;
|
|
8
|
+
severity: Severity;
|
|
9
|
+
fatal?: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
line?: number;
|
|
12
|
+
column?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Result {
|
|
15
|
+
messages: Message[];
|
|
16
|
+
filePath: string;
|
|
17
|
+
errorCount: number;
|
|
18
|
+
warningCount: number;
|
|
19
|
+
fixableErrorCount: number;
|
|
20
|
+
fixableWarningCount: number;
|
|
21
|
+
}
|
|
22
|
+
declare function stylish(results: Result[]): string;
|
|
23
|
+
export default stylish;
|
|
24
|
+
|
|
25
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,209 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
9
|
};
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// node_modules/text-table/index.js
|
|
26
|
+
var require_text_table = __commonJS({
|
|
27
|
+
"node_modules/text-table/index.js"(exports, module2) {
|
|
28
|
+
module2.exports = function(rows_, opts) {
|
|
29
|
+
if (!opts)
|
|
30
|
+
opts = {};
|
|
31
|
+
var hsep = opts.hsep === void 0 ? " " : opts.hsep;
|
|
32
|
+
var align = opts.align || [];
|
|
33
|
+
var stringLength = opts.stringLength || function(s) {
|
|
34
|
+
return String(s).length;
|
|
35
|
+
};
|
|
36
|
+
var dotsizes = reduce(rows_, function(acc, row) {
|
|
37
|
+
forEach(row, function(c, ix) {
|
|
38
|
+
var n = dotindex(c);
|
|
39
|
+
if (!acc[ix] || n > acc[ix])
|
|
40
|
+
acc[ix] = n;
|
|
41
|
+
});
|
|
42
|
+
return acc;
|
|
43
|
+
}, []);
|
|
44
|
+
var rows = map(rows_, function(row) {
|
|
45
|
+
return map(row, function(c_, ix) {
|
|
46
|
+
var c = String(c_);
|
|
47
|
+
if (align[ix] === ".") {
|
|
48
|
+
var index = dotindex(c);
|
|
49
|
+
var size = dotsizes[ix] + (/\./.test(c) ? 1 : 2) - (stringLength(c) - index);
|
|
50
|
+
return c + Array(size).join(" ");
|
|
51
|
+
} else
|
|
52
|
+
return c;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
var sizes = reduce(rows, function(acc, row) {
|
|
56
|
+
forEach(row, function(c, ix) {
|
|
57
|
+
var n = stringLength(c);
|
|
58
|
+
if (!acc[ix] || n > acc[ix])
|
|
59
|
+
acc[ix] = n;
|
|
60
|
+
});
|
|
61
|
+
return acc;
|
|
62
|
+
}, []);
|
|
63
|
+
return map(rows, function(row) {
|
|
64
|
+
return map(row, function(c, ix) {
|
|
65
|
+
var n = sizes[ix] - stringLength(c) || 0;
|
|
66
|
+
var s = Array(Math.max(n + 1, 1)).join(" ");
|
|
67
|
+
if (align[ix] === "r" || align[ix] === ".") {
|
|
68
|
+
return s + c;
|
|
69
|
+
}
|
|
70
|
+
if (align[ix] === "c") {
|
|
71
|
+
return Array(Math.ceil(n / 2 + 1)).join(" ") + c + Array(Math.floor(n / 2 + 1)).join(" ");
|
|
72
|
+
}
|
|
73
|
+
return c + s;
|
|
74
|
+
}).join(hsep).replace(/\s+$/, "");
|
|
75
|
+
}).join("\n");
|
|
76
|
+
};
|
|
77
|
+
function dotindex(c) {
|
|
78
|
+
var m = /\.[^.]*$/.exec(c);
|
|
79
|
+
return m ? m.index + 1 : c.length;
|
|
80
|
+
}
|
|
81
|
+
function reduce(xs, f, init) {
|
|
82
|
+
if (xs.reduce)
|
|
83
|
+
return xs.reduce(f, init);
|
|
84
|
+
var i = 0;
|
|
85
|
+
var acc = arguments.length >= 3 ? init : xs[i++];
|
|
86
|
+
for (; i < xs.length; i++) {
|
|
87
|
+
f(acc, xs[i], i);
|
|
88
|
+
}
|
|
89
|
+
return acc;
|
|
90
|
+
}
|
|
91
|
+
function forEach(xs, f) {
|
|
92
|
+
if (xs.forEach)
|
|
93
|
+
return xs.forEach(f);
|
|
94
|
+
for (var i = 0; i < xs.length; i++) {
|
|
95
|
+
f.call(xs, xs[i], i);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function map(xs, f) {
|
|
99
|
+
if (xs.map)
|
|
100
|
+
return xs.map(f);
|
|
101
|
+
var res = [];
|
|
102
|
+
for (var i = 0; i < xs.length; i++) {
|
|
103
|
+
res.push(f.call(xs, xs[i], i));
|
|
104
|
+
}
|
|
105
|
+
return res;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// src/index.ts
|
|
111
|
+
var src_exports = {};
|
|
112
|
+
__export(src_exports, {
|
|
113
|
+
default: () => src_default
|
|
114
|
+
});
|
|
115
|
+
module.exports = __toCommonJS(src_exports);
|
|
116
|
+
|
|
117
|
+
// src/stylish.ts
|
|
118
|
+
var kleur = __toESM(require("kleur/colors"));
|
|
119
|
+
var import_text_table = __toESM(require_text_table());
|
|
120
|
+
function pluralize(word, count) {
|
|
121
|
+
return count === 1 ? word : `${word}s`;
|
|
122
|
+
}
|
|
123
|
+
function centerLineColumn(el) {
|
|
124
|
+
return el.replace(/(\d+)\s+(\d+)/u, (_m, p1, p2) => kleur.dim(`${p1}:${p2}`));
|
|
125
|
+
}
|
|
126
|
+
function stripAnsi(text) {
|
|
127
|
+
return text.replace(/\u001B\[[0-9;]*m/g, "");
|
|
128
|
+
}
|
|
129
|
+
function stylish(results) {
|
|
130
|
+
let output = "\n";
|
|
131
|
+
let errorCount = 0;
|
|
132
|
+
let warningCount = 0;
|
|
133
|
+
let fixableErrorCount = 0;
|
|
134
|
+
let fixableWarningCount = 0;
|
|
135
|
+
let summaryColor = kleur.yellow;
|
|
136
|
+
results.forEach((result) => {
|
|
137
|
+
const messages = result.messages;
|
|
138
|
+
if (messages.length === 0) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
errorCount += result.errorCount;
|
|
142
|
+
warningCount += result.warningCount;
|
|
143
|
+
fixableErrorCount += result.fixableErrorCount;
|
|
144
|
+
fixableWarningCount += result.fixableWarningCount;
|
|
145
|
+
const rows = messages.map((message) => {
|
|
146
|
+
let messageType;
|
|
147
|
+
if (message.fatal || message.severity === 2 /* ERROR */) {
|
|
148
|
+
messageType = kleur.red("error");
|
|
149
|
+
summaryColor = kleur.red;
|
|
150
|
+
} else {
|
|
151
|
+
messageType = kleur.yellow("warning");
|
|
152
|
+
}
|
|
153
|
+
return [
|
|
154
|
+
"",
|
|
155
|
+
message.line || 0,
|
|
156
|
+
message.column || 0,
|
|
157
|
+
messageType,
|
|
158
|
+
message.message.replace(/([^ ])\.$/u, "$1"),
|
|
159
|
+
message.ruleId ? kleur.dim(message.ruleId) : ""
|
|
160
|
+
];
|
|
161
|
+
});
|
|
162
|
+
const options = {
|
|
163
|
+
align: ["l", "r", "l"],
|
|
164
|
+
stringLength(str) {
|
|
165
|
+
return stripAnsi(str).length;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const formattedTable = (0, import_text_table.default)(rows, options).split("\n").map(centerLineColumn).join("\n");
|
|
169
|
+
output += `${kleur.underline(result.filePath)}
|
|
170
|
+
`;
|
|
171
|
+
output += `${formattedTable}
|
|
172
|
+
|
|
173
|
+
`;
|
|
174
|
+
});
|
|
175
|
+
const total = errorCount + warningCount;
|
|
176
|
+
if (total > 0) {
|
|
177
|
+
output += summaryColor(kleur.bold([
|
|
178
|
+
"\u2716 ",
|
|
179
|
+
total,
|
|
180
|
+
pluralize(" problem", total),
|
|
181
|
+
" (",
|
|
182
|
+
errorCount,
|
|
183
|
+
pluralize(" error", errorCount),
|
|
184
|
+
", ",
|
|
185
|
+
warningCount,
|
|
186
|
+
pluralize(" warning", warningCount),
|
|
187
|
+
")\n"
|
|
188
|
+
].join("")));
|
|
189
|
+
if (fixableErrorCount > 0 || fixableWarningCount > 0) {
|
|
190
|
+
output += summaryColor(kleur.bold([
|
|
191
|
+
" ",
|
|
192
|
+
fixableErrorCount,
|
|
193
|
+
pluralize(" error", fixableErrorCount),
|
|
194
|
+
" and ",
|
|
195
|
+
fixableWarningCount,
|
|
196
|
+
pluralize(" warning", fixableWarningCount),
|
|
197
|
+
" potentially fixable with the `--fix` option.\n"
|
|
198
|
+
].join("")));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return total > 0 ? kleur.reset(output) : "";
|
|
202
|
+
}
|
|
203
|
+
var stylish_default = stylish;
|
|
204
|
+
|
|
205
|
+
// src/index.ts
|
|
206
|
+
var src_default = stylish_default;
|
|
207
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
+
0 && (module.exports = {});
|
|
209
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,YAAO,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;AACl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AAAA,MAC3B;AAAA,MACA;AAAA,MACA,UAAU,UAAU,UAAU;AAAA,MAC9B;AAAA,MACA;AAAA,MACA,UAAU,YAAY,YAAY;AAAA,MAClC;AAAA,IACD,EAAE,KAAK,EAAE,CACV,CACD;AAEA,QAAI,oBAAoB,KAAK,sBAAsB,GAAG;AACrD,gBAAU,aACT,AAAM,WACL;AAAA,QACC;AAAA,QACA;AAAA,QACA,UAAU,UAAU,iBAAiB;AAAA,QACrC;AAAA,QACA;AAAA,QACA,UAAU,YAAY,mBAAmB;AAAA,QACzC;AAAA,MACD,EAAE,KAAK,EAAE,CACV,CACD;AAAA,IACD;AAAA,EACD;AAGA,SAAO,QAAQ,IAAI,AAAM,YAAM,MAAM,IAAI;AAC1C;AAEA,IAAO,kBAAQ;;;AD3Hf,IAAO,cAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@html-validate/stylish",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "ESLint compatible stylish formatter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stylish",
|
|
@@ -16,82 +16,18 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"author": "David Sveningsson <ext@sidvind.com>",
|
|
19
|
+
"sideEffects": false,
|
|
19
20
|
"main": "dist/index.js",
|
|
20
21
|
"files": [
|
|
21
|
-
"dist"
|
|
22
|
-
"!**/*.spec.js",
|
|
23
|
-
"!**/*.spec.d.ts"
|
|
22
|
+
"dist"
|
|
24
23
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsc --build",
|
|
27
|
-
"eslint": "eslint .",
|
|
28
|
-
"eslint:fix": "eslint --fix .",
|
|
29
|
-
"prepare": "husky install && git config commit.template ./node_modules/@html-validate/commitlint-config/gitmessage",
|
|
30
|
-
"prettier:check": "prettier --check .",
|
|
31
|
-
"prettier:write": "prettier --write .",
|
|
32
|
-
"semantic-release": "semantic-release",
|
|
33
|
-
"test": "jest"
|
|
34
|
-
},
|
|
35
|
-
"husky": {
|
|
36
|
-
"hooks": {
|
|
37
|
-
"pre-commit": "lint-staged",
|
|
38
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"commitlint": {
|
|
42
|
-
"extends": [
|
|
43
|
-
"@html-validate"
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
"lint-staged": {
|
|
47
|
-
"*.{ts,js,json,md}": "prettier --write"
|
|
48
|
-
},
|
|
49
|
-
"prettier": "@html-validate/prettier-config",
|
|
50
|
-
"jest": {
|
|
51
|
-
"preset": "@html-validate/jest-config",
|
|
52
|
-
"snapshotSerializers": [
|
|
53
|
-
"pretty-format/build/plugins/ConvertAnsi"
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
24
|
"dependencies": {
|
|
57
|
-
"kleur": "^4.0.0"
|
|
58
|
-
"text-table": "^0.2.0"
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@commitlint/cli": "12.1.1",
|
|
62
|
-
"@html-validate/commitlint-config": "1.3.1",
|
|
63
|
-
"@html-validate/eslint-config": "4.1.0",
|
|
64
|
-
"@html-validate/eslint-config-jest": "4.0.0",
|
|
65
|
-
"@html-validate/eslint-config-typescript": "4.0.0",
|
|
66
|
-
"@html-validate/jest-config": "1.2.9",
|
|
67
|
-
"@html-validate/prettier-config": "1.1.0",
|
|
68
|
-
"@html-validate/semantic-release-config": "1.2.6",
|
|
69
|
-
"@types/jest": "26.0.23",
|
|
70
|
-
"@types/node": "11.15.52",
|
|
71
|
-
"@types/text-table": "0.2.1",
|
|
72
|
-
"eslint": "7.25.0",
|
|
73
|
-
"husky": "6.0.0",
|
|
74
|
-
"jest": "26.6.3",
|
|
75
|
-
"lint-staged": "10.5.4",
|
|
76
|
-
"npm-pkg-lint": "1.3.0",
|
|
77
|
-
"prettier": "2.2.1",
|
|
78
|
-
"pretty-format": "26.6.2",
|
|
79
|
-
"semantic-release": "17.4.2",
|
|
80
|
-
"ts-jest": "26.5.5",
|
|
81
|
-
"typescript": "4.2.4"
|
|
25
|
+
"kleur": "^4.0.0"
|
|
82
26
|
},
|
|
83
27
|
"engines": {
|
|
84
|
-
"node": ">=
|
|
28
|
+
"node": ">= 14.0"
|
|
85
29
|
},
|
|
86
30
|
"publishConfig": {
|
|
87
31
|
"access": "public"
|
|
88
|
-
},
|
|
89
|
-
"release": {
|
|
90
|
-
"extends": "@html-validate/semantic-release-config"
|
|
91
|
-
},
|
|
92
|
-
"renovate": {
|
|
93
|
-
"extends": [
|
|
94
|
-
"@html-validate"
|
|
95
|
-
]
|
|
96
32
|
}
|
|
97
33
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# @html-validate/stylish changelog
|
|
2
|
-
|
|
3
|
-
### [1.0.1](https://gitlab.com/html-validate/stylish/compare/v1.0.0...v1.0.1) (2021-04-27)
|
|
4
|
-
|
|
5
|
-
### Dependency upgrades
|
|
6
|
-
|
|
7
|
-
- **deps:** replace `chalk` with `kleur` ([6d80b65](https://gitlab.com/html-validate/stylish/commit/6d80b65226ca1fbc4ddf24e035e37f8aac3b4cea))
|
|
8
|
-
|
|
9
|
-
## 1.0.0 (2020-11-15)
|
|
10
|
-
|
|
11
|
-
### Features
|
|
12
|
-
|
|
13
|
-
- fork and migrate to typescript with testcases ([652f4be](https://gitlab.com/html-validate/stylish/commit/652f4be99c539a3653f659c40d821bf39e8aad9b))
|
|
14
|
-
|
|
15
|
-
### Bug Fixes
|
|
16
|
-
|
|
17
|
-
- default export ([a2fa549](https://gitlab.com/html-validate/stylish/commit/a2fa5493ee5efd772213140d43d7e2f795887e50))
|
package/dist/message.d.ts
DELETED
package/dist/message.js
DELETED
package/dist/result.d.ts
DELETED
package/dist/result.js
DELETED
package/dist/severity.d.ts
DELETED
package/dist/severity.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Severity = void 0;
|
|
4
|
-
var Severity;
|
|
5
|
-
(function (Severity) {
|
|
6
|
-
Severity[Severity["OFF"] = 0] = "OFF";
|
|
7
|
-
Severity[Severity["WARN"] = 1] = "WARN";
|
|
8
|
-
Severity[Severity["ERROR"] = 2] = "ERROR";
|
|
9
|
-
})(Severity = exports.Severity || (exports.Severity = {}));
|
package/dist/stylish.d.ts
DELETED
package/dist/stylish.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const kleur = __importStar(require("kleur/colors"));
|
|
26
|
-
const text_table_1 = __importDefault(require("text-table"));
|
|
27
|
-
const severity_1 = require("./severity");
|
|
28
|
-
/**
|
|
29
|
-
* Given a word and a count, append an s if count is not one.
|
|
30
|
-
* @param word - A word in its singular form.
|
|
31
|
-
* @param count - A number controlling whether word should be pluralized.
|
|
32
|
-
* @returns - The original word with an s on the end if count is not one.
|
|
33
|
-
*/
|
|
34
|
-
function pluralize(word, count) {
|
|
35
|
-
return count === 1 ? word : `${word}s`;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Given a line with " ${line} ${column} " where line is right-aligned and
|
|
39
|
-
* column is left-aligned it replaces the delimiter with a colon.
|
|
40
|
-
*/
|
|
41
|
-
function centerLineColumn(el) {
|
|
42
|
-
return el.replace(/(\d+)\s+(\d+)/u, (_m, p1, p2) => kleur.dim(`${p1}:${p2}`));
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Strip ANSI color escape sequences from text.
|
|
46
|
-
*/
|
|
47
|
-
function stripAnsi(text) {
|
|
48
|
-
/* eslint-disable-next-line no-control-regex */
|
|
49
|
-
return text.replace(/\u001B\[[0-9;]*m/g, "");
|
|
50
|
-
}
|
|
51
|
-
function stylish(results) {
|
|
52
|
-
let output = "\n";
|
|
53
|
-
let errorCount = 0;
|
|
54
|
-
let warningCount = 0;
|
|
55
|
-
let fixableErrorCount = 0;
|
|
56
|
-
let fixableWarningCount = 0;
|
|
57
|
-
let summaryColor = kleur.yellow;
|
|
58
|
-
results.forEach((result) => {
|
|
59
|
-
const messages = result.messages;
|
|
60
|
-
if (messages.length === 0) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
errorCount += result.errorCount;
|
|
64
|
-
warningCount += result.warningCount;
|
|
65
|
-
fixableErrorCount += result.fixableErrorCount;
|
|
66
|
-
fixableWarningCount += result.fixableWarningCount;
|
|
67
|
-
const rows = messages.map((message) => {
|
|
68
|
-
let messageType;
|
|
69
|
-
if (message.fatal || message.severity === severity_1.Severity.ERROR) {
|
|
70
|
-
messageType = kleur.red("error");
|
|
71
|
-
summaryColor = kleur.red;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
messageType = kleur.yellow("warning");
|
|
75
|
-
}
|
|
76
|
-
return [
|
|
77
|
-
"",
|
|
78
|
-
message.line || 0,
|
|
79
|
-
message.column || 0,
|
|
80
|
-
messageType,
|
|
81
|
-
message.message.replace(/([^ ])\.$/u, "$1"),
|
|
82
|
-
message.ruleId ? kleur.dim(message.ruleId) : "",
|
|
83
|
-
];
|
|
84
|
-
});
|
|
85
|
-
const options = {
|
|
86
|
-
align: ["l", "r", "l"],
|
|
87
|
-
stringLength(str) {
|
|
88
|
-
return stripAnsi(str).length;
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
const formattedTable = text_table_1.default(rows, options).split("\n").map(centerLineColumn).join("\n");
|
|
92
|
-
output += `${kleur.underline(result.filePath)}\n`;
|
|
93
|
-
output += `${formattedTable}\n\n`;
|
|
94
|
-
});
|
|
95
|
-
const total = errorCount + warningCount;
|
|
96
|
-
if (total > 0) {
|
|
97
|
-
output += summaryColor(kleur.bold([
|
|
98
|
-
"\u2716 ",
|
|
99
|
-
total,
|
|
100
|
-
pluralize(" problem", total),
|
|
101
|
-
" (",
|
|
102
|
-
errorCount,
|
|
103
|
-
pluralize(" error", errorCount),
|
|
104
|
-
", ",
|
|
105
|
-
warningCount,
|
|
106
|
-
pluralize(" warning", warningCount),
|
|
107
|
-
")\n",
|
|
108
|
-
].join("")));
|
|
109
|
-
if (fixableErrorCount > 0 || fixableWarningCount > 0) {
|
|
110
|
-
output += summaryColor(kleur.bold([
|
|
111
|
-
" ",
|
|
112
|
-
fixableErrorCount,
|
|
113
|
-
pluralize(" error", fixableErrorCount),
|
|
114
|
-
" and ",
|
|
115
|
-
fixableWarningCount,
|
|
116
|
-
pluralize(" warning", fixableWarningCount),
|
|
117
|
-
" potentially fixable with the `--fix` option.\n",
|
|
118
|
-
].join("")));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// Resets output color, for prevent change on top level
|
|
122
|
-
return total > 0 ? kleur.reset(output) : "";
|
|
123
|
-
}
|
|
124
|
-
exports.default = stylish;
|