Skip to content

chore(ci): add prettier formatter#2570

Merged
MikeMcC399 merged 1 commit into
nodejs:mainfrom
MikeMcC399:migrate/prettier
Jul 21, 2026
Merged

chore(ci): add prettier formatter#2570
MikeMcC399 merged 1 commit into
nodejs:mainfrom
MikeMcC399:migrate/prettier

Conversation

@MikeMcC399

@MikeMcC399 MikeMcC399 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description

Add Prettier for source code formatting of js, mjs, json, md, yml files using prettier npm module.

In .prettierrc.json, set default

  • singleQuote = true

Execute npx prettier --write . to reformat all affected files.

Add a GitHub Actions workflow prettier.yml

Remove workflow eclint.yml

Motivation and Context

The npm module eclint, last published in Oct 2018, is archived since Oct 2020 and is therefore unsupported and unmaintained. It is used in the GitHub Actions workflow eclint.yml "Test Whitespace and line endings".

Prettier is a widely-used, mature, code formatter (91 Mio downloads / week, 4.9k GitHub stars).

Prettier parses an EditorConfig file and so can work with the existing .editorconfig in the repo.

In .prettierrc.json, set configuration options only where they differ from Prettier defaults:

Option Prettier default docker-node setting
singleQuote false true

Set the printWidth for versions.json to 38 to force the variant arrays to continue to be vertically formatted.

Testing Details

npm install prettier@latest -g
npx prettier --check .

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.

@MikeMcC399 MikeMcC399 added the ci CI (Continuous Integration) workflows label Jul 20, 2026
@MikeMcC399

Copy link
Copy Markdown
Contributor Author

This PR enables the unsupported eclint to be replaced with prettier using minimal configuration.

I'd like feedback about whether this is a reasonable approach.

If the end-result is acceptable, the PR could either be merged in one go, or each of the files / file types could be separated out for finer-grained review and testing in a set of stacked PRs. Theoretically none of the formatting changes should have any effect on execution, but testing is usually better than just assuming!

In JavaScript, quotes and semicolons were being used inconsistently. This change sets the standard to single quotes, and usage of semicolons. This is the same setting that the nodejs/node repo uses, although it is enforced there through ESLint, not through Prettier.

@MikeMcC399
MikeMcC399 marked this pull request as draft July 20, 2026 12:42
@MikeMcC399

This comment was marked as resolved.

@nschonni nschonni left a comment

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.

2 things that could be done as separate PRs:

  1. Create a package.json to easier manage the versions of Prettier, and a script reference to locally debug the CI
  2. Adding Depenabot for the NPM deps if a package.json is added.

@MikeMcC399

Copy link
Copy Markdown
Contributor Author

2 things that could be done as separate PRs:

  1. Create a package.json to easier manage the versions of Prettier, and a script reference to locally debug the CI
  2. Adding Depenabot for the NPM deps if a package.json is added.

I do believe this is the way to go, and I'm happy you're suggesting it. I did already consider it when I looked at using ESLint instead of, or together with, Prettier. It would also allow other npm dependencies called only in CI to be managed through Dependabot's version updates.

@MikeMcC399

Copy link
Copy Markdown
Contributor Author

I will leave this open for one week for review. Also I'm seeing that there is a security release planned for Jul 27, 2026, so I would wait until after that date before merging to avoid any risk of disrupting it.

Comment thread .prettierrc.json
@nschonni

Copy link
Copy Markdown
Member

I think if you rebase this for the conflicts from the Action bump, it doesn't need to wait till after the Security release. All this is non-breaking formatting things

@MikeMcC399

Copy link
Copy Markdown
Contributor Author

I think if you rebase this for the conflicts from the Action bump, it doesn't need to wait till after the Security release. All this is non-breaking formatting things

OK. I'll do that. I was just being super cautious!

Add prettier workflow
Reformat files js, mjs, json, md & yml

Remove eclint workflow

Exclude auto-generated TOC contents
@MikeMcC399
MikeMcC399 merged commit ebca933 into nodejs:main Jul 21, 2026
31 checks passed
@MikeMcC399
MikeMcC399 deleted the migrate/prettier branch July 21, 2026 15:43
@MikeMcC399
MikeMcC399 removed the request for review from sxa July 21, 2026 15:43
@github-actions

Copy link
Copy Markdown

Created PR on the official-images repo (docker-library/official-images#21889). See https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what if you are wondering when it will be available on the Docker Hub.

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

Labels

ci CI (Continuous Integration) workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Test Whitespace and line endings" workflow uses unmaintained eclint

2 participants