Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5595ab

Browse files
committed
Add customize pint.json config for laravel project code style fix
1 parent 1e660fb commit e5595ab

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function sidebarProgrammingLanguage()
5454
items: [
5555
{text: "重定向 redirect", link: "/programming-language/php/laravel/route/redirect"},
5656
{text: "@each 渲染集合视图", link: "/programming-language/php/laravel/blade/each"},
57+
{text: "pint 代码风格", link: "/programming-language/php/laravel/code-style/pint"},
5758
]
5859
}
5960
];
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# pint 代码风格
2+
3+
[Laravel Pint](https://laravel.com/docs/master/pint#main-content) 支持开箱即用的代码风格检查和修复。
4+
5+
通过在项目根目录下添加 `pint.json` 来制定自定义的代码风格,更多自定义风格配置可以[查看这里](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/rules/index.rst)
6+
7+
文件内容如下:
8+
9+
```yml
10+
{
11+
"preset": "laravel",
12+
"rules": {
13+
"ordered_imports": {
14+
"sort_algorithm": "length",
15+
"imports_order": [
16+
"const",
17+
"class",
18+
"function"
19+
]
20+
}
21+
}
22+
}
23+
```
24+
25+
`ordered_imports` 格式化 PHP 中类的 `use` 语句,排序的规则使用字符长度,导入顺序按照 `const``class``function`

0 commit comments

Comments
 (0)