@aklinker1/check 2.0.0 → 2.1.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/README.md CHANGED
@@ -13,7 +13,7 @@ pnpm check --fix
13
13
  To enable checks for any of the following modules, just install them:
14
14
 
15
15
  ```sh
16
- pnpm i -D typescript oxlint prettier publint eslint
16
+ pnpm i -D typescript oxlint prettier publint eslint markdownlint-cli
17
17
  ```
18
18
 
19
19
  ## Contributing
@@ -30,10 +30,14 @@ bun run build
30
30
  # Run checks
31
31
  bun check --help
32
32
  bun check
33
+
34
+ # Debug commands used
35
+ DEBUG=1 bun check
33
36
  ```
34
37
 
35
38
  ### Adding Tools
36
39
 
37
- I've added everything I use, so if you want to add support for another tool, feel free.
38
-
39
- Just copy `src/tools/prettier.ts` and `src/tools/prettier.test.ts`, update the implementations (yes, tests are required), and add your new tool to `src/tools/index.ts`'s `ALL_TOOLS` export.
40
+ 1. Copy and rename `src/tools/prettier.ts` and `src/tools/prettier.test.ts` accordingly
41
+ 2. Implement and update tests for your new tool
42
+ 3. Add your tool to the `ALL_TOOLS` array in `src/tools/index.ts`
43
+ 4. Add the tool's NPM package to the first section of this README
@@ -1,6 +1,14 @@
1
1
  import { eslint } from "./eslint.mjs";
2
+ import { markdownlint } from "./markdownlint.mjs";
2
3
  import { oxlint } from "./oxlint.mjs";
3
4
  import { prettier } from "./prettier.mjs";
4
5
  import { publint } from "./publint.mjs";
5
6
  import { typescript } from "./typescript.mjs";
6
- export const ALL_TOOLS = [publint, prettier, typescript, oxlint, eslint];
7
+ export const ALL_TOOLS = [
8
+ eslint,
9
+ markdownlint,
10
+ oxlint,
11
+ prettier,
12
+ publint,
13
+ typescript
14
+ ];
@@ -0,0 +1,3 @@
1
+ import type { OutputParser, ToolDefinition } from "../types";
2
+ export declare const markdownlint: ToolDefinition;
3
+ export declare const parseOutput: OutputParser;
@@ -0,0 +1,34 @@
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
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,72 @@
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aklinker1/check",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "packageManager": "bun@1.2.11",
5
5
  "repository": {
6
6
  "type": "git",