Skip to content

Commit 0b58160

Browse files
author
Aviv Keller
authored
tools: use util.parseArgs in lint-md
PR-URL: #55694 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent d35cde6 commit 0b58160

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tools/lint-md/lint-md.mjs

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import fs from 'fs';
1+
import fs from 'node:fs';
2+
import { parseArgs } from 'node:util';
23

34
import { unified } from 'unified';
45
import remarkParse from 'remark-parse';
@@ -7,20 +8,18 @@ import presetLintNode from 'remark-preset-lint-node';
78
import { read } from 'to-vfile';
89
import { reporter } from 'vfile-reporter';
910

10-
const paths = process.argv.slice(2);
11+
const { values: { format }, positionals: paths } = parseArgs({
12+
options: {
13+
format: { type: 'boolean', default: false },
14+
},
15+
allowPositionals: true,
16+
});
1117

1218
if (!paths.length) {
13-
console.error('Usage: lint-md.mjs <path> [<path> ...]');
19+
console.error('Usage: lint-md.mjs [--format] <path> [<path> ...]');
1420
process.exit(1);
1521
}
1622

17-
let format = false;
18-
19-
if (paths[0] === '--format') {
20-
paths.shift();
21-
format = true;
22-
}
23-
2423
const linter = unified()
2524
.use(remarkParse)
2625
.use(presetLintNode)

0 commit comments

Comments
 (0)