diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..c12134b --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +v20.15.0 diff --git a/npm/prettier-config/CHANGELOG.md b/npm/prettier-config/CHANGELOG.md new file mode 100644 index 0000000..ba0c673 --- /dev/null +++ b/npm/prettier-config/CHANGELOG.md @@ -0,0 +1,17 @@ +# `@revi/prettier-config` changelog + +Version bump criteria follows: + +- major: When the plugin is removed. +- minor: When the plugin is added. +- patch: When the rule is modified (without plugin addition/removal). + +## v0.1.0 + +### New plugin + +- [@prettier/plugin-xml](https://github.com/prettier/plugin-xml) + +### New rules + +- plugin-xml rules. diff --git a/npm/prettier-config/README.md b/npm/prettier-config/README.md index e69d7c1..058ce75 100644 --- a/npm/prettier-config/README.md +++ b/npm/prettier-config/README.md @@ -23,25 +23,7 @@ ## Config 'prettier-plugin-toml', ], overrides: [ - { - files: '*.php', - options: { - parser: 'php', - phpVersion: '8.1', - useTabs: true, - tabWidth: 4, - braceStyle: '1tbs', - }, - }, - { - files: [ - '.editorconfig', - '.gitattributes', - '.gitignore', - '.prettierignore', - ], - options: {parser: 'sh', keepPadding: true, minify: false}, - }, + // Sort by parser alphabet. { files: ['.arcconfig', '.arclint', '.arcunit', '.imgbotconfig'], options: {parser: 'json'}, @@ -64,6 +46,25 @@ ## Config ], options: {parser: 'jsonc', trailingComma: 'none'}, }, + { + files: '*.php', + options: { + parser: 'php', + phpVersion: '8.1', + useTabs: true, + tabWidth: 4, + braceStyle: '1tbs', + }, + }, + { + files: [ + '.editorconfig', + '.gitattributes', + '.gitignore', + '.prettierignore', + ], + options: {parser: 'sh', keepPadding: true, minify: false}, + }, { files: '.yamllint', options: {parser: 'yaml'}, diff --git a/npm/prettier-config/package.json b/npm/prettier-config/package.json index 2d7550c..0cd6c06 100644 --- a/npm/prettier-config/package.json +++ b/npm/prettier-config/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@revi/prettier-config", - "version": "0.0.7", + "version": "0.1.0", "author": { "name": "revi", "email": "package-admin@revi.dev", @@ -9,14 +9,21 @@ }, "description": "@revi's prettier configs", "main": "prettier.config.js", + "types": "./types/prettier.config.d.ts", "peerDependencies": { "@prettier/plugin-php": "0.22.2", "prettier": "3.3.2", "prettier-plugin-sh": "0.14.0", "prettier-plugin-toml": "2.0.1" }, + "devDependencies": { + "@prettier/plugin-php": "0.22.2", + "prettier-plugin-sh": "0.14.0", + "prettier-plugin-toml": "2.0.1", + "@prettier/plugin-xml": "3.4.1" + }, "scripts": { - "p:c": "prettier --check" + "tsc": "tsc prettier.config.js --declaration --allowJs --emitDeclarationOnly --esModuleInterop --outdir types" }, "repository": { "type": "git", diff --git a/npm/prettier-config/prettier.config.js b/npm/prettier-config/prettier.config.js index cdf1d77..2f03dd3 100644 --- a/npm/prettier-config/prettier.config.js +++ b/npm/prettier-config/prettier.config.js @@ -21,27 +21,11 @@ const config = { 'prettier-plugin-sh', // https://github.com/bd82/toml-tools/tree/master/packages/prettier-plugin-toml 'prettier-plugin-toml', + // https://github.com/prettier/plugin-xml + '@prettier/plugin-xml', ], overrides: [ - { - files: '*.php', - options: { - parser: 'php', - phpVersion: '8.1', - useTabs: true, - tabWidth: 4, - braceStyle: '1tbs', - }, - }, - { - files: [ - '.editorconfig', - '.gitattributes', - '.gitignore', - '.prettierignore', - ], - options: {parser: 'sh', keepPadding: true, minify: false}, - }, + // Sort by parser alphabet. { files: ['.arcconfig', '.arclint', '.arcunit', '.imgbotconfig'], options: {parser: 'json'}, @@ -64,6 +48,36 @@ const config = { ], options: {parser: 'jsonc', trailingComma: 'none'}, }, + { + files: '*.php', + options: { + parser: 'php', + phpVersion: '8.1', + useTabs: true, + tabWidth: 4, + braceStyle: '1tbs', + }, + }, + { + files: [ + '.editorconfig', + '.gitattributes', + '.gitignore', + '.prettierignore', + ], + options: {parser: 'sh', keepPadding: true, minify: false}, + }, + { + files: ['*.svg', '*.xml'], + options: { + parser: 'xml', + singleAttributePerLine: false, + xmlQuoteAttributes: 'preserve', + xmlSelfClosingSpace: true, + xmlSortAttributesByKey: false, + xmlWhitespaceSensitivity: 'strict', + }, + }, { files: '.yamllint', options: {parser: 'yaml'}, diff --git a/npm/prettier-config/types/prettier.config.d.ts b/npm/prettier-config/types/prettier.config.d.ts new file mode 100644 index 0000000..8286ff4 --- /dev/null +++ b/npm/prettier-config/types/prettier.config.d.ts @@ -0,0 +1,9 @@ +export default config; +/** + * @file revi's prettier config preset + * @see https://prettier.io/docs/en/configuration.html + * @type {import("prettier").Config} + * @copyright Hong Yongmin 2024 + * @license Apache-2.0 + */ +declare const config: import('prettier').Config; diff --git a/package-lock.json b/package-lock.json index 863e43d..e8e778b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -390,6 +390,19 @@ "prettier": "^3.0.0" } }, + "node_modules/@prettier/plugin-xml": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@prettier/plugin-xml/-/plugin-xml-3.4.1.tgz", + "integrity": "sha512-Uf/6/+9ez6z/IvZErgobZ2G9n1ybxF5BhCd7eMcKqfoWuOzzNUxBipNo3QAP8kRC1VD18TIo84no7LhqtyDcTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@xml-tools/parser": "^1.0.11" + }, + "peerDependencies": { + "prettier": "^3.0.0" + } + }, "node_modules/@revi/eslint-config": { "resolved": "npm/eslint-config", "link": true @@ -599,6 +612,16 @@ "dev": true, "license": "ISC" }, + "node_modules/@xml-tools/parser": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@xml-tools/parser/-/parser-1.0.11.tgz", + "integrity": "sha512-aKqQ077XnR+oQtHJlrAflaZaL7qZsulWc/i/ZEooar5JiWj1eLt0+Wg28cpa+XLney107wXqneC+oG1IZvxkTA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "chevrotain": "7.1.1" + } + }, "node_modules/acorn": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", @@ -831,6 +854,16 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/chevrotain": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-7.1.1.tgz", + "integrity": "sha512-wy3mC1x4ye+O+QkEinVJkPf5u2vsrDIYW9G7ZuwFl6v/Yu0LwUuT2POsb+NUWApebyxfkQq6+yDfRExbnI5rcw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "regexp-to-ast": "0.5.0" + } + }, "node_modules/ci-info": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz", @@ -3180,6 +3213,13 @@ "string_decoder": "~0.10.x" } }, + "node_modules/regexp-to-ast": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/regexp-to-ast/-/regexp-to-ast-0.5.0.tgz", + "integrity": "sha512-tlbJqcMHnPKI9zSrystikWKwHkBqu2a/Sgw01h3zFjvYrMxEDYHzzoMZnUrbIfpTFEsoRnnviOXNCzFiSc54Qw==", + "dev": true, + "license": "MIT" + }, "node_modules/regexp-tree": { "version": "0.1.27", "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", @@ -3859,15 +3899,16 @@ "url": "https://github.com/sponsors/revi" }, "peerDependencies": { - "@eslint/js": "9.5.0", - "eslint": "9.5.0", - "eslint-config-prettier": "9.1.0" + "eslint": "9.5.0" } }, "npm/prettier-config": { "name": "@revi/prettier-config", - "version": "0.0.7", + "version": "0.0.8", "license": "Apache-2.0", + "devDependencies": { + "@prettier/plugin-xml": "3.4.1" + }, "funding": { "url": "https://github.com/sponsors/revi" }, @@ -4122,6 +4163,15 @@ "php-parser": "^3.1.5" } }, + "@prettier/plugin-xml": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@prettier/plugin-xml/-/plugin-xml-3.4.1.tgz", + "integrity": "sha512-Uf/6/+9ez6z/IvZErgobZ2G9n1ybxF5BhCd7eMcKqfoWuOzzNUxBipNo3QAP8kRC1VD18TIo84no7LhqtyDcTg==", + "dev": true, + "requires": { + "@xml-tools/parser": "^1.0.11" + } + }, "@revi/eslint-config": { "version": "file:npm/eslint-config", "requires": { @@ -4138,7 +4188,9 @@ }, "@revi/prettier-config": { "version": "file:npm/prettier-config", - "requires": {} + "requires": { + "@prettier/plugin-xml": "3.4.1" + } }, "@taplo/core": { "version": "0.1.1", @@ -4283,6 +4335,15 @@ "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "dev": true }, + "@xml-tools/parser": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@xml-tools/parser/-/parser-1.0.11.tgz", + "integrity": "sha512-aKqQ077XnR+oQtHJlrAflaZaL7qZsulWc/i/ZEooar5JiWj1eLt0+Wg28cpa+XLney107wXqneC+oG1IZvxkTA==", + "dev": true, + "requires": { + "chevrotain": "7.1.1" + } + }, "acorn": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", @@ -4417,6 +4478,15 @@ "supports-color": "^7.1.0" } }, + "chevrotain": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-7.1.1.tgz", + "integrity": "sha512-wy3mC1x4ye+O+QkEinVJkPf5u2vsrDIYW9G7ZuwFl6v/Yu0LwUuT2POsb+NUWApebyxfkQq6+yDfRExbnI5rcw==", + "dev": true, + "requires": { + "regexp-to-ast": "0.5.0" + } + }, "ci-info": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz", @@ -6000,6 +6070,12 @@ "string_decoder": "~0.10.x" } }, + "regexp-to-ast": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/regexp-to-ast/-/regexp-to-ast-0.5.0.tgz", + "integrity": "sha512-tlbJqcMHnPKI9zSrystikWKwHkBqu2a/Sgw01h3zFjvYrMxEDYHzzoMZnUrbIfpTFEsoRnnviOXNCzFiSc54Qw==", + "dev": true + }, "regexp-tree": { "version": "0.1.27", "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz",