#lint #linter #diff #git #staged #config-file

app lint-emit

对 git 差分进行 Lint 检查!

4 个版本

0.3.3 2019 年 2 月 19 日
0.3.2 2019 年 2 月 18 日
0.3.1 2019 年 2 月 17 日
0.3.0 2019 年 2 月 17 日

#11 in #staged

MIT 许可证

34KB
528 代码行

此工具旨在在兼容 git 的提交范围内运行多个 linters。

灵感来自 lint-difflint-staged

linters 是强制执行代码样式的优秀工具,但它有一些限制:它只能对整个文件进行 linters。
当与遗留代码一起工作时,我们经常需要对非常大的文件进行更改(修复所有 lint 错误将会非常麻烦)
因此,最好只对更改的行进行 lint,而不是整个文件。

lint-emit 接收一个提交范围,并使用指定的 linters 对更改的文件进行 lint,并过滤出提交范围内引入的错误(以及其他内容)。

配置

您可以通过编辑用户路径中找到的配置文件来添加 linter。

  • Linux: /home/alice/.config/lint-emit
  • Windows: C:\Users\Alice\AppData\Roaming\ragone\lint-emit
  • macOS: /Users/Alice/Library/Preferences/io.ragone.lint-emit

如果找不到配置文件,您将被提示选择要添加的默认 linters。

[[linters]]                                                                                                                                                                 
name = "eslint"                                                                                                                                                             
cmd = "eslint"                                                                                                                                                              
args = ["{file}", "-f=compact"]                                                                                                                                             
regex = '(?P<file>.*): line (?P<line>\d*), col \d*, (?P<message>.*)'                                                                                                        
ext = ["js", "jsx"]                                                                                                                                                         

安装

cargo install lint-emit

用法

检查最后一个提交

$ lint-emit HEAD^..HEAD                                                                                                                                                     

检查最后 3 个提交

$ lint-emit HEAD~3..HEAD                                                                                                                                                    

检查尚未提交的本地更改

$ lint-emit HEAD                                                                                                                                                            
# or                                                                                                                                                                        
$ lint-emit                                                                                                                                                                 

使用 phpmdphpcs 进行 lint

$ lint-emit --linters phpmd phpcs                                                                                                                                           

依赖项

~8–17MB
~222K SLoC