Skip to content

Commit 7e22dc9

Browse files
committed
Add TOML language formatting support to Prettier
Projects may use data files written in the TOML language. A common example of such is the `pyproject.toml` file present in projects that use the Poetry Python package management tool (either for project code dependencies, or development tools). In cases where the TOML content is edited directly by human contributors, it will be useful to provide code formatting infrastructure for TOML files, and to enforce consistent formatting. This is easily accomplished by adding TOML support to the existing code formatting infrastructure via the "prettier-plugin-toml" plugin for the Prettier formatting tool. Poetry's `poetry.lock` file is also written in the TOML language. This file is automatically generated and never manually edited. In this case, the automatically generated content is accepted as-is. So Prettier is configured to exclude the `poetry.lock` file from formatting.
1 parent 89c1776 commit 7e22dc9

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

.github/workflows/check-prettier-formatting-task.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ on:
9090
- "**.mkdn?"
9191
- "**.ronn"
9292
- "**.workbook"
93+
# TOML
94+
- "**/Cargo.lock"
95+
- "**/Cargo.toml.orig"
96+
- "**/Gopkg.lock"
97+
- "**/Pipfile"
98+
- "**/pdm.lock"
99+
- "**.toml"
93100
# YAML
94101
- "**/.clang-format"
95102
- "**/.clang-tidy"
@@ -187,6 +194,13 @@ on:
187194
- "**.mkdn?"
188195
- "**.ronn"
189196
- "**.workbook"
197+
# TOML
198+
- "**/Cargo.lock"
199+
- "**/Cargo.toml.orig"
200+
- "**/Gopkg.lock"
201+
- "**/Pipfile"
202+
- "**/pdm.lock"
203+
- "**.toml"
190204
# YAML
191205
- "**/.clang-format"
192206
- "**/.clang-tidy"

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/.licenses/
99
__pycache__/
1010
node_modules/
11+
poetry.lock
1112

1213
# Test files
1314
/internal/rule/schema/testdata/input/invalid-schema.json

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"plugins": ["prettier-plugin-toml"],
23
"semi": false,
34
"printWidth": 120,
45
"overrides": [

package-lock.json

Lines changed: 38 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"github-label-sync": "3.0.0",
66
"markdown-link-check": "3.13.7",
77
"markdownlint-cli": "0.45.0",
8-
"prettier": "3.6.2"
8+
"prettier": "3.6.2",
9+
"prettier-plugin-toml": "2.0.6"
910
},
1011
"engines": {
1112
"node": "20.x"

0 commit comments

Comments
 (0)