mavsolutions / yaml-linter
用于检查 YAML 文件语法的 Symfony 命令行工具
0.1.0
2023-04-11 08:50 UTC
Requires
- composer-runtime-api: ^2
- symfony/console: ^5 | ^6
- symfony/finder: ^5 | ^6
- symfony/yaml: ^5 | ^6
Requires (Dev)
- roave/security-advisories: dev-latest
README
symfony/yaml 的 LintCommand 的包装器(见 Symfony/Yaml)
使用方法与 Symfony 的 LintCommand 相同,以 filename
作为参数,单个文件作为 exclude
-选项,并带有附加选项 excludePattern
。
排除模式(ExcludePattern)将使用 symfony/finder(见 Symfony/Finder)作为路径解析,所有匹配的 yaml|yml
都将添加到 LintCommand 的排除选项中。
用例
在一些项目中,可能会使用本地 composer 包,这些包有它们自己的前端构建链。这个构建链可能会将一些第三方库集成到你的项目结构中,并包含格式不正确的 yaml
文件,这些文件你不需要关心。
├── composer.json ├── src … └── packages └── local-subpackage ├── composer.json ├── Configuration ├── Documentation ├── Resources │ ├── node_modules │ │ ├── some third party npm-packages │ │ └── … │ ├── package.json │ ├── Sources │ ├── webpack.config.js │ └── yarn.lock …
当使用 yaml-lint
命令扫描整个项目时,我从 node_modules 子目录中得到了一些错误。你当然应该验证这些错误消息,为第三方仓库创建几个 pull-request,在等待 pull-request 合并的同时修复你的本地文件 - 但说实话,在现实生活中你只需要一个 "绿色管道"。
示例
vandor/bin/yaml-linter src --excludePattern=thirdParty