Use Prettier to check formatting. Supported languages include:
- JavaScript
- TypeScript
- CSS
- HTML
- JSON
- Markdown
- YAML
This is the version of the workflow for projects using the Task task runner tool.
Install the check-prettier-formatting-task.yml
GitHub Actions workflow to .github/workflows/
Taskfile.yml
- Formatting task.- Install to: repository root (or merge into the existing
Taskfile.yml
).
- Install to: repository root (or merge into the existing
Taskfile.yml
- npm tasks.- Install to: repository root (or merge into the existing
Taskfile.yml
).
- Install to: repository root (or merge into the existing
.prettierignore
- ignore paths configuration file.- Install to: repository root.
The tool dependencies of this workflow are managed by npm.
Add the dependencies by running this command:
npm install --save-dev prettier@^2.8.4
Commit the resulting changes to the package.json
and package-lock.json
files.
Configure the version of Node.js used for development of the project in the env.NODE_VERSION
field of check-prettier-formatting-task.yml
.
Prettier should be configured via a .prettierignore
file to ignore any externally maintained files contained in the repository:
https://prettier.io/docs/en/ignore.html
Support for additional languages can be added to Prettier via plugins: https://prettier.io/docs/en/plugins.html
Prettier automatically determines the language based on file name. In cases where it is not able to recognize a file, the parser can be specified in a .prettierrc.yml
configuration file:
https://prettier.io/docs/en/configuration.html#setting-the-parserdocsenoptionshtmlparser-option
The default Prettier code style is the official standardized style to be used in all Arduino tooling projects and should not be modified.
Add the following to /.gitignore
:
/node_modules/
Markdown badge:
[](https://github.com/TODO_REPO_OWNER/TODO_REPO_NAME/actions/workflows/check-prettier-formatting-task.yml)
Replace the TODO_REPO_OWNER
and TODO_REPO_NAME
placeholders in the URLs with the final repository owner and name (example).
Asciidoc badge:
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-prettier-formatting-task.yml/badge.svg["Check Prettier Formatting status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-prettier-formatting-task.yml"]
Define the {repository-owner}
and {repository-name}
attributes and use them throughout the readme (example).
Add CI workflow to check for Prettier formatting compliance
On every push and pull request that affects relevant files, check whether the formatting of supported
files is compliant with the Prettier style.
On every push and pull request that affects relevant files, check whether the formatting of supported files is compliant with the [Prettier](https://prettier.io/docs/en/index.html) style.