From deec84ba79118226ee706cec80b23b11ea44fdec Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 16 Mar 2025 04:32:36 -0700 Subject: [PATCH] Add TOML language formatting capability to the project infrastructure Python package-based tools are used by the infrastructure of this project. The configuration of this Python infrastructure is defined by the `pyproject.toml` file. This file uses the TOML language. In addition to the machine entries produced by the Poetry tool, this important file is also edited directly by human contributors. For this reason, 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. --- .../check-prettier-formatting-task.yml | 14 +++++ .prettierignore | 1 + .prettierrc.yml | 2 + package-lock.json | 63 ++++++++++++++++++- package.json | 3 +- 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 .prettierrc.yml diff --git a/.github/workflows/check-prettier-formatting-task.yml b/.github/workflows/check-prettier-formatting-task.yml index 2fd375a..486678d 100644 --- a/.github/workflows/check-prettier-formatting-task.yml +++ b/.github/workflows/check-prettier-formatting-task.yml @@ -92,6 +92,13 @@ on: - "**.mkdn?" - "**.ronn" - "**.workbook" + # TOML + - "**/Cargo.lock" + - "**/Cargo.toml.orig" + - "**/Gopkg.lock" + - "**/Pipfile" + - "**/pdm.lock" + - "**.toml" # YAML - "**/.clang-format" - "**/.clang-tidy" @@ -189,6 +196,13 @@ on: - "**.mkdn?" - "**.ronn" - "**.workbook" + # TOML + - "**/Cargo.lock" + - "**/Cargo.toml.orig" + - "**/Gopkg.lock" + - "**/Pipfile" + - "**/pdm.lock" + - "**.toml" # YAML - "**/.clang-format" - "**/.clang-tidy" diff --git a/.prettierignore b/.prettierignore index e1f03f1..b5b48de 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ .licenses/ __pycache__/ node_modules/ +poetry.lock diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..5b86838 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,2 @@ +plugins: + - prettier-plugin-toml diff --git a/package-lock.json b/package-lock.json index 418e263..73a5f8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "github-label-sync": "3.0.0", "markdown-link-check": "^3.13.7", "markdownlint-cli": "^0.44.0", - "prettier": "^3.5.3" + "prettier": "^3.5.3", + "prettier-plugin-toml": "2.0.2" }, "engines": { "node": "20.x" @@ -127,6 +128,23 @@ "node": ">=14.16" } }, + "node_modules/@taplo/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@taplo/core/-/core-0.1.1.tgz", + "integrity": "sha512-BG/zLGf5wiNXGEVPvUAAX/4ilB3PwDUY2o0MV0y47mZbDZ9ad9UK/cIQsILat3bqbPJsALVbU6k3cskNZ3vAQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@taplo/lib": { + "version": "0.4.0-alpha.2", + "resolved": "https://registry.npmjs.org/@taplo/lib/-/lib-0.4.0-alpha.2.tgz", + "integrity": "sha512-DV/Re3DPVY+BhBtLZ3dmP4mP6YMLSsgq9qGLXwOV38lvNF/fBlgvQswzlXmzCEefL/3q2eMoefZpOI/+GLuCNA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@taplo/core": "^0.1.0" + } + }, "node_modules/@tootallnate/quickjs-emscripten": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", @@ -2754,6 +2772,25 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-plugin-toml": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/prettier-plugin-toml/-/prettier-plugin-toml-2.0.2.tgz", + "integrity": "sha512-tUIIhyfdVX5DMsLGKX/2qaEwi3W48OkUSR7XC91PRI5jFzhexmaYWkrSP1Xh/eWUcEc0TVMQenM3lB09xLQstQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@taplo/lib": "^0.4.0-alpha.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + }, + "peerDependencies": { + "prettier": "^3.0.3" + } + }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -3563,6 +3600,21 @@ "defer-to-connect": "^2.0.1" } }, + "@taplo/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@taplo/core/-/core-0.1.1.tgz", + "integrity": "sha512-BG/zLGf5wiNXGEVPvUAAX/4ilB3PwDUY2o0MV0y47mZbDZ9ad9UK/cIQsILat3bqbPJsALVbU6k3cskNZ3vAQg==", + "dev": true + }, + "@taplo/lib": { + "version": "0.4.0-alpha.2", + "resolved": "https://registry.npmjs.org/@taplo/lib/-/lib-0.4.0-alpha.2.tgz", + "integrity": "sha512-DV/Re3DPVY+BhBtLZ3dmP4mP6YMLSsgq9qGLXwOV38lvNF/fBlgvQswzlXmzCEefL/3q2eMoefZpOI/+GLuCNA==", + "dev": true, + "requires": { + "@taplo/core": "^0.1.0" + } + }, "@tootallnate/quickjs-emscripten": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", @@ -5376,6 +5428,15 @@ "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", "dev": true }, + "prettier-plugin-toml": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/prettier-plugin-toml/-/prettier-plugin-toml-2.0.2.tgz", + "integrity": "sha512-tUIIhyfdVX5DMsLGKX/2qaEwi3W48OkUSR7XC91PRI5jFzhexmaYWkrSP1Xh/eWUcEc0TVMQenM3lB09xLQstQ==", + "dev": true, + "requires": { + "@taplo/lib": "^0.4.0-alpha.2" + } + }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", diff --git a/package.json b/package.json index b852736..e1ab3f4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "github-label-sync": "3.0.0", "markdown-link-check": "^3.13.7", "markdownlint-cli": "^0.44.0", - "prettier": "^3.5.3" + "prettier": "^3.5.3", + "prettier-plugin-toml": "2.0.2" }, "engines": { "node": "20.x"