chore(ci): add prettier formatter#2570
Conversation
Add prettier workflow Reformat files js, mjs, json, md & yml Remove eclint workflow
|
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. |
This comment was marked as resolved.
This comment was marked as resolved.
nschonni
left a comment
There was a problem hiding this comment.
2 things that could be done as separate PRs:
- Create a
package.jsonto easier manage the versions of Prettier, and ascriptreference to locally debug the CI - Adding Depenabot for the NPM deps if a
package.jsonis 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. |
eclint#2526Description
Add Prettier for source code formatting of
js,mjs,json,md,ymlfiles using prettier npm module.In
.prettierrc.json, set defaultsingleQuote=trueExecute
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:singleQuotefalsetrueSet 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
Checklist