@textlint/fixer-formatter 15.7.1 → 15.8.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/lib/src/formatters/diff.d.ts.map +1 -1
- package/lib/src/formatters/diff.js +11 -11
- package/lib/src/formatters/diff.js.map +1 -1
- package/lib/src/formatters/stylish.d.ts.map +1 -1
- package/lib/src/formatters/stylish.js +7 -7
- package/lib/src/formatters/stylish.js.map +1 -1
- package/package.json +10 -8
- package/src/formatters/diff.ts +14 -12
- package/src/formatters/stylish.ts +9 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/formatters/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAkDzD,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,iBAAiB,EAAE,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/formatters/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAkDzD,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,iBAAiB,EAAE,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,UAuGvF"}
|
|
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.default = default_1;
|
|
40
40
|
const fs = __importStar(require("node:fs"));
|
|
41
41
|
const diff_1 = require("diff");
|
|
42
|
-
const
|
|
42
|
+
const node_util_1 = require("node:util");
|
|
43
43
|
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
44
44
|
const isFile = (filePath) => {
|
|
45
45
|
try {
|
|
@@ -98,7 +98,7 @@ function default_1(results, options = {}) {
|
|
|
98
98
|
if (!isFile(filePath)) {
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
output += `${
|
|
101
|
+
output += `${(0, node_util_1.styleText)("underline", result.filePath)}\n`;
|
|
102
102
|
const originalContent = fs.readFileSync(filePath, "utf-8");
|
|
103
103
|
const diff = (0, diff_1.diffLines)(originalContent, result.output);
|
|
104
104
|
diff.forEach(function (part, index) {
|
|
@@ -106,7 +106,7 @@ function default_1(results, options = {}) {
|
|
|
106
106
|
const prevLine = diff[index - 1];
|
|
107
107
|
const nextLine = diff[index + 1];
|
|
108
108
|
if (!isModified(part) && ((_a = part.count) !== null && _a !== void 0 ? _a : 0) > 1) {
|
|
109
|
-
const greyColor = "
|
|
109
|
+
const greyColor = "gray";
|
|
110
110
|
/*
|
|
111
111
|
<MODIFIED>
|
|
112
112
|
first line
|
|
@@ -114,12 +114,12 @@ function default_1(results, options = {}) {
|
|
|
114
114
|
*/
|
|
115
115
|
if (isModified(prevLine)) {
|
|
116
116
|
const lines = part.value.split("\n");
|
|
117
|
-
output += `${
|
|
117
|
+
output += `${(0, node_util_1.styleText)(greyColor, lines[0])}\n`;
|
|
118
118
|
}
|
|
119
|
-
output +=
|
|
119
|
+
output += (0, node_util_1.styleText)(greyColor, "...");
|
|
120
120
|
if (isModified(nextLine)) {
|
|
121
121
|
const lines = part.value.split("\n");
|
|
122
|
-
output += `${
|
|
122
|
+
output += `${(0, node_util_1.styleText)(greyColor, lines[lines.length - 1])}\n`;
|
|
123
123
|
}
|
|
124
124
|
/*
|
|
125
125
|
...
|
|
@@ -129,7 +129,7 @@ function default_1(results, options = {}) {
|
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
// green for additions, red for deletions
|
|
132
|
-
//
|
|
132
|
+
// gray for common parts
|
|
133
133
|
let lineColor;
|
|
134
134
|
let diffMark = "";
|
|
135
135
|
if (part.added) {
|
|
@@ -141,15 +141,15 @@ function default_1(results, options = {}) {
|
|
|
141
141
|
diffMark = "- ";
|
|
142
142
|
}
|
|
143
143
|
else {
|
|
144
|
-
lineColor = "
|
|
144
|
+
lineColor = "gray";
|
|
145
145
|
diffMark = "";
|
|
146
146
|
}
|
|
147
|
-
output +=
|
|
147
|
+
output += (0, node_util_1.styleText)(lineColor, addMarkEachLine(diffMark, part.value));
|
|
148
148
|
});
|
|
149
149
|
output += "\n\n";
|
|
150
150
|
});
|
|
151
151
|
if (totalFixed > 0) {
|
|
152
|
-
output +=
|
|
152
|
+
output += (0, node_util_1.styleText)([greenColor, "bold"], [
|
|
153
153
|
// http://www.fileformat.info/info/unicode/char/2714/index.htm
|
|
154
154
|
"✔ Fixed ",
|
|
155
155
|
totalFixed,
|
|
@@ -158,7 +158,7 @@ function default_1(results, options = {}) {
|
|
|
158
158
|
].join(""));
|
|
159
159
|
}
|
|
160
160
|
if (errors > 0) {
|
|
161
|
-
output +=
|
|
161
|
+
output += (0, node_util_1.styleText)([summaryColor, "bold"], [
|
|
162
162
|
// http://www.fileformat.info/info/unicode/char/2716/index.htm
|
|
163
163
|
"✖ Remaining ",
|
|
164
164
|
errors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/formatters/diff.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDb,
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/formatters/diff.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDb,4BAuGC;AAxJD,4CAA8B;AAC9B,+BAAiC;AACjC,yCAAsC;AACtC,4DAAmC;AAQnC,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAE,EAAE;IAChC,IAAI,CAAC;QACD,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;IAC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AAG,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,IAAA,qBAAS,EACf,CAAC,UAAU,EAAE,MAAM,CAAC,EACpB;YACI,8DAA8D;YAC9D,UAAU;YACV,UAAU;YACV,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;YACjC,IAAI;SACP,CAAC,IAAI,CAAC,EAAE,CAAC,CACb,CAAC;IACN,CAAC;IAED,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,IAAA,qBAAS,EACf,CAAC,YAAY,EAAE,MAAM,CAAC,EACtB;YACI,8DAA8D;YAC9D,cAAc;YACd,MAAM;YACN,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;YAC7B,IAAI;SACP,CAAC,IAAI,CAAC,EAAE,CAAC,CACb,CAAC;IACN,CAAC;IAED,MAAM,WAAW,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,IAAA,oBAAS,EAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,WAAW,CAAC;AACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylish.d.ts","sourceRoot":"","sources":["../../../src/formatters/stylish.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAkBzD,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"stylish.d.ts","sourceRoot":"","sources":["../../../src/formatters/stylish.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAkBzD,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,iBAAiB,EAAE,EAAE,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,UA6GlF"}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
|
-
const
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
8
8
|
// @ts-expect-error no types
|
|
9
9
|
const text_table_1 = __importDefault(require("text-table"));
|
|
10
10
|
const string_width_1 = __importDefault(require("string-width"));
|
|
@@ -51,18 +51,18 @@ function default_1(results, options) {
|
|
|
51
51
|
if (messages.length === 0) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
output += `${
|
|
54
|
+
output += `${(0, node_util_1.styleText)("underline", result.filePath)}\n`;
|
|
55
55
|
output += `${(0, text_table_1.default)(messages.map(function (message) {
|
|
56
56
|
// fixable
|
|
57
57
|
totalFixed++;
|
|
58
|
-
const messageType =
|
|
58
|
+
const messageType = (0, node_util_1.styleText)([greenColor, "bold"], "\u2714 ");
|
|
59
59
|
return [
|
|
60
60
|
"",
|
|
61
61
|
message.line || 0,
|
|
62
62
|
message.column || 0,
|
|
63
63
|
messageType,
|
|
64
64
|
message.message.replace(/\.$/, ""),
|
|
65
|
-
|
|
65
|
+
(0, node_util_1.styleText)("gray", message.ruleId || "")
|
|
66
66
|
];
|
|
67
67
|
}), {
|
|
68
68
|
align: ["", "r", "l"],
|
|
@@ -76,13 +76,13 @@ function default_1(results, options) {
|
|
|
76
76
|
.split("\n")
|
|
77
77
|
.map(function (el) {
|
|
78
78
|
return el.replace(/(\d+)\s+(\d+)/, function (_m, p1, p2) {
|
|
79
|
-
return
|
|
79
|
+
return (0, node_util_1.styleText)("gray", `${p1}:${p2}`);
|
|
80
80
|
});
|
|
81
81
|
})
|
|
82
82
|
.join("\n")}\n\n`;
|
|
83
83
|
});
|
|
84
84
|
if (totalFixed > 0) {
|
|
85
|
-
output +=
|
|
85
|
+
output += (0, node_util_1.styleText)([greenColor, "bold"], [
|
|
86
86
|
// http://www.fileformat.info/info/unicode/char/2714/index.htm
|
|
87
87
|
"\u2714 Fixed ",
|
|
88
88
|
totalFixed,
|
|
@@ -97,7 +97,7 @@ function default_1(results, options) {
|
|
|
97
97
|
`${warnings} ${pluralize("warning", warnings)}`,
|
|
98
98
|
`${infos} ${pluralize("info", infos)}`
|
|
99
99
|
];
|
|
100
|
-
output +=
|
|
100
|
+
output += (0, node_util_1.styleText)([summaryColor, "bold"], [
|
|
101
101
|
// http://www.fileformat.info/info/unicode/char/2716/index.htm
|
|
102
102
|
"\u2716 Remaining ",
|
|
103
103
|
summaryParts.join(", "),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylish.js","sourceRoot":"","sources":["../../../src/formatters/stylish.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAmBb,
|
|
1
|
+
{"version":3,"file":"stylish.js","sourceRoot":"","sources":["../../../src/formatters/stylish.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;AAmBb,4BA6GC;AA7HD,yCAAsC;AACtC,4BAA4B;AAC5B,4DAA+B;AAC/B,gEAAyC;AACzC,4DAAmC;AAEnC;;;;;GAKG;AACH,SAAS,SAAS,CAAC,IAAY,EAAE,KAAa;IAC1C,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;AAC3C,CAAC;AAED,mBAAyB,OAA4B,EAAE,OAA4B;IAC/E,gBAAgB;IAChB,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,QAAQ,GAAG,C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AC;IACN,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACjD,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,YAAY,GAAG;YACjB,GAAG,MAAM,IAAI,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;YACzC,GAAG,QAAQ,IAAI,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YAC/C,GAAG,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;SACzC,CAAC;QACF,MAAM,IAAI,IAAA,qBAAS,EACf,CAAC,YAAY,EAAE,MAAM,CAAC,EACtB;YACI,8DAA8D;YAC9D,mBAAmB;YACnB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,IAAI;SACP,CAAC,IAAI,CAAC,EAAE,CAAC,CACb,CAAC;IACN,CAAC;IAED,MAAM,WAAW,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,IAAA,oBAAS,EAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,WAAW,CAAC;AACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textlint/fixer-formatter",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.8.0",
|
|
4
4
|
"description": "textlint output formatter for fixer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"AST",
|
|
@@ -39,10 +39,9 @@
|
|
|
39
39
|
"test:watch": "vitest watch"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@textlint/module-interop": "15.
|
|
43
|
-
"@textlint/resolver": "15.
|
|
44
|
-
"@textlint/types": "15.
|
|
45
|
-
"chalk": "^4.1.2",
|
|
42
|
+
"@textlint/module-interop": "15.8.0",
|
|
43
|
+
"@textlint/resolver": "15.8.0",
|
|
44
|
+
"@textlint/types": "15.8.0",
|
|
46
45
|
"debug": "^4.4.3",
|
|
47
46
|
"diff": "^8.0.4",
|
|
48
47
|
"string-width": "^4.2.3",
|
|
@@ -51,13 +50,16 @@
|
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
52
|
"@types/debug": "^4.1.13",
|
|
54
|
-
"@types/node": "^24.
|
|
53
|
+
"@types/node": "^24.13.3",
|
|
55
54
|
"rimraf": "^6.1.3",
|
|
56
55
|
"typescript": "~5.8.3",
|
|
57
|
-
"vitest": "^3.2.
|
|
56
|
+
"vitest": "^3.2.7"
|
|
58
57
|
},
|
|
59
58
|
"publishConfig": {
|
|
60
59
|
"access": "public"
|
|
61
60
|
},
|
|
62
|
-
"
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=20.18.0"
|
|
63
|
+
},
|
|
64
|
+
"gitHead": "4ba5bfedb27e86ffc12558743e5840eb57d13302"
|
|
63
65
|
}
|
package/src/formatters/diff.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { TextlintFixResult } from "@textlint/types";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { diffLines } from "diff";
|
|
5
|
-
import
|
|
5
|
+
import { styleText } from "node:util";
|
|
6
6
|
import stripAnsi from "strip-ansi";
|
|
7
7
|
|
|
8
8
|
type DiffPart = {
|
|
@@ -71,7 +71,7 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
71
71
|
if (!isFile(filePath)) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
output += `${
|
|
74
|
+
output += `${styleText("underline", result.filePath)}\n`;
|
|
75
75
|
|
|
76
76
|
const originalContent = fs.readFileSync(filePath, "utf-8");
|
|
77
77
|
const diff = diffLines(originalContent, result.output);
|
|
@@ -80,7 +80,7 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
80
80
|
const prevLine = diff[index - 1] as DiffPart;
|
|
81
81
|
const nextLine = diff[index + 1] as DiffPart;
|
|
82
82
|
if (!isModified(part) && (part.count ?? 0) > 1) {
|
|
83
|
-
const greyColor = "
|
|
83
|
+
const greyColor = "gray";
|
|
84
84
|
/*
|
|
85
85
|
<MODIFIED>
|
|
86
86
|
first line
|
|
@@ -88,12 +88,12 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
88
88
|
*/
|
|
89
89
|
if (isModified(prevLine)) {
|
|
90
90
|
const lines = part.value.split("\n");
|
|
91
|
-
output += `${
|
|
91
|
+
output += `${styleText(greyColor, lines[0])}\n`;
|
|
92
92
|
}
|
|
93
|
-
output +=
|
|
93
|
+
output += styleText(greyColor, "...");
|
|
94
94
|
if (isModified(nextLine)) {
|
|
95
95
|
const lines = part.value.split("\n");
|
|
96
|
-
output += `${
|
|
96
|
+
output += `${styleText(greyColor, lines[lines.length - 1])}\n`;
|
|
97
97
|
}
|
|
98
98
|
/*
|
|
99
99
|
...
|
|
@@ -103,8 +103,8 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
105
|
// green for additions, red for deletions
|
|
106
|
-
//
|
|
107
|
-
let lineColor: "green" | "red" | "
|
|
106
|
+
// gray for common parts
|
|
107
|
+
let lineColor: "green" | "red" | "gray";
|
|
108
108
|
let diffMark = "";
|
|
109
109
|
if (part.added) {
|
|
110
110
|
lineColor = "green";
|
|
@@ -113,16 +113,17 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
113
113
|
lineColor = "red";
|
|
114
114
|
diffMark = "- ";
|
|
115
115
|
} else {
|
|
116
|
-
lineColor = "
|
|
116
|
+
lineColor = "gray";
|
|
117
117
|
diffMark = "";
|
|
118
118
|
}
|
|
119
|
-
output +=
|
|
119
|
+
output += styleText(lineColor, addMarkEachLine(diffMark, part.value));
|
|
120
120
|
});
|
|
121
121
|
output += "\n\n";
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
if (totalFixed > 0) {
|
|
125
|
-
output +=
|
|
125
|
+
output += styleText(
|
|
126
|
+
[greenColor, "bold"],
|
|
126
127
|
[
|
|
127
128
|
// http://www.fileformat.info/info/unicode/char/2714/index.htm
|
|
128
129
|
"✔ Fixed ",
|
|
@@ -134,7 +135,8 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
if (errors > 0) {
|
|
137
|
-
output +=
|
|
138
|
+
output += styleText(
|
|
139
|
+
[summaryColor, "bold"],
|
|
138
140
|
[
|
|
139
141
|
// http://www.fileformat.info/info/unicode/char/2716/index.htm
|
|
140
142
|
"✖ Remaining ",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import type { TextlintFixResult } from "@textlint/types";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { styleText } from "node:util";
|
|
5
5
|
// @ts-expect-error no types
|
|
6
6
|
import table from "text-table";
|
|
7
7
|
import widthOfString from "string-width";
|
|
@@ -51,13 +51,13 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
51
51
|
if (messages.length === 0) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
output += `${
|
|
54
|
+
output += `${styleText("underline", result.filePath)}\n`;
|
|
55
55
|
|
|
56
56
|
output += `${table(
|
|
57
57
|
messages.map(function (message) {
|
|
58
58
|
// fixable
|
|
59
59
|
totalFixed++;
|
|
60
|
-
const messageType =
|
|
60
|
+
const messageType = styleText([greenColor, "bold"], "\u2714 ");
|
|
61
61
|
|
|
62
62
|
return [
|
|
63
63
|
"",
|
|
@@ -65,7 +65,7 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
65
65
|
message.column || 0,
|
|
66
66
|
messageType,
|
|
67
67
|
message.message.replace(/\.$/, ""),
|
|
68
|
-
|
|
68
|
+
styleText("gray", message.ruleId || "")
|
|
69
69
|
];
|
|
70
70
|
}),
|
|
71
71
|
{
|
|
@@ -84,14 +84,15 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
84
84
|
.split("\n")
|
|
85
85
|
.map(function (el: string) {
|
|
86
86
|
return el.replace(/(\d+)\s+(\d+)/, function (_m, p1, p2) {
|
|
87
|
-
return
|
|
87
|
+
return styleText("gray", `${p1}:${p2}`);
|
|
88
88
|
});
|
|
89
89
|
})
|
|
90
90
|
.join("\n")}\n\n`;
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
if (totalFixed > 0) {
|
|
94
|
-
output +=
|
|
94
|
+
output += styleText(
|
|
95
|
+
[greenColor, "bold"],
|
|
95
96
|
[
|
|
96
97
|
// http://www.fileformat.info/info/unicode/char/2714/index.htm
|
|
97
98
|
"\u2714 Fixed ",
|
|
@@ -109,7 +110,8 @@ export default function (results: TextlintFixResult[], options: { color?: boolea
|
|
|
109
110
|
`${warnings} ${pluralize("warning", warnings)}`,
|
|
110
111
|
`${infos} ${pluralize("info", infos)}`
|
|
111
112
|
];
|
|
112
|
-
output +=
|
|
113
|
+
output += styleText(
|
|
114
|
+
[summaryColor, "bold"],
|
|
113
115
|
[
|
|
114
116
|
// http://www.fileformat.info/info/unicode/char/2716/index.htm
|
|
115
117
|
"\u2716 Remaining ",
|