代码拉取完成,页面将自动刷新
[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)."
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。