style: add formatter config

This commit is contained in:
ZhenShuo Leo
2025-05-28 06:22:24 +08:00
parent 0b06a64139
commit e785f50575
6 changed files with 112 additions and 2 deletions

10
.editorconfig Normal file
View File

@@ -0,0 +1,10 @@
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false

40
.prettierignore Normal file
View File

@@ -0,0 +1,40 @@
# https://github.com/gohugoio/hugo/blob/b39b24962350090122b5f3927456dde710cffb57/docs/.prettierignore
# https://github.com/gohugoio/hugo/blob/b39b24962350090122b5f3927456dde710cffb57/docs/.prettierrc
# develop
.vscode
node_modules
package.json
# Hugo
assets/lib
assets/css/compiled
content
themes
public
static
*.md
# Invalid nodes and unexpected tokens, mostly caused by unmatched tags in Hugo statements.
# For example:
# {{ with .Params.externalUrl }}
# <a href="{{ . }}">
# {{ else }}
# <a href="{{ .RelPermalink }}" class="min-w-full">
# {{ end }}
#
# This create an unclose node
layouts/_default/_markup/render-heading.html
layouts/_default/index.json
layouts/_default/list.html
layouts/partials/article-link/card-related.html
layouts/partials/article-link/card.html
layouts/partials/article-link/simple.html
layouts/partials/header/basic.html
layouts/partials/hero/background.html
layouts/partials/head.html
layouts/shortcodes/screenshot.html
layouts/shortcodes/figure.html
assets/js/appearance.js

45
.prettierrc Normal file
View File

@@ -0,0 +1,45 @@
{
"singleQuote": false,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"trailingComma": "all",
"proseWrap": "always",
"plugins": [
"prettier-plugin-go-template",
"@awmottaz/prettier-plugin-void-html"
],
"overrides": [
{
"files": ["*.html"],
"options": {
"useTabs": false,
"parser": "go-template",
"goTemplateBracketSpacing": true,
"printWidth": 112,
"bracketSameLine": true
}
},
{
"files": ["*.js", "*.mjs", "*.mts", "*.ts"],
"options": {
"semi": true,
"useTabs": false,
"printWidth": 112,
"singleQuote": false
}
},
{
"files": ["*.yml", "*.yaml"],
"options": {
"singleQuote": false
}
},
{
"files": ["*.json*"],
"options": {
"trailingComma": "none"
}
}
]
}

View File

@@ -45,7 +45,7 @@ The project includes a Prettier config that helps to format code in line with th
#### Commit message guidelines #### Commit message guidelines
- Use [Gitmoji](https://gitmoji.dev) in commit messages to provide context. - Use [Gitmoji](https://gitmoji.dev) in PR messages to provide context.
- Clearly describe the change with a short summary in the first 72 characters. - Clearly describe the change with a short summary in the first 72 characters.
- Place more detailed explanations in paragraphs below the summary, separated by a blank line. - Place more detailed explanations in paragraphs below the summary, separated by a blank line.
- Use imperative language (ie. "Fix bug", not "Fixed bug" or "Fixes bug"). - Use imperative language (ie. "Fix bug", not "Fixed bug" or "Fixes bug").

14
package-lock.json generated
View File

@@ -17,6 +17,7 @@
"commander": "^14.0.0" "commander": "^14.0.0"
}, },
"devDependencies": { "devDependencies": {
"@awmottaz/prettier-plugin-void-html": "^1.8.0",
"@tailwindcss/cli": "^4.1.7", "@tailwindcss/cli": "^4.1.7",
"@tailwindcss/typography": "^0.5.16", "@tailwindcss/typography": "^0.5.16",
"chart.js": "^4.4.9", "chart.js": "^4.4.9",
@@ -77,6 +78,19 @@
"url": "https://github.com/sponsors/antfu" "url": "https://github.com/sponsors/antfu"
} }
}, },
"node_modules/@awmottaz/prettier-plugin-void-html": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/@awmottaz/prettier-plugin-void-html/-/prettier-plugin-void-html-1.8.0.tgz",
"integrity": "sha512-gC1CO6TdjILFBc9UYJHY93RvM76jbNhb8IMiFzNbhyH1aCqvSVVjIhXCEQ9BkLyXGy8gmPfHX3m9BKHnl0edhQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=22.0.0"
},
"peerDependencies": {
"prettier": "3.0.0 - 3.5.x"
}
},
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
"version": "7.23.5", "version": "7.23.5",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz",

View File

@@ -36,6 +36,7 @@
}, },
"homepage": "https://github.com/nunocoracao/blowfish#readme", "homepage": "https://github.com/nunocoracao/blowfish#readme",
"devDependencies": { "devDependencies": {
"@awmottaz/prettier-plugin-void-html": "^1.8.0",
"@tailwindcss/cli": "^4.1.7", "@tailwindcss/cli": "^4.1.7",
"@tailwindcss/typography": "^0.5.16", "@tailwindcss/typography": "^0.5.16",
"chart.js": "^4.4.9", "chart.js": "^4.4.9",