Skip to content

fix(cli): avoid executing lint setup when no input is provided - #168

Merged
luojiyin1987 merged 1 commit into
masterfrom
fix/help-before-setup
Aug 22, 2026
Merged

fix(cli): avoid executing lint setup when no input is provided#168
luojiyin1987 merged 1 commit into
masterfrom
fix/help-before-setup

Conversation

@luojiyin1987

Copy link
Copy Markdown
Contributor

Closes #167

改动

无输入判断从 parseAsync() 之后移到 action 最前面:

// No input at all: show help before touching config, threads, or
// stdin. A broken .lintmdrc must not turn bare "lint-md" into a
// config error.
if (!files.length && !stdin) {
  program.help();
}

main() 里 parseAsync 之后的原检查删除,保持单一判断来源。

行为变化

场景 之前 现在
lint-md(配置正常) 跑一遍空 setup 后显示 help 直接显示 help
lint-md.lintmdrc 损坏) CONFIG_INVALID 报错 exit 1 显示 help,exit 0

测试(新增 1 个)

  • 无输入时 getLintConfig 未被调用、process.exit(0) 被调用——证明 lint setup 完全没有开始

既有 "main shows help when no input is provided" 用例不变通过;--stdin 与文件路径的行为由 #166 的用例覆盖。

验证

检查项 结果
npm test -- --runInBand 25 suites / 214 tests 通过
手动:坏 .lintmdrc + 裸 lint-md 输出 Usage/Options,exit 0
npm run test:package 通过

@luojiyin1987
luojiyin1987 merged commit ddc7796 into master Aug 22, 2026
6 checks passed
@luojiyin1987
luojiyin1987 deleted the fix/help-before-setup branch August 22, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): avoid executing lint setup when no input is provided

1 participant