@aklinker1/check 1.3.1 → 1.4.1
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/README.md +1 -1
- package/dist/tools/index.mjs +3 -2
- package/dist/tools/oxlint.d.ts +3 -0
- package/dist/tools/oxlint.mjs +49 -0
- package/dist/tools/oxlint.test.d.ts +1 -0
- package/dist/tools/oxlint.test.mjs +57 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/tools/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { eslint } from "./eslint.mjs";
|
|
2
|
+
import { oxlint } from "./oxlint.mjs";
|
|
2
3
|
import { prettier } from "./prettier.mjs";
|
|
3
|
-
import { typescript } from "./typescript.mjs";
|
|
4
4
|
import { publint } from "./publint.mjs";
|
|
5
|
-
|
|
5
|
+
import { typescript } from "./typescript.mjs";
|
|
6
|
+
export const ALL_TOOLS = [publint, prettier, typescript, oxlint, eslint];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { execAndParse, isBinInstalled } from "../utils.mjs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
export const oxlint = ({ binDir, root }) => {
|
|
4
|
+
const bin = resolve(root, binDir, "oxlint");
|
|
5
|
+
const checkArgs = [
|
|
6
|
+
"--format=linux",
|
|
7
|
+
"--deny-warnings",
|
|
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
|
+
isInstalled: () => isBinInstalled(bin),
|
|
17
|
+
check: () => execAndParse(bin, checkArgs, root, parseOuptut),
|
|
18
|
+
fix: () => execAndParse(bin, fixArgs, root, parseOuptut)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const parseOuptut = ({ stdout, stderr }) => {
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, it, expect } from "bun:test";
|
|
2
|
+
import { parseOuptut } 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(parseOuptut({ 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
|
+
});
|