diff --git a/tools/lint-md/lint-md.mjs b/tools/lint-md/lint-md.mjs index 4116d7e803b64e..fd5576d404c905 100644 --- a/tools/lint-md/lint-md.mjs +++ b/tools/lint-md/lint-md.mjs @@ -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'; @@ -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 [ ...]'); + console.error('Usage: lint-md.mjs [--format] [ ...]'); process.exit(1); } -let format = false; - -if (paths[0] === '--format') { - paths.shift(); - format = true; -} - const linter = unified() .use(remarkParse) .use(presetLintNode)