Skip to content

Commit 8ac4336

Browse files
committed
Update pre-commit config.
1 parent 76e5f63 commit 8ac4336

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

.pre-commit-config.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
exclude: |
2+
(?x)^(
3+
^.github/|
4+
bin/.*\.gitkeep
5+
)
16
repos:
27
- repo: https://github.com/pre-commit/pre-commit-hooks
38
rev: v5.0.0
@@ -16,21 +21,20 @@ repos:
1621
rev: v4.0.0-alpha.8
1722
hooks:
1823
- id: prettier
19-
entry: pnpm prettier --write --plugin=prettier-plugin-astro
20-
args: ["--tab-width", "2", "--trailing-comma", "es5"]
21-
additional_dependencies: ["prettier", "prettier-plugin-astro"]
24+
entry: pnpm run format:files
2225
exclude: "pnpm-lock.yaml"
26+
exclude_types: ["svg", "editorconfig", "gitignore"]
2327

2428
- repo: local
2529
hooks:
2630
- id: local_prettier
2731
name: prettier
28-
entry: pnpm prettier --log-level=error --plugin=prettier-plugin-astro
29-
args: ["--tab-width", "2", "--trailing-comma", "es5"]
32+
entry: pnpm run format:files
3033
language: node
3134
types_or: ["text"]
3235
exclude_types: ["editorconfig", "gitignore"]
3336
additional_dependencies: ["prettier", "prettier-plugin-astro"]
37+
files: \.(astro|mdx|md|yml|yaml|ts|js|mjs)$
3438

3539
- id: astro-check
3640
name: astro check
@@ -39,6 +43,7 @@ repos:
3943
files: "^(?:public|src)/.+|astro\\.config\\.mjs|tsconfig\\.json"
4044
pass_filenames: false
4145
additional_dependencies: ["astro", "@astrojs/check"]
46+
4247
- id: astro-build
4348
name: astro build
4449
entry: astro build

.prettierrc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"tabWidth": 2,
3+
"trailingComma": "es5",
4+
"plugins": ["prettier-plugin-astro"],
5+
"overrides": [
6+
{
7+
"files": "*.astro",
8+
"options": {
9+
"parser": "astro"
10+
}
11+
}
12+
],
13+
"printWidth": 100,
14+
"semi": true,
15+
"singleQuote": false,
16+
"bracketSpacing": true,
17+
"bracketSameLine": false,
18+
"arrowParens": "avoid",
19+
"endOfLine": "lf",
20+
"ignore": ["pnpm-lock.yaml", ".github/**", "**/.gitkeep"],
21+
"include": [
22+
"\\.astro$",
23+
"\\.mdx$",
24+
"\\.md$",
25+
"\\.yml$",
26+
"\\.yaml$",
27+
"\\.ts$",
28+
"\\.js$",
29+
"\\.mjs$"
30+
]
31+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"build": "astro check && astro build && pnpm pagefind --site dist",
99
"preview": "astro preview",
1010
"astro": "astro",
11-
"format": "pnpm prettier --tab-width 2 --trailing-comma es5 --write --log-level=error --plugin=prettier-plugin-astro ."
11+
"format:files": "pnpm prettier --config .prettierrc --write --log-level=error",
12+
"format": "pnpm run format:files ."
1213
},
1314
"dependencies": {
1415
"@astro-community/astro-embed-youtube": "^0.5.6",

0 commit comments

Comments
 (0)