1 Star 0 Fork 0

吉良吉影/MoreLINQ

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
eclint.ps1 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
Atif Aziz 提交于 2023-01-30 04:37 +08:00 . Dynamically discover/build glob for ECLint (#957)
[CmdletBinding(DefaultParameterSetName='Default')]
param (
[Parameter(ParameterSetName='Default')]
[switch]$TrimTrailingWhitespace,
[Parameter(ParameterSetName='Default')]
[switch]$InsertFinalNewline,
[Parameter(Mandatory=$true, ParameterSetName='ShowGlob')]
[switch]$ShowGlob
)
$ErrorActionPreference = 'Stop'
$exts =
git ls-files --eol | # get versioned file paths with line endings
? { $_ -notmatch '/-text\b' } | # exclude binary files
% { ($_ -split '\t', 2)[1] } | # get file path
Split-Path -Extension | # get file extension
? { $_.Length -gt 1 } | # exclude those without an extension
Sort-Object | # sort alphabetically
Select-Object -Unique | # remove duplicates
% { $_.Substring(1) } # remove leading dot
$glob = "**/*.{$($exts -join ',')}"
if ($PSCmdlet.ParameterSetName -eq 'ShowGlob') {
Write-Output $glob
return
}
if (-not (Get-Command eclint -ErrorAction SilentlyContinue)) {
throw 'ECLint is not installed. To install, run: npm install -g eclint'
}
$rules = @()
if ($trimTrailingWhitespace) {
$rules += '--trim_trailing_whitespace'
}
if ($insertFinalNewline) {
$rules += '--insert_final_newline'
}
$rules | % {
Write-Verbose "eclint check $rule $glob"
# https://github.com/jednano/eclint
eclint check $_ $glob
if ($LASTEXITCODE) {
throw "eclint terminated with a non-zero exit code ($LASTEXITCODE)."
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hopefsharp/MoreLINQ.git
git@gitee.com:hopefsharp/MoreLINQ.git
hopefsharp
MoreLINQ
MoreLINQ
master

搜索帮助