lint

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Run linting tools on shell scripts and GitHub Actions workflows in this project.
对本项目中的Shell脚本和GitHub Actions工作流运行代码检查工具。

Your Task

你的任务

Run the following checks on changed files (relative to main branch):
针对相对于main分支的变更文件,运行以下检查:

1. Shell Scripts (shellcheck)

1. Shell脚本(shellcheck)

bash
undefined
bash
undefined

Find changed shell scripts

查找变更的Shell脚本

changed_scripts=$(git diff --name-only main...HEAD 2>/dev/null | grep -E '.sh$')
changed_scripts=$(git diff --name-only main...HEAD 2>/dev/null | grep -E '.sh$')

Run shellcheck on each

对每个脚本运行shellcheck

for script in $changed_scripts; do if [[ -f "$script" ]]; then shellcheck -f gcc "$script" fi done
undefined
for script in $changed_scripts; do if [[ -f "$script" ]]; then shellcheck -f gcc "$script" fi done
undefined

2. GitHub Actions Workflows (actionlint)

2. GitHub Actions工作流(actionlint)

bash
undefined
bash
undefined

Find changed workflow files

查找变更的工作流文件

changed_workflows=$(git diff --name-only main...HEAD 2>/dev/null | grep -E '.github/workflows/.*.ya?ml$')
changed_workflows=$(git diff --name-only main...HEAD 2>/dev/null | grep -E '.github/workflows/.*.ya?ml$')

Run actionlint on each

对每个工作流运行actionlint

for workflow in $changed_workflows; do if [[ -f "$workflow" ]]; then actionlint "$workflow" fi done
undefined
for workflow in $changed_workflows; do if [[ -f "$workflow" ]]; then actionlint "$workflow" fi done
undefined

Handling Issues

问题处理

When lint issues are found:
  1. Fix the issues - Correct the code to resolve warnings/errors
  2. Only use disable directives as a last resort - If a warning is a false positive or truly unavoidable, add a disable comment with explanation:
    bash
    # shellcheck disable=SC2034  # Variable used by sourcing script
  3. Report what was fixed - Summarize the changes made
当发现代码检查问题时:
  1. 修复问题 - 修正代码以解决警告/错误
  2. 仅在万不得已时使用禁用指令 - 如果警告是误报或确实无法避免,请添加带有解释的禁用注释:
    bash
    # shellcheck disable=SC2034  # Variable used by sourcing script
  3. 报告修复内容 - 总结所做的变更

Optional Guidance

可选指导

$ARGUMENTS
$ARGUMENTS