npm(prettier-config): add xml, alphabetical sort

Summary:
Add xml linter, and bump version to 0.1.0 with changelog rules.

(and types w/ version bump & `.node_version`)

Signed-off-by: Yongmin Hong <revi@omglol.email>

Test Plan: not really testable?

Reviewers: O1 revi & automations, revi

Reviewed By: O1 revi & automations, revi

Differential Revision: https://issuetracker.revi.xyz/D473
This commit is contained in:
revi 2024-06-30 16:41:50 +09:00
parent f556f313d7
commit 1cceb76236
Signed by: revi
GPG key ID: 1EB4F6CEEA100E94
7 changed files with 170 additions and 45 deletions

1
.node-version Normal file
View file

@ -0,0 +1 @@
v20.15.0

View file

@ -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.

View file

@ -23,25 +23,7 @@ ## Config
'prettier-plugin-toml', 'prettier-plugin-toml',
], ],
overrides: [ overrides: [
{ // Sort by parser alphabet.
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: ['.arcconfig', '.arclint', '.arcunit', '.imgbotconfig'], files: ['.arcconfig', '.arclint', '.arcunit', '.imgbotconfig'],
options: {parser: 'json'}, options: {parser: 'json'},
@ -64,6 +46,25 @@ ## Config
], ],
options: {parser: 'jsonc', trailingComma: 'none'}, 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', files: '.yamllint',
options: {parser: 'yaml'}, options: {parser: 'yaml'},

View file

@ -1,7 +1,7 @@
{ {
"$schema": "https://json.schemastore.org/package.json", "$schema": "https://json.schemastore.org/package.json",
"name": "@revi/prettier-config", "name": "@revi/prettier-config",
"version": "0.0.7", "version": "0.1.0",
"author": { "author": {
"name": "revi", "name": "revi",
"email": "package-admin@revi.dev", "email": "package-admin@revi.dev",
@ -9,14 +9,21 @@
}, },
"description": "@revi's prettier configs", "description": "@revi's prettier configs",
"main": "prettier.config.js", "main": "prettier.config.js",
"types": "./types/prettier.config.d.ts",
"peerDependencies": { "peerDependencies": {
"@prettier/plugin-php": "0.22.2", "@prettier/plugin-php": "0.22.2",
"prettier": "3.3.2", "prettier": "3.3.2",
"prettier-plugin-sh": "0.14.0", "prettier-plugin-sh": "0.14.0",
"prettier-plugin-toml": "2.0.1" "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": { "scripts": {
"p:c": "prettier --check" "tsc": "tsc prettier.config.js --declaration --allowJs --emitDeclarationOnly --esModuleInterop --outdir types"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -21,27 +21,11 @@ const config = {
'prettier-plugin-sh', 'prettier-plugin-sh',
// https://github.com/bd82/toml-tools/tree/master/packages/prettier-plugin-toml // https://github.com/bd82/toml-tools/tree/master/packages/prettier-plugin-toml
'prettier-plugin-toml', 'prettier-plugin-toml',
// https://github.com/prettier/plugin-xml
'@prettier/plugin-xml',
], ],
overrides: [ overrides: [
{ // Sort by parser alphabet.
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: ['.arcconfig', '.arclint', '.arcunit', '.imgbotconfig'], files: ['.arcconfig', '.arclint', '.arcunit', '.imgbotconfig'],
options: {parser: 'json'}, options: {parser: 'json'},
@ -64,6 +48,36 @@ const config = {
], ],
options: {parser: 'jsonc', trailingComma: 'none'}, 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', files: '.yamllint',
options: {parser: 'yaml'}, options: {parser: 'yaml'},

View file

@ -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;

86
package-lock.json generated
View file

@ -390,6 +390,19 @@
"prettier": "^3.0.0" "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": { "node_modules/@revi/eslint-config": {
"resolved": "npm/eslint-config", "resolved": "npm/eslint-config",
"link": true "link": true
@ -599,6 +612,16 @@
"dev": true, "dev": true,
"license": "ISC" "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": { "node_modules/acorn": {
"version": "8.12.0", "version": "8.12.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz",
@ -831,6 +854,16 @@
"url": "https://github.com/chalk/chalk?sponsor=1" "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": { "node_modules/ci-info": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz",
@ -3180,6 +3213,13 @@
"string_decoder": "~0.10.x" "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": { "node_modules/regexp-tree": {
"version": "0.1.27", "version": "0.1.27",
"resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz",
@ -3859,15 +3899,16 @@
"url": "https://github.com/sponsors/revi" "url": "https://github.com/sponsors/revi"
}, },
"peerDependencies": { "peerDependencies": {
"@eslint/js": "9.5.0", "eslint": "9.5.0"
"eslint": "9.5.0",
"eslint-config-prettier": "9.1.0"
} }
}, },
"npm/prettier-config": { "npm/prettier-config": {
"name": "@revi/prettier-config", "name": "@revi/prettier-config",
"version": "0.0.7", "version": "0.0.8",
"license": "Apache-2.0", "license": "Apache-2.0",
"devDependencies": {
"@prettier/plugin-xml": "3.4.1"
},
"funding": { "funding": {
"url": "https://github.com/sponsors/revi" "url": "https://github.com/sponsors/revi"
}, },
@ -4122,6 +4163,15 @@
"php-parser": "^3.1.5" "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": { "@revi/eslint-config": {
"version": "file:npm/eslint-config", "version": "file:npm/eslint-config",
"requires": { "requires": {
@ -4138,7 +4188,9 @@
}, },
"@revi/prettier-config": { "@revi/prettier-config": {
"version": "file:npm/prettier-config", "version": "file:npm/prettier-config",
"requires": {} "requires": {
"@prettier/plugin-xml": "3.4.1"
}
}, },
"@taplo/core": { "@taplo/core": {
"version": "0.1.1", "version": "0.1.1",
@ -4283,6 +4335,15 @@
"integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==",
"dev": true "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": { "acorn": {
"version": "8.12.0", "version": "8.12.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz",
@ -4417,6 +4478,15 @@
"supports-color": "^7.1.0" "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": { "ci-info": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.0.0.tgz",
@ -6000,6 +6070,12 @@
"string_decoder": "~0.10.x" "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": { "regexp-tree": {
"version": "0.1.27", "version": "0.1.27",
"resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz",