@aklinker1/check 2.1.0 → 2.1.2
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/bin/check.mjs +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +37 -0
- package/dist/index.d.ts +63 -5
- package/dist/index.js +3 -0
- package/dist/src-CKPF6CV1.js +451 -0
- package/package.json +23 -38
- package/dist/cli.mjs +0 -34
- package/dist/index.mjs +0 -135
- package/dist/tasklist/index.d.ts +0 -8
- package/dist/tasklist/index.mjs +0 -78
- package/dist/tools/eslint.d.ts +0 -3
- package/dist/tools/eslint.mjs +0 -41
- package/dist/tools/eslint.test.d.ts +0 -1
- package/dist/tools/eslint.test.mjs +0 -35
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.mjs +0 -14
- package/dist/tools/markdownlint.d.ts +0 -3
- package/dist/tools/markdownlint.mjs +0 -34
- package/dist/tools/markdownlint.test.d.ts +0 -1
- package/dist/tools/markdownlint.test.mjs +0 -72
- package/dist/tools/oxlint.d.ts +0 -3
- package/dist/tools/oxlint.mjs +0 -49
- package/dist/tools/oxlint.test.d.ts +0 -1
- package/dist/tools/oxlint.test.mjs +0 -57
- package/dist/tools/prettier.d.ts +0 -3
- package/dist/tools/prettier.mjs +0 -40
- package/dist/tools/prettier.test.d.ts +0 -1
- package/dist/tools/prettier.test.mjs +0 -78
- package/dist/tools/publint.d.ts +0 -3
- package/dist/tools/publint.mjs +0 -28
- package/dist/tools/publint.test.d.ts +0 -1
- package/dist/tools/publint.test.mjs +0 -33
- package/dist/tools/typescript.d.ts +0 -3
- package/dist/tools/typescript.mjs +0 -47
- package/dist/tools/typescript.test.d.ts +0 -1
- package/dist/tools/typescript.test.mjs +0 -51
- package/dist/types.d.ts +0 -55
- package/dist/types.mjs +0 -0
- package/dist/utils.d.ts +0 -11
- package/dist/utils.mjs +0 -50
package/dist/index.mjs
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { ALL_TOOLS } from "./tools/index.mjs";
|
|
2
|
-
import { p } from "@antfu/utils";
|
|
3
|
-
import {
|
|
4
|
-
bold,
|
|
5
|
-
cyan,
|
|
6
|
-
debug as debugLog,
|
|
7
|
-
dim,
|
|
8
|
-
humanMs,
|
|
9
|
-
isDebug,
|
|
10
|
-
red,
|
|
11
|
-
yellow
|
|
12
|
-
} from "./utils.mjs";
|
|
13
|
-
import { createTaskList } from "./tasklist/index.mjs";
|
|
14
|
-
import { relative, resolve, sep, join } from "node:path";
|
|
15
|
-
import { isCI } from "ci-info";
|
|
16
|
-
import { readFile } from "node:fs/promises";
|
|
17
|
-
export async function check(options = {}) {
|
|
18
|
-
const { debug, fix = !isCI, root = process.cwd() } = options;
|
|
19
|
-
const packageJson = JSON.parse(
|
|
20
|
-
await readFile(join(root, "package.json"), "utf8")
|
|
21
|
-
);
|
|
22
|
-
if (debug) {
|
|
23
|
-
process.env.DEBUG = "true";
|
|
24
|
-
}
|
|
25
|
-
console.log();
|
|
26
|
-
debugLog("Options:" + JSON.stringify(options));
|
|
27
|
-
debugLog(
|
|
28
|
-
"Resolved options:" + JSON.stringify({ debug, fix, root, packageJson })
|
|
29
|
-
);
|
|
30
|
-
const tools = await findInstalledTools({ root, packageJson });
|
|
31
|
-
if (tools.length === 0) {
|
|
32
|
-
if (isDebug()) {
|
|
33
|
-
console.log("No tools detected!");
|
|
34
|
-
} else {
|
|
35
|
-
console.log("No tools detected! Run with --debug for more info");
|
|
36
|
-
}
|
|
37
|
-
console.log();
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
const results = await createTaskList(
|
|
41
|
-
tools,
|
|
42
|
-
async ({ input: tool, fail, succeed, warn }) => {
|
|
43
|
-
const startTime = performance.now();
|
|
44
|
-
const fn = fix ? tool.fix ?? tool.check : tool.check;
|
|
45
|
-
const problems2 = await fn();
|
|
46
|
-
problems2.forEach((problem) => {
|
|
47
|
-
problem.file = resolve(root ?? process.cwd(), problem.file);
|
|
48
|
-
});
|
|
49
|
-
const duration = humanMs(performance.now() - startTime);
|
|
50
|
-
const title = `${tool.name} ${dim(`(${duration})`)}`;
|
|
51
|
-
const errorCount = problems2.filter((p2) => p2.kind === "error").length;
|
|
52
|
-
if (errorCount > 0)
|
|
53
|
-
fail(title);
|
|
54
|
-
else if (problems2.length > 0)
|
|
55
|
-
warn(title);
|
|
56
|
-
else
|
|
57
|
-
succeed(title);
|
|
58
|
-
return problems2;
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
const problems = results.flat();
|
|
62
|
-
console.log();
|
|
63
|
-
if (problems.length === 0) {
|
|
64
|
-
process.exit(0);
|
|
65
|
-
}
|
|
66
|
-
console.log(plural(problems.length, "Problem:", "Problems:"));
|
|
67
|
-
problems.sort((l, r) => {
|
|
68
|
-
const nameCompare = l.file.localeCompare(r.file);
|
|
69
|
-
if (nameCompare !== 0)
|
|
70
|
-
return nameCompare;
|
|
71
|
-
const lineCompare = (l.location?.line ?? 0) - (r.location?.line ?? 0);
|
|
72
|
-
if (lineCompare !== 0)
|
|
73
|
-
return lineCompare;
|
|
74
|
-
return (l.location?.column ?? 0) - (r.location?.column ?? 0);
|
|
75
|
-
});
|
|
76
|
-
const groupedProblems = problems.reduce((acc, problem) => {
|
|
77
|
-
const locationHash = `${problem.file}:${problem.location?.line}:${problem.location?.column}`;
|
|
78
|
-
const list = acc.get(locationHash) ?? [];
|
|
79
|
-
list.push(problem);
|
|
80
|
-
acc.set(locationHash, list);
|
|
81
|
-
return acc;
|
|
82
|
-
}, /* @__PURE__ */ new Map());
|
|
83
|
-
console.log([...groupedProblems.values()].map(renderProblemGroup).join("\n"));
|
|
84
|
-
const files = Object.entries(
|
|
85
|
-
problems.reduce((acc, problem) => {
|
|
86
|
-
const file = "." + sep + relative(process.cwd(), problem.file);
|
|
87
|
-
acc[file] ??= 0;
|
|
88
|
-
acc[file]++;
|
|
89
|
-
return acc;
|
|
90
|
-
}, {})
|
|
91
|
-
);
|
|
92
|
-
const maxLength = files.reduce(
|
|
93
|
-
(prev, [file]) => Math.max(prev, file.length),
|
|
94
|
-
0
|
|
95
|
-
);
|
|
96
|
-
console.log();
|
|
97
|
-
console.log("Across " + plural(files.length, "File:", "Files:"));
|
|
98
|
-
files.forEach(([file, count]) => {
|
|
99
|
-
console.log(`${cyan(file.padEnd(maxLength, " "))} ${count}`);
|
|
100
|
-
});
|
|
101
|
-
console.log();
|
|
102
|
-
process.exit(problems.length);
|
|
103
|
-
}
|
|
104
|
-
async function findInstalledTools(opts) {
|
|
105
|
-
const status = await p(ALL_TOOLS).map(async (def) => {
|
|
106
|
-
const tool = await def(opts);
|
|
107
|
-
const isInstalled = !!opts.packageJson.devDependencies?.[tool.packageName];
|
|
108
|
-
return { tool, isInstalled };
|
|
109
|
-
}).promise;
|
|
110
|
-
if (isDebug()) {
|
|
111
|
-
const getTools = (isInstalled) => status.filter((item) => item.isInstalled === isInstalled).map((item) => item.tool.name).join(", ");
|
|
112
|
-
const installed = getTools(true);
|
|
113
|
-
debugLog(`Installed: ${installed || "(none)"}`);
|
|
114
|
-
const skipped = getTools(false);
|
|
115
|
-
debugLog(`Skipping: ${skipped || "(none)"} `);
|
|
116
|
-
}
|
|
117
|
-
return status.filter(({ isInstalled }) => isInstalled).map((item) => item.tool);
|
|
118
|
-
}
|
|
119
|
-
function plural(count, singular, plural2) {
|
|
120
|
-
return `${count} ${count === 1 ? singular : plural2} `;
|
|
121
|
-
}
|
|
122
|
-
export function renderProblemGroup(problems) {
|
|
123
|
-
const renderedProblems = problems.map(renderProblem);
|
|
124
|
-
const problem = problems[0];
|
|
125
|
-
const path = relative(process.cwd(), problem.file);
|
|
126
|
-
const location = problem.location ? `${path}:${problem.location.line}:${problem.location.column}` : path;
|
|
127
|
-
const link = dim(`\u2192 .${sep}${location}`);
|
|
128
|
-
return `${renderedProblems.join("\n")}
|
|
129
|
-
${link}`;
|
|
130
|
-
}
|
|
131
|
-
export function renderProblem(problem) {
|
|
132
|
-
const icon = problem.kind === "warning" ? bold(yellow("\u26A0")) : bold(red("\u2717"));
|
|
133
|
-
const source = problem.rule ? dim(` (${problem.rule})`) : "";
|
|
134
|
-
return `${icon} ${problem.message}${source}`;
|
|
135
|
-
}
|
package/dist/tasklist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function createTaskList<TInput extends {
|
|
2
|
-
name: string;
|
|
3
|
-
}, TResult = void>(inputs: TInput[], run: (ctx: {
|
|
4
|
-
input: TInput;
|
|
5
|
-
succeed: (title?: string) => void;
|
|
6
|
-
warn: (title?: string) => void;
|
|
7
|
-
fail: (title?: string) => void;
|
|
8
|
-
}) => Promise<TResult>): Promise<TResult[]>;
|
package/dist/tasklist/index.mjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { cyan, dim, green, red, yellow } from "../utils.mjs";
|
|
2
|
-
import readline from "node:readline";
|
|
3
|
-
export async function createTaskList(inputs, run) {
|
|
4
|
-
const states = inputs.map((item) => ({
|
|
5
|
-
title: item.name,
|
|
6
|
-
state: "pending"
|
|
7
|
-
}));
|
|
8
|
-
const isTty = process.stderr.isTTY;
|
|
9
|
-
let tick = 0;
|
|
10
|
-
const render = (opts) => {
|
|
11
|
-
if (isTty && !opts?.firstRender) {
|
|
12
|
-
readline.moveCursor(process.stderr, 0, -1 * states.length);
|
|
13
|
-
}
|
|
14
|
-
if (isTty || opts?.firstRender || opts?.lastRender) {
|
|
15
|
-
states.forEach(({ state, title }) => {
|
|
16
|
-
readline.clearLine(process.stderr, 0);
|
|
17
|
-
const frames = SPINNER_FRAMES[state];
|
|
18
|
-
process.stderr.write(`${frames[tick % frames.length]} ${title}
|
|
19
|
-
`);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
tick++;
|
|
23
|
-
};
|
|
24
|
-
render({ firstRender: true });
|
|
25
|
-
const renderInterval = setInterval(render, SPINNER_INTERVAL_MS);
|
|
26
|
-
try {
|
|
27
|
-
const result = await Promise.all(
|
|
28
|
-
inputs.map(async (input, i) => {
|
|
29
|
-
const succeed = (title) => {
|
|
30
|
-
if (title != null)
|
|
31
|
-
states[i].title = title;
|
|
32
|
-
states[i].state = "success";
|
|
33
|
-
render();
|
|
34
|
-
};
|
|
35
|
-
const warn = (title) => {
|
|
36
|
-
if (title != null)
|
|
37
|
-
states[i].title = title;
|
|
38
|
-
states[i].state = "warning";
|
|
39
|
-
render();
|
|
40
|
-
};
|
|
41
|
-
const fail = (title) => {
|
|
42
|
-
if (title != null)
|
|
43
|
-
states[i].title = title;
|
|
44
|
-
states[i].state = "error";
|
|
45
|
-
render();
|
|
46
|
-
};
|
|
47
|
-
try {
|
|
48
|
-
states[i].state = "in-progress";
|
|
49
|
-
render();
|
|
50
|
-
const res = await run({ input, succeed, warn, fail });
|
|
51
|
-
if (states[i].state === "in-progress")
|
|
52
|
-
states[i].state = "success";
|
|
53
|
-
render();
|
|
54
|
-
return res;
|
|
55
|
-
} catch (err) {
|
|
56
|
-
if (err instanceof Error)
|
|
57
|
-
fail(err.message);
|
|
58
|
-
else
|
|
59
|
-
fail(String(err));
|
|
60
|
-
render();
|
|
61
|
-
throw err;
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
render({ lastRender: true });
|
|
66
|
-
return result;
|
|
67
|
-
} finally {
|
|
68
|
-
clearInterval(renderInterval);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const SPINNER_INTERVAL_MS = 80;
|
|
72
|
-
const SPINNER_FRAMES = {
|
|
73
|
-
pending: [dim("\u25A1")],
|
|
74
|
-
"in-progress": ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"].map(cyan),
|
|
75
|
-
success: [green("\u2714")],
|
|
76
|
-
warning: [yellow("\u26A0")],
|
|
77
|
-
error: [red("\u2717")]
|
|
78
|
-
};
|
package/dist/tools/eslint.d.ts
DELETED
package/dist/tools/eslint.mjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { execAndParse } from "../utils.mjs";
|
|
2
|
-
export const eslint = ({ root }) => {
|
|
3
|
-
const bin = "eslint";
|
|
4
|
-
const checkArgs = [
|
|
5
|
-
".",
|
|
6
|
-
"--ext",
|
|
7
|
-
".js,.ts,.jsx,.tsx,.mjs,.mts,.cjs,.cts,.vue",
|
|
8
|
-
"--format",
|
|
9
|
-
"compact",
|
|
10
|
-
"--max-warnings",
|
|
11
|
-
"0"
|
|
12
|
-
];
|
|
13
|
-
const fixArgs = [...checkArgs, "--fix"];
|
|
14
|
-
return {
|
|
15
|
-
name: "ESLint",
|
|
16
|
-
packageName: "eslint",
|
|
17
|
-
check: () => execAndParse(bin, checkArgs, root, parseOutput),
|
|
18
|
-
fix: () => execAndParse(bin, fixArgs, root, parseOutput)
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export const parseOutput = ({ stdout, stderr }) => {
|
|
22
|
-
return `${stdout}
|
|
23
|
-
${stderr}`.split(/\r?\n/).reduce((acc, line) => {
|
|
24
|
-
const groups = /^(?<file>.*?): line (?<line>[0-9]+), col (?<column>[0-9]+), (?<kind>\S+) - (?<message>.*?) \((?<rule>\S*?)\)$/.exec(
|
|
25
|
-
line
|
|
26
|
-
)?.groups;
|
|
27
|
-
if (groups) {
|
|
28
|
-
acc.push({
|
|
29
|
-
file: groups.file,
|
|
30
|
-
kind: groups.kind === "Warning" ? "warning" : "error",
|
|
31
|
-
message: groups.message,
|
|
32
|
-
location: {
|
|
33
|
-
line: parseInt(groups.line, 10),
|
|
34
|
-
column: parseInt(groups.column, 10)
|
|
35
|
-
},
|
|
36
|
-
rule: groups.rule
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return acc;
|
|
40
|
-
}, []);
|
|
41
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "bun:test";
|
|
2
|
-
import { parseOutput } from "./eslint.mjs";
|
|
3
|
-
describe("ESLint", () => {
|
|
4
|
-
it("should properly parse output", async () => {
|
|
5
|
-
const stdout = `/path/to/check/demo/test.ts: line 1, col 7, Warning - 'test' is assigned a value but never used. (@typescript-eslint/no-unused-vars)
|
|
6
|
-
/path/to/check/demo/test.ts: line 5, col 7, Error - 'variable' is assigned a value but never used. (@typescript-eslint/no-unused-vars)
|
|
7
|
-
|
|
8
|
-
4 problems
|
|
9
|
-
`;
|
|
10
|
-
const stderr = "";
|
|
11
|
-
const code = 1;
|
|
12
|
-
expect(parseOutput({ code, stdout, stderr })).toEqual([
|
|
13
|
-
{
|
|
14
|
-
file: "/path/to/check/demo/test.ts",
|
|
15
|
-
message: "'test' is assigned a value but never used.",
|
|
16
|
-
kind: "warning",
|
|
17
|
-
location: {
|
|
18
|
-
line: 1,
|
|
19
|
-
column: 7
|
|
20
|
-
},
|
|
21
|
-
rule: "@typescript-eslint/no-unused-vars"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
file: "/path/to/check/demo/test.ts",
|
|
25
|
-
message: "'variable' is assigned a value but never used.",
|
|
26
|
-
kind: "error",
|
|
27
|
-
location: {
|
|
28
|
-
line: 5,
|
|
29
|
-
column: 7
|
|
30
|
-
},
|
|
31
|
-
rule: "@typescript-eslint/no-unused-vars"
|
|
32
|
-
}
|
|
33
|
-
]);
|
|
34
|
-
});
|
|
35
|
-
});
|
package/dist/tools/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const ALL_TOOLS: import("..").ToolDefinition[];
|
package/dist/tools/index.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { eslint } from "./eslint.mjs";
|
|
2
|
-
import { markdownlint } from "./markdownlint.mjs";
|
|
3
|
-
import { oxlint } from "./oxlint.mjs";
|
|
4
|
-
import { prettier } from "./prettier.mjs";
|
|
5
|
-
import { publint } from "./publint.mjs";
|
|
6
|
-
import { typescript } from "./typescript.mjs";
|
|
7
|
-
export const ALL_TOOLS = [
|
|
8
|
-
eslint,
|
|
9
|
-
markdownlint,
|
|
10
|
-
oxlint,
|
|
11
|
-
prettier,
|
|
12
|
-
publint,
|
|
13
|
-
typescript
|
|
14
|
-
];
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { execAndParse } from "../utils.mjs";
|
|
2
|
-
export const markdownlint = ({ root }) => {
|
|
3
|
-
const bin = "markdownlint";
|
|
4
|
-
const checkArgs = [
|
|
5
|
-
".",
|
|
6
|
-
"--json",
|
|
7
|
-
"--ignore='**/dist/**'",
|
|
8
|
-
"--ignore='**/node_modules/**'",
|
|
9
|
-
"--ignore='**/.output/**'",
|
|
10
|
-
"--ignore='**/coverage/**'"
|
|
11
|
-
];
|
|
12
|
-
const fixArgs = [...checkArgs, "--fix"];
|
|
13
|
-
return {
|
|
14
|
-
name: "Markdownlint",
|
|
15
|
-
packageName: "markdownlint-cli",
|
|
16
|
-
check: () => execAndParse(bin, checkArgs, root, parseOutput),
|
|
17
|
-
fix: () => execAndParse(bin, fixArgs, root, parseOutput)
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export const parseOutput = ({ stderr: _stderr }) => {
|
|
21
|
-
const stderr = _stderr.trim();
|
|
22
|
-
if (!stderr)
|
|
23
|
-
return [];
|
|
24
|
-
return JSON.parse(stderr).map((warning) => ({
|
|
25
|
-
location: {
|
|
26
|
-
line: warning.lineNumber,
|
|
27
|
-
column: warning.errorRange?.[0] ?? 0
|
|
28
|
-
},
|
|
29
|
-
message: warning.ruleDescription,
|
|
30
|
-
file: warning.fileName,
|
|
31
|
-
kind: "warning",
|
|
32
|
-
rule: warning.ruleNames[0]
|
|
33
|
-
}));
|
|
34
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "bun:test";
|
|
2
|
-
import { parseOutput } from "./markdownlint.mjs";
|
|
3
|
-
describe("Markdownlint", () => {
|
|
4
|
-
it("should properly parse output", async () => {
|
|
5
|
-
const stdout = "";
|
|
6
|
-
const stderr = `
|
|
7
|
-
[
|
|
8
|
-
{
|
|
9
|
-
"fileName": "docs/guide/resources/upgrading.md",
|
|
10
|
-
"lineNumber": 59,
|
|
11
|
-
"ruleNames": [
|
|
12
|
-
"MD031",
|
|
13
|
-
"blanks-around-fences"
|
|
14
|
-
],
|
|
15
|
-
"ruleDescription": "Fenced code blocks should be surrounded by blank lines",
|
|
16
|
-
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md",
|
|
17
|
-
"errorDetail": null,
|
|
18
|
-
"errorContext": "\`\`\`ts",
|
|
19
|
-
"errorRange": null,
|
|
20
|
-
"fixInfo": {
|
|
21
|
-
"lineNumber": 59,
|
|
22
|
-
"insertText": "\\n"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"fileName": "CODE_OF_CONDUCT.md",
|
|
27
|
-
"lineNumber": 63,
|
|
28
|
-
"ruleNames": [
|
|
29
|
-
"MD034",
|
|
30
|
-
"no-bare-urls"
|
|
31
|
-
],
|
|
32
|
-
"ruleDescription": "Bare URL used",
|
|
33
|
-
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md034.md",
|
|
34
|
-
"errorDetail": null,
|
|
35
|
-
"errorContext": "example@gmail.com",
|
|
36
|
-
"errorRange": [
|
|
37
|
-
5,
|
|
38
|
-
23
|
|
39
|
-
],
|
|
40
|
-
"fixInfo": {
|
|
41
|
-
"editColumn": 1,
|
|
42
|
-
"deleteCount": 23,
|
|
43
|
-
"insertText": "<example@gmail.com>"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
`;
|
|
48
|
-
const code = 1;
|
|
49
|
-
expect(parseOutput({ code, stdout, stderr })).toEqual([
|
|
50
|
-
{
|
|
51
|
-
file: "docs/guide/resources/upgrading.md",
|
|
52
|
-
message: "Fenced code blocks should be surrounded by blank lines",
|
|
53
|
-
location: {
|
|
54
|
-
line: 59,
|
|
55
|
-
column: 0
|
|
56
|
-
},
|
|
57
|
-
rule: "MD031",
|
|
58
|
-
kind: "warning"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
file: "CODE_OF_CONDUCT.md",
|
|
62
|
-
message: "Bare URL used",
|
|
63
|
-
location: {
|
|
64
|
-
line: 63,
|
|
65
|
-
column: 5
|
|
66
|
-
},
|
|
67
|
-
rule: "MD034",
|
|
68
|
-
kind: "warning"
|
|
69
|
-
}
|
|
70
|
-
]);
|
|
71
|
-
});
|
|
72
|
-
});
|
package/dist/tools/oxlint.d.ts
DELETED
package/dist/tools/oxlint.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { execAndParse } from "../utils.mjs";
|
|
2
|
-
export const oxlint = ({ root }) => {
|
|
3
|
-
const bin = "oxlint";
|
|
4
|
-
const checkArgs = [
|
|
5
|
-
"--format=unix",
|
|
6
|
-
"--deny-warnings",
|
|
7
|
-
"--ignore-path=.oxlintignore",
|
|
8
|
-
"--ignore-pattern='**/dist/**'",
|
|
9
|
-
"--ignore-pattern='**/node_modules/**'",
|
|
10
|
-
"--ignore-pattern='**/.output/**'",
|
|
11
|
-
"--ignore-pattern='**/coverage/**'"
|
|
12
|
-
];
|
|
13
|
-
const fixArgs = [...checkArgs, "--fix"];
|
|
14
|
-
return {
|
|
15
|
-
name: "Oxlint",
|
|
16
|
-
packageName: "oxlint",
|
|
17
|
-
check: () => execAndParse(bin, checkArgs, root, parseOutput),
|
|
18
|
-
fix: () => execAndParse(bin, fixArgs, root, parseOutput)
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export const parseOutput = ({ stdout }) => {
|
|
22
|
-
if (stdout.trim()) {
|
|
23
|
-
return stdout.split(/\r?\n/).reduce((acc, line) => {
|
|
24
|
-
const groups = /^(?<file>.+?):(?<line>[0-9]+):(?<column>[0-9]+):\s?(?<message>.*?)\s?\[(?<kind>Warning|Error)\/?(?<rule>.*?)\]\s?$/.exec(
|
|
25
|
-
line
|
|
26
|
-
)?.groups;
|
|
27
|
-
if (groups) {
|
|
28
|
-
acc.push({
|
|
29
|
-
file: groups.file,
|
|
30
|
-
kind: groups.kind === "Error" ? "error" : "warning",
|
|
31
|
-
message: groups.message,
|
|
32
|
-
rule: groups.rule || void 0,
|
|
33
|
-
location: {
|
|
34
|
-
line: parseInt(groups.line, 10),
|
|
35
|
-
column: parseInt(groups.column, 10)
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return acc;
|
|
40
|
-
}, []);
|
|
41
|
-
}
|
|
42
|
-
return stdout.trim().split(/\r?\n/).map((line) => line.trim()).filter((line) => !!line && !line.includes(" ")).map(
|
|
43
|
-
(line) => ({
|
|
44
|
-
file: line.trim(),
|
|
45
|
-
kind: "warning",
|
|
46
|
-
message: "Not formatted."
|
|
47
|
-
})
|
|
48
|
-
);
|
|
49
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "bun:test";
|
|
2
|
-
import { parseOutput } from "./oxlint.mjs";
|
|
3
|
-
describe("Oxlint", () => {
|
|
4
|
-
it("should properly parse output", async () => {
|
|
5
|
-
const stdout = `
|
|
6
|
-
test.ts:1:7: Variable 'test' is declared but never used. [Warning/eslint(no-unused-vars)]
|
|
7
|
-
test.ts:3:7: Variable 'variable' is declared but never used. [Warning/eslint(no-unused-vars)]
|
|
8
|
-
test.ts:8:7: Variable 'two' is declared but never used. [Warning/eslint(no-unused-vars)]
|
|
9
|
-
test.ts:8:7: Missing initializer in const declaration [Error]
|
|
10
|
-
|
|
11
|
-
3 problems
|
|
12
|
-
`;
|
|
13
|
-
const stderr = "";
|
|
14
|
-
const code = 1;
|
|
15
|
-
expect(parseOutput({ code, stdout, stderr })).toEqual([
|
|
16
|
-
{
|
|
17
|
-
file: "test.ts",
|
|
18
|
-
message: "Variable 'test' is declared but never used.",
|
|
19
|
-
location: {
|
|
20
|
-
line: 1,
|
|
21
|
-
column: 7
|
|
22
|
-
},
|
|
23
|
-
rule: "eslint(no-unused-vars)",
|
|
24
|
-
kind: "warning"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
file: "test.ts",
|
|
28
|
-
message: "Variable 'variable' is declared but never used.",
|
|
29
|
-
location: {
|
|
30
|
-
line: 3,
|
|
31
|
-
column: 7
|
|
32
|
-
},
|
|
33
|
-
rule: "eslint(no-unused-vars)",
|
|
34
|
-
kind: "warning"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
file: "test.ts",
|
|
38
|
-
message: "Variable 'two' is declared but never used.",
|
|
39
|
-
location: {
|
|
40
|
-
line: 8,
|
|
41
|
-
column: 7
|
|
42
|
-
},
|
|
43
|
-
rule: "eslint(no-unused-vars)",
|
|
44
|
-
kind: "warning"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
file: "test.ts",
|
|
48
|
-
message: "Missing initializer in const declaration",
|
|
49
|
-
location: {
|
|
50
|
-
line: 8,
|
|
51
|
-
column: 7
|
|
52
|
-
},
|
|
53
|
-
kind: "error"
|
|
54
|
-
}
|
|
55
|
-
]);
|
|
56
|
-
});
|
|
57
|
-
});
|
package/dist/tools/prettier.d.ts
DELETED
package/dist/tools/prettier.mjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { execAndParse } from "../utils.mjs";
|
|
2
|
-
export const prettier = ({ root }) => {
|
|
3
|
-
const bin = "prettier";
|
|
4
|
-
const checkArgs = [".", "--list-different"];
|
|
5
|
-
const fixArgs = [".", "-w"];
|
|
6
|
-
return {
|
|
7
|
-
name: "Prettier",
|
|
8
|
-
packageName: "prettier",
|
|
9
|
-
check: () => execAndParse(bin, checkArgs, root, parseOutput),
|
|
10
|
-
fix: () => execAndParse(bin, fixArgs, root, parseOutput)
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export const parseOutput = ({ stdout, stderr }) => {
|
|
14
|
-
if (stderr.trim()) {
|
|
15
|
-
return stderr.split(/\r?\n/).reduce((acc, line) => {
|
|
16
|
-
const groups = /^\[(?<kind>.+?)\]\s?(?<file>.+?):\s?(?<message>.*?)\s?\((?<line>[0-9]+):(?<column>[0-9]+)\)$/.exec(
|
|
17
|
-
line
|
|
18
|
-
)?.groups;
|
|
19
|
-
if (groups) {
|
|
20
|
-
acc.push({
|
|
21
|
-
file: groups.file,
|
|
22
|
-
kind: groups.kind === "error" ? "error" : "warning",
|
|
23
|
-
message: groups.message,
|
|
24
|
-
location: {
|
|
25
|
-
line: parseInt(groups.line, 10),
|
|
26
|
-
column: parseInt(groups.column, 10)
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return acc;
|
|
31
|
-
}, []);
|
|
32
|
-
}
|
|
33
|
-
return stdout.trim().split(/\r?\n/).map((line) => line.trim()).filter((line) => !!line && !line.includes(" ")).map(
|
|
34
|
-
(line) => ({
|
|
35
|
-
file: line.trim(),
|
|
36
|
-
kind: "warning",
|
|
37
|
-
message: "Not formatted."
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|