Skip to content

Commit cf933a8

Browse files
committed
Use npm to manage Prettier tool dependency
The project uses the Prettier tool to format various file types. Previously, the version of the tool used was not controlled. This was problematic because: - A different version of the tool may be used on the contributor's machine than on the CI runner, resulting in confusing failures. - The project is immediately subject to disruption or breakage resulting from a release of the tool. The new approach is to specify the version of the tools via the standard npm metadata files (package.json + package-lock.json), providing the following benefits: - Enables automated updates via Dependabot PRs - Enables automated vulnerability alerts
1 parent a7443f8 commit cf933a8

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

Diff for: .github/workflows/check-prettier-formatting-task.yml

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-prettier-formatting-task.md
22
name: Check Prettier Formatting
33

4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 20.x
7+
48
# See: https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
59
on:
610
create:
@@ -238,6 +242,11 @@ jobs:
238242
- name: Checkout repository
239243
uses: actions/checkout@v4
240244

245+
- name: Setup Node.js
246+
uses: actions/setup-node@v4
247+
with:
248+
node-version: ${{ env.NODE_VERSION }}
249+
241250
- name: Install Task
242251
uses: arduino/setup-task@v2
243252
with:

Diff for: Taskfile.yml

+2
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ tasks:
200200
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml
201201
general:format-prettier:
202202
desc: Format all supported files with Prettier
203+
deps:
204+
- task: npm:install-deps
203205
cmds:
204206
- npx prettier --write .
205207

Diff for: package-lock.json

+18-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"devDependencies": {
33
"markdown-link-check": "3.11.2",
4-
"markdownlint-cli": "0.37.0"
4+
"markdownlint-cli": "0.37.0",
5+
"prettier": "3.3.3"
56
},
67
"type": "module"
78
}

0 commit comments

Comments
 (0)