Skip to content

scripts: stop markdownlint from modifying package.json and package-lock.json - #24464

Open
mjonss wants to merge 1 commit into
pingcap:masterfrom
mjonss:fix-markdownlint-script
Open

mjonss wants to merge 1 commit into
pingcap:masterfrom
mjonss:fix-markdownlint-script

Conversation

@mjonss

@mjonss mjonss commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What is changed, added, or deleted? (Required)

When markdownlint is not installed globally, the first run of ./scripts/markdownlint installs markdownlint-cli. Before this PR, this step had the following side effects:

  • npm install --save-dev added "markdownlint-cli": "^0.17.0" to package.json.
  • The script checked for package-json.lock instead of package-lock.json, so it always deleted the tracked package-lock.json.

This PR installs markdownlint-cli with npm install --no-save instead, which leaves package.json and package-lock.json unchanged, and removes the lock file handling.

Tested in a copy of the repository without node_modules: the first run installs markdownlint-cli and lints the files without modifying package.json or package-lock.json, later runs reuse the installed binary, and lint errors still result in a non-zero exit code.

Close #24446

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

  • Related code change PR links (if applicable):
  • This PR is translated from:
  • Other reference link(s):

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated the Markdown linting setup to install its command-line tool temporarily when it is missing, rather than saving it as a project development dependency. The setup no longer checks for an existing lockfile or removes a generated one. This changes how the linting tool is obtained and how lockfile changes are handled during setup; it does not change the Markdown linting checks themselves.

…ck.json

On the first run, scripts/markdownlint installed markdownlint-cli with
`npm install --save-dev`, which added it to package.json. It then checked
for `package-json.lock` instead of `package-lock.json`, so it always
deleted the tracked package-lock.json.

Install markdownlint-cli with `npm install --no-save` instead, which leaves
both files unchanged, and remove the lock file handling.

Close pingcap#24446

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mjonss mjonss added translation/no-need No need to translate this PR. area/docs-efficiency Indicates that the PR or issue belongs to improving docs work efficiency. labels Oct 15, 2026
@ti-chi-bot

ti-chi-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kissmydb for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 15, 2026
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pingcap/docs/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 06a76db8-5572-47dd-9545-ff2c6db5088a
📥 Commits

Reviewing files that changed from the base of the PR and between e9b33be and bad8daa.

📒 Files selected for processing: 1
  • scripts/markdownlint

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

When the local markdownlint executable is missing, the script installs markdownlint-cli@0.17.0 with npm install --no-save. It no longer checks for or deletes package-lock.json.

Changes: Markdownlint install behavior

Layer / File(s) Summary
Fallback installation
scripts/markdownlint
The missing-executable path installs markdownlint-cli@0.17.0 without saving it as a project dependency. It removes the prior lockfile check and conditional deletion of package-lock.json.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to bad8d

The fallback installs markdownlint without saving the dependency and no longer has the path that deleted package-lock.json. The stated first-run objective is met, with no actionable merge risk remaining.

### Architecture Summary

Architecture risk: 🔵 Low · up to bad8d

The change affects 1 system.

Changed systems: scripts

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — scripts (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in scripts/markdownlint: The missing-executable path now installs markdownlint-cli@0.17.0 without saving it as a dev dependency. It removes the prior lockfile check and conditional deletion of package-lock.json.
Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Title check Passed The title clearly describes the main change: preventing the markdownlint script from modifying package.json and package-lock.json.
Description check Passed The description explains the problem, the implementation, the affected version, testing results, issue reference, and AI involvement. It follows the repository template sufficiently.
Linked Issues check Passed Issue #24446 requires ./scripts/markdownlint to avoid modifying package.json and package-lock.json when it installs the missing local CLI. The supplied PR evidence states that the script now use…
Out of Scope Changes check Passed The supplied change summary identifies one change in scripts/markdownlint: it changes the installation mode and removes obsolete lock-file handling. These changes directly implement issue #24446. No…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs-efficiency Indicates that the PR or issue belongs to improving docs work efficiency. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. translation/no-need No need to translate this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant