Skip to content

Commit

Permalink
tools: use util.parseArgs in lint-md
Browse files Browse the repository at this point in the history
PR-URL: #55694
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
  • Loading branch information
RedYetiDev authored and ruyadorno committed Nov 27, 2024
1 parent 428701a commit 12543d5
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tools/lint-md/lint-md.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs';
import fs from 'node:fs';
import { parseArgs } from 'node:util';

import { unified } from 'unified';
import remarkParse from 'remark-parse';
Expand All @@ -7,20 +8,18 @@ import presetLintNode from 'remark-preset-lint-node';
import { read } from 'to-vfile';
import { reporter } from 'vfile-reporter';

const paths = process.argv.slice(2);
const { values: { format }, positionals: paths } = parseArgs({
options: {
format: { type: 'boolean', default: false },
},
allowPositionals: true,
});

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

let format = false;

if (paths[0] === '--format') {
paths.shift();
format = true;
}

const linter = unified()
.use(remarkParse)
.use(presetLintNode)
Expand Down

0 comments on commit 12543d5

Please sign in to comment.