@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.
Files changed (41) hide show
  1. package/bin/check.mjs +1 -1
  2. package/dist/cli.d.ts +1 -1
  3. package/dist/cli.js +37 -0
  4. package/dist/index.d.ts +63 -5
  5. package/dist/index.js +3 -0
  6. package/dist/src-CKPF6CV1.js +451 -0
  7. package/package.json +23 -38
  8. package/dist/cli.mjs +0 -34
  9. package/dist/index.mjs +0 -135
  10. package/dist/tasklist/index.d.ts +0 -8
  11. package/dist/tasklist/index.mjs +0 -78
  12. package/dist/tools/eslint.d.ts +0 -3
  13. package/dist/tools/eslint.mjs +0 -41
  14. package/dist/tools/eslint.test.d.ts +0 -1
  15. package/dist/tools/eslint.test.mjs +0 -35
  16. package/dist/tools/index.d.ts +0 -1
  17. package/dist/tools/index.mjs +0 -14
  18. package/dist/tools/markdownlint.d.ts +0 -3
  19. package/dist/tools/markdownlint.mjs +0 -34
  20. package/dist/tools/markdownlint.test.d.ts +0 -1
  21. package/dist/tools/markdownlint.test.mjs +0 -72
  22. package/dist/tools/oxlint.d.ts +0 -3
  23. package/dist/tools/oxlint.mjs +0 -49
  24. package/dist/tools/oxlint.test.d.ts +0 -1
  25. package/dist/tools/oxlint.test.mjs +0 -57
  26. package/dist/tools/prettier.d.ts +0 -3
  27. package/dist/tools/prettier.mjs +0 -40
  28. package/dist/tools/prettier.test.d.ts +0 -1
  29. package/dist/tools/prettier.test.mjs +0 -78
  30. package/dist/tools/publint.d.ts +0 -3
  31. package/dist/tools/publint.mjs +0 -28
  32. package/dist/tools/publint.test.d.ts +0 -1
  33. package/dist/tools/publint.test.mjs +0 -33
  34. package/dist/tools/typescript.d.ts +0 -3
  35. package/dist/tools/typescript.mjs +0 -47
  36. package/dist/tools/typescript.test.d.ts +0 -1
  37. package/dist/tools/typescript.test.mjs +0 -51
  38. package/dist/types.d.ts +0 -55
  39. package/dist/types.mjs +0 -0
  40. package/dist/utils.d.ts +0 -11
  41. package/dist/utils.mjs +0 -50
@@ -1,78 +0,0 @@
1
- import { describe, it, expect } from "bun:test";
2
- import { parseOutput } from "./prettier.mjs";
3
- describe("Prettier", () => {
4
- it("should properly parse output", async () => {
5
- const stdout = `target/.rustc_info.json
6
- test.ts
7
- `;
8
- const stderr = "";
9
- const code = 1;
10
- expect(parseOutput({ code, stdout, stderr })).toEqual([
11
- {
12
- file: "target/.rustc_info.json",
13
- message: "Not formatted.",
14
- kind: "warning"
15
- },
16
- {
17
- file: "test.ts",
18
- message: "Not formatted.",
19
- kind: "warning"
20
- }
21
- ]);
22
- });
23
- it("return no problems when there isn't any output", async () => {
24
- const stdout = "";
25
- const stderr = "";
26
- const code = 1;
27
- expect(parseOutput({ code, stdout, stderr })).toEqual([]);
28
- });
29
- it("should return an error when a syntax error is reported", async () => {
30
- const stderr = `[error] src/components/CommitDiff.ts: SyntaxError: Declaration or statement expected. (15:1)
31
- [error] 13 | });
32
- [error] 14 |
33
- [error] > 15 | }
34
- [error] | ^
35
- [error] 16 |
36
- [error] src/components/CompareDiff.ts: Some other error message. (14:1)
37
- [error] 12 | });
38
- [error] 13 |
39
- [error] > 14 | }
40
- [error] | ^
41
- [error] 15 |
42
- `;
43
- const stdout = `.github/assets/privacy-policy.md 18ms
44
- .github/workflows/submit.yml 20ms
45
- .github/workflows/validate.yml 4ms
46
- .prettierrc.yml 0ms`;
47
- const code = 1;
48
- expect(parseOutput({ code, stdout, stderr })).toEqual([
49
- {
50
- file: "src/components/CommitDiff.ts",
51
- message: "SyntaxError: Declaration or statement expected.",
52
- location: {
53
- line: 15,
54
- column: 1
55
- },
56
- kind: "error"
57
- },
58
- {
59
- file: "src/components/CompareDiff.ts",
60
- message: "Some other error message.",
61
- location: {
62
- line: 14,
63
- column: 1
64
- },
65
- kind: "error"
66
- }
67
- ]);
68
- });
69
- it("should not report warnings for fix output", () => {
70
- const stderr = "";
71
- const stdout = `.github/assets/privacy-policy.md 18ms
72
- .github/workflows/submit.yml 20ms
73
- .github/workflows/validate.yml 4ms
74
- .prettierrc.yml 0ms`;
75
- const code = 0;
76
- expect(parseOutput({ code, stdout, stderr })).toEqual([]);
77
- });
78
- });
@@ -1,3 +0,0 @@
1
- import type { OutputParser, ToolDefinition } from "../types";
2
- export declare const publint: ToolDefinition;
3
- export declare const parseOutput: OutputParser;
@@ -1,28 +0,0 @@
1
- import { execAndParse } from "../utils.mjs";
2
- export const publint = ({ root }) => {
3
- const bin = "publint";
4
- const args = [];
5
- return {
6
- name: "Publint",
7
- packageName: "publint",
8
- check: () => execAndParse(bin, args, root, parseOutput)
9
- };
10
- };
11
- export const parseOutput = ({ stdout }) => {
12
- let kind = "warning";
13
- return stdout.split(/\r?\n/).reduce((acc, line) => {
14
- if (line.includes("Errors:")) {
15
- kind = "error";
16
- return acc;
17
- }
18
- const groups = /^[0-9]+\.\s?(?<message>.*)$/.exec(line)?.groups;
19
- if (groups == null)
20
- return acc;
21
- acc.push({
22
- kind,
23
- message: groups.message,
24
- file: "package.json"
25
- });
26
- return acc;
27
- }, []);
28
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- import { describe, it, expect } from "bun:test";
2
- import { parseOutput } from "./publint.mjs";
3
- describe("Publint", () => {
4
- it("should properly parse output", async () => {
5
- const stdout = `@aklinker1/check lint results:
6
- Suggestions:
7
- 1. Consider being better lolz.
8
- Warnings:
9
- 1. pkg.exports["."].import types is not exported. Consider adding pkg.exports["."].import.types: "./dist/index.d.ts" to be compatible with TypeScript's "moduleResolution": "bundler" compiler option.
10
- Errors:
11
- 1. pkg.module is ./dist/index.cjs but the file does not exist.
12
- `;
13
- const stderr = "";
14
- const code = 1;
15
- expect(parseOutput({ code, stdout, stderr })).toEqual([
16
- {
17
- file: "package.json",
18
- message: "Consider being better lolz.",
19
- kind: "warning"
20
- },
21
- {
22
- file: "package.json",
23
- message: `pkg.exports["."].import types is not exported. Consider adding pkg.exports["."].import.types: "./dist/index.d.ts" to be compatible with TypeScript's "moduleResolution": "bundler" compiler option.`,
24
- kind: "warning"
25
- },
26
- {
27
- file: "package.json",
28
- message: "pkg.module is ./dist/index.cjs but the file does not exist.",
29
- kind: "error"
30
- }
31
- ]);
32
- });
33
- });
@@ -1,3 +0,0 @@
1
- import type { OutputParser, ToolDefinition } from "../types";
2
- export declare const typescript: ToolDefinition;
3
- export declare const parseOutput: OutputParser;
@@ -1,47 +0,0 @@
1
- import { debug, execAndParse } from "../utils.mjs";
2
- export const typescript = async ({
3
- root,
4
- packageJson
5
- }) => {
6
- const tsc = {
7
- name: "TypeScript",
8
- bin: "tsc",
9
- packageName: "typescript",
10
- args: ["--noEmit", "--pretty", "false"]
11
- };
12
- const vueTsc = {
13
- name: "TypeScript (Vue)",
14
- bin: "vue-tsc",
15
- packageName: "vue-tsc",
16
- args: ["--noEmit", "--pretty", "false"]
17
- };
18
- const isVueTsc = packageJson.devDependencies?.["vue-tsc"] !== void 0;
19
- debug("TypeScript: Is vue-tsc installed? " + isVueTsc);
20
- const cmd = isVueTsc ? vueTsc : tsc;
21
- return {
22
- name: cmd.name,
23
- packageName: cmd.packageName,
24
- // Execute the other TSC binary if necessary
25
- check: async () => execAndParse(cmd.bin, cmd.args, root, parseOutput)
26
- };
27
- };
28
- export const parseOutput = ({ stdout }) => {
29
- return stdout.split(/\r?\n/).reduce((acc, line) => {
30
- const groups = /^(?<file>\S+?)\((?<line>[0-9]+),(?<column>[0-9]+)\): \w+? (?<rule>TS[0-9]+): (?<message>.*)$/.exec(
31
- line
32
- )?.groups;
33
- if (groups) {
34
- acc.push({
35
- file: groups.file,
36
- kind: "error",
37
- message: groups.message,
38
- location: {
39
- line: parseInt(groups.line, 10),
40
- column: parseInt(groups.column, 10)
41
- },
42
- rule: groups.rule
43
- });
44
- }
45
- return acc;
46
- }, []);
47
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- import { describe, it, expect } from "bun:test";
2
- import { parseOutput } from "./typescript.mjs";
3
- describe("TypeScript", () => {
4
- it("should properly parse output", async () => {
5
- const stdout = `test.ts(1,19): error TS2355: A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.
6
- test.ts(5,24): error TS7006: Parameter 'a' implicitly has an 'any' type.
7
- `;
8
- const stderr = "";
9
- const code = 1;
10
- expect(parseOutput({ code, stdout, stderr })).toEqual([
11
- {
12
- file: "test.ts",
13
- message: "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.",
14
- kind: "error",
15
- location: {
16
- line: 1,
17
- column: 19
18
- },
19
- rule: "TS2355"
20
- },
21
- {
22
- file: "test.ts",
23
- message: "Parameter 'a' implicitly has an 'any' type.",
24
- kind: "error",
25
- location: {
26
- line: 5,
27
- column: 24
28
- },
29
- rule: "TS7006"
30
- }
31
- ]);
32
- });
33
- it("should parse vue-tsc output", () => {
34
- const stdout = `src/components/CustomListsPref.vue(46,6): error TS2345: Argument of type '{ vale: string; }' is not assignable to parameter of type 'Partial<{}> & Omit<{ readonly value: string; "onUpdate:value"?: ((newValue: string) => any) | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...> & { ...; }, never> & Record<...>'.
35
- Property 'value' is missing in type '{ vale: string; }' but required in type 'Omit<{ readonly value: string; "onUpdate:value"?: ((newValue: string) => any) | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...> & { ...; }, never>'.`;
36
- const stderr = "";
37
- const code = 1;
38
- expect(parseOutput({ code, stdout, stderr })).toEqual([
39
- {
40
- file: "src/components/CustomListsPref.vue",
41
- message: `Argument of type '{ vale: string; }' is not assignable to parameter of type 'Partial<{}> & Omit<{ readonly value: string; "onUpdate:value"?: ((newValue: string) => any) | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...> & { ...; }, never> & Record<...>'.`,
42
- kind: "error",
43
- location: {
44
- line: 46,
45
- column: 6
46
- },
47
- rule: "TS2345"
48
- }
49
- ]);
50
- });
51
- });
package/dist/types.d.ts DELETED
@@ -1,55 +0,0 @@
1
- export interface CheckOptions {
2
- /**
3
- * Set to true to fix problems that can be automatically fixed.
4
- *
5
- * Defaults to `true` outside CI, and `false` inside CI.
6
- */
7
- fix?: boolean;
8
- /**
9
- * Directory to run commands in.
10
- */
11
- root?: string;
12
- /**
13
- * Set to true to enable debug logs.
14
- */
15
- debug?: boolean;
16
- }
17
- export type ToolDefinition = (opts: {
18
- root: string;
19
- packageJson: any;
20
- }) => Promise<Tool> | Tool;
21
- export interface Tool {
22
- /**
23
- * Name of tool shown in the console output.
24
- */
25
- name: string;
26
- /**
27
- * The name of the package in your `package.json`. If present, this tool will be ran.
28
- */
29
- packageName: string;
30
- /**
31
- * Run the tool, only checking for problems.
32
- */
33
- check: () => Promise<Problem[]>;
34
- /**
35
- * Run the tool, but fix problems if possible. If the tool doesn't support fixing problems, `check` will be called instead.
36
- */
37
- fix?: () => Promise<Problem[]>;
38
- }
39
- export interface Problem {
40
- location?: CodeLocation;
41
- message: string;
42
- file: string;
43
- kind: ProblemKind;
44
- rule?: string;
45
- }
46
- export interface CodeLocation {
47
- line: number;
48
- column: number;
49
- }
50
- export type ProblemKind = "warning" | "error";
51
- export type OutputParser = (data: {
52
- code: number;
53
- stdout: string;
54
- stderr: string;
55
- }) => Problem[];
package/dist/types.mjs DELETED
File without changes
package/dist/utils.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { OutputParser, Problem } from "./types";
2
- export declare function execAndParse(bin: string, args: string[], cwd: string, parser: OutputParser): Promise<Problem[]>;
3
- export declare function isDebug(): boolean;
4
- export declare const bold: (str: string) => string;
5
- export declare const dim: (str: string) => string;
6
- export declare const red: (str: string) => string;
7
- export declare const green: (str: string) => string;
8
- export declare const yellow: (str: string) => string;
9
- export declare const cyan: (str: string) => string;
10
- export declare function humanMs(ms: number): string;
11
- export declare function debug(message: string): void;
package/dist/utils.mjs DELETED
@@ -1,50 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- function exec(cmd, args, opts) {
3
- return new Promise((resolve, reject) => {
4
- const child = spawn(cmd, args, { ...opts, shell: true });
5
- let stderr = "";
6
- let stdout = "";
7
- child.stdout.on("data", (data) => {
8
- stdout += data.toString();
9
- });
10
- child.stderr.on("data", (data) => {
11
- stderr += data.toString();
12
- });
13
- child.on("error", (error) => {
14
- reject(error);
15
- });
16
- child.on("close", (exitCode) => {
17
- resolve({ stderr, stdout, exitCode });
18
- });
19
- });
20
- }
21
- export async function execAndParse(bin, args, cwd, parser) {
22
- const res = await exec(bin, args, { cwd });
23
- if (res.exitCode == null)
24
- throw Error("Exit code was null");
25
- if (isDebug())
26
- console.debug({ bin, args, cwd, ...res });
27
- return parser({
28
- code: res.exitCode,
29
- stderr: res.stderr,
30
- stdout: res.stdout
31
- });
32
- }
33
- export function isDebug() {
34
- return process.env.DEBUG === "true" || process.env.DEBUG === "1";
35
- }
36
- export const bold = (str) => `\x1B[1m${str}\x1B[0m`;
37
- export const dim = (str) => `\x1B[2m${str}\x1B[0m`;
38
- export const red = (str) => `\x1B[31m${str}\x1B[0m`;
39
- export const green = (str) => `\x1B[32m${str}\x1B[0m`;
40
- export const yellow = (str) => `\x1B[33m${str}\x1B[0m`;
41
- export const cyan = (str) => `\x1B[36m${str}\x1B[0m`;
42
- export function humanMs(ms) {
43
- const minutes = Math.floor(ms / 6e4);
44
- const seconds = (ms % 6e4 / 1e3).toFixed(minutes > 0 ? 0 : 3);
45
- return `${minutes > 0 ? `${minutes}m ` : ""}${seconds}s`;
46
- }
47
- export function debug(message) {
48
- if (isDebug())
49
- console.debug(dim("\u2699 " + message));
50
- }