Skip to content

chore: migrate to package.json-based linting package management#2576

Open
MikeMcC399 wants to merge 1 commit into
nodejs:mainfrom
MikeMcC399:migrate/linting-npm-package
Open

chore: migrate to package.json-based linting package management#2576
MikeMcC399 wants to merge 1 commit into
nodejs:mainfrom
MikeMcC399:migrate/linting-npm-package

Conversation

@MikeMcC399

Copy link
Copy Markdown
Contributor

Description

Move version definition of npm packages to package.json & package-lock.json:

  • doctoc
  • markdown-link-check
  • prettier

Use Node.js 24 (Active LTS).

Update linting workflows to run based on above package definitions:

Workflow
doctoc.yml
markdown-link-check.yml
prettier.yml

workflow_dispatch: event triggers are added to make it easier to check linting issue before submitting a PR.

Enable weekly npm updating through Dependabot.

Update CONTRIBUTING with prerequisites and linting instructions. Add Table of Contents.

Motivation and Context

The following workflows currently install npm dependencies on the fly. Code scanning alerts notes this as an issue.

Workflow npm Package
doctoc.yml doctoc (latest)
markdown-link-check.yml markdown-link-check@3.14.2
prettier.yml prettier@3.9.5

By moving the package version selection from GitHub Actions to npm package.json & package-lock.json files, versions can be pinned exactly and maintained regularly by Dependabot.

Setting Dependabot and npm minimum age to 5 days for updates, reduces the risk of fast supply-chain attacks:

Testing Details

Types of changes

  • Documentation
  • Version change (Update, remove or add more Node.js versions)
  • Variant change (Update, remove or add more variants, or versions of variants)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (none of the above)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING.md document.
  • All new and existing tests passed.

Move version definition of npm packages to
package.json & package-lock.json:
- doctoc
- markdown-link-check
- prettier

Update linting workflows.

Enable npm updating through Dependabot.
Add scripts and documentation to aid local linting.
@MikeMcC399

Copy link
Copy Markdown
Contributor Author

@MikeMcC399
MikeMcC399 marked this pull request as ready for review July 22, 2026 15:35
@MikeMcC399
MikeMcC399 requested a review from nschonni July 22, 2026 15:35
- README.md
- CONTRIBUTING.md
- docs/BestPractices.md
- .github/workflows/doctoc.yml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also run on changes to package*.com to test when the dependencies are changed

- 'markdown_link_check_config.json'
- '.github/workflows/markdown-link-check.yml'
- markdown_link_check_config.json
- .github/workflows/markdown-link-check.yml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also run on changes to package*.com to test when the dependencies are changed

run: npm i -g markdown-link-check@3.14.2
node-version-file: .node-version
cache: npm
cache-dependency-path: package-lock.json

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the default, and like doesn't need to be there.

node-version: 'lts/*'
- name: Install markdown-link-check
run: npm i -g markdown-link-check@3.14.2
node-version-file: .node-version

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is picked up automatically and doesn't need to be configured

Comment thread package.json
"name": "docker-node",
"description": "Build official Docker images for Node.js",
"private": true,
"type": "commonjs",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a mix of Common and Module, note sure which is better to declare

Comment thread package.json
"format:prettier": "prettier --write .",
"format:prettier:check": "prettier --check .",
"lint": "run-s format:toc format:prettier",
"check:markdown-links": "find *.md docs/*.md -print0 | xargs -0 -n1 markdown-link-check -c markdown_link_check_config.json"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The find stuff isn't cross platform portable, but I also struggled to get the globbing/ignore to work properly locally

Comment thread package.json
"private": true,
"type": "commonjs",
"scripts": {
"format:toc": "doctoc --update-only .",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playing with this locally I needed additional parameters, but maybe it was a version issue. I had "doctoc:README": "doctoc README.md --github --title \"## Table of Contents\"", separate targets, otherwise I thing the title stuff was causing a diff

- name: Install dependencies
run: npm ci
- name: Run Prettier
run: npx prettier --check .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run: npx prettier --check .
run: npm run format:prettier:check

Better to call the configured target

- name: Install dependencies
run: npm ci
- name: Run doctoc
run: npx doctoc --update-only .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run: npx doctoc --update-only .
run: npm run format:toc

Comment thread package.json
"format:toc": "doctoc --update-only .",
"format:prettier": "prettier --write .",
"format:prettier:check": "prettier --check .",
"lint": "run-s format:toc format:prettier",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"lint": "run-s format:toc format:prettier",
"lint": "run-s format:toc format:prettier:check",

I think you'd want the "check" versions" for this, but I also didn't know about the doctoc, if there was an equivilent.

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.

Manage npm packages used in workflows

2 participants