Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

scripts/markdownlint deletes the tracked package-lock.json and modifies package.json

未关闭 适合新手
#24,446 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
bash, nodejs
领域
tooling

调研方向

问题出在 scripts/markdownlint 中检查锁文件并运行 npm install --save-dev 的代码块里。请先阅读该代码块,以及检查 package-json.lock 的那段判断,该名称拼写有误。完成的标准是:在未安装 markdownlint 的情况下运行脚本后,git status 中 package-lock.json 和 package.json 保持不变,并且 lint 仍然正常运行。该 issue 建议用 npm install --no-save 作为修复方案。

由索引模型根据 Issue 内容生成。

描述

area/docs-efficiency type/bug

Error Report

Please answer the following questions before submitting your issue. Thanks!

  1. What is the URL/path of the document related to this issue?

    scripts/markdownlint

  2. How would you like to improve it?

    When markdownlint is not installed globally and ./node_modules/.bin/markdownlint does not exist yet, running ./scripts/markdownlint <files> deletes the tracked package-lock.json file and modifies package.json:

    $ ./scripts/markdownlint some-file.md
    $ git status --short
     D package-lock.json
     M package.json
    

    The cause is in the following part of the script:

    had_lock=
    if test -f package-json.lock ; then
      had_lock=true
    fi
    npm install --save-dev '[email protected]'
    if [[ -z "$had_lock"  ]] ; then
      rm -f package-lock.json
    fi
    
    • The lock file check uses package-json.lock instead of package-lock.json, so had_lock is always empty and package-lock.json is always removed. package-lock.json has been tracked in the repository since #8881, so this removes a tracked file.
    • npm install --save-dev adds "markdownlint-cli": "^0.17.0" to devDependencies in package.json, and the script does not revert it.

    Because AGENTS.md and several skills in .agents/ instruct agents to run ./scripts/markdownlint <files> for validation, these unrelated changes can easily end up in doc PRs.

    Suggested fix: install markdownlint-cli without modifying the tracked files, for example, with npm install --no-save '[email protected]', and remove the had_lock logic. Alternatively, add markdownlint-cli to devDependencies in package.json and package-lock.json.

主要语言
Python
星标
615
派生
724
平均合并
1 天 4 小时
30 天内合并 PR
531

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pingcap/docs 的其他 Issue

查看 pingcap/docs 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。