lint

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Lint

代码检查与格式化

Tooling

工具选择

Prefer lintro for linting and formatting. When available, use
uv run lintro chk
and
uv run lintro fmt
.
If lintro is unavailable, fall back to the language's native bundled tools (ruff, black, clippy, rustfmt, eslint, bandit, etc.). Another skill may document an additional pass after lintro (for example,
raycast
runs
npm run lint
after lintro — Raycast rules take precedence for extension-specific checks).
优先使用lintro进行代码检查与格式化。当lintro可用时,使用
uv run lintro chk
uv run lintro fmt
命令。
若lintro不可用,则使用对应语言的原生工具(ruff、black、clippy、rustfmt、eslint、bandit等)作为备选。部分技能文档可能要求在lintro之后执行额外检查步骤(例如,
raycast
会在lintro之后运行
npm run lint
——针对扩展的特定检查需优先遵循Raycast规则)。

Commands

命令说明

  • uv run lintro fmt
    — format code
  • uv run lintro chk
    — check code for issues
  • uv run lintro tst
    — run tests
  • uv run lintro fmt
    — 格式化代码
  • uv run lintro chk
    — 检查代码问题
  • uv run lintro tst
    — 运行测试

Rules

规则要求

  • CRITICAL: NEVER run
    lintro chk --tools ...
    (targeted/filtered checks).
    Always run the full
    uv run lintro chk
    without
    --tools
    . Filtered runs silently skip tools and miss issues.
    • Exception: single-tool runs (
      --tools <tool>
      ) are permitted only when developing or verifying that specific lintro tool (the
      /lintro-add
      and
      /lintro-verify
      workflows). Even then, a full
      uv run lintro chk
      is still required before committing.
  • Linting must produce zero issues before proceeding
  • Fix ALL issues — whether introduced in the current session or pre-existing
  • Ignore policy — suppressing a finding is not a fix:
    1. Fix the root cause first.
      # noqa
      ,
      # type: ignore
      ,
      # nosec
      ,
      # nosemgrep
      ,
      # yamllint disable-line
      , etc. are a LAST resort, only when there is no reasonable fix.
    2. If suppression is genuinely required, use the narrowest possible ignore — specific rule code, single line — WITH an inline justification comment (
      # nosec B603 - fixed argv list, no shell
      ). Unjustified ignores are rejected.
    3. Blanket or file-level ignores (whole-file disables, config-wide excludes) require a documented exception (e.g. in
      CONTRIBUTING.md
      ).
  • 重要警告:禁止运行
    lintro chk --tools ...
    (针对性/过滤式检查)。
    始终运行完整的
    uv run lintro chk
    命令,不得添加
    --tools
    参数。过滤式检查会静默跳过部分工具,导致遗漏问题。
    • 例外情况: 仅在开发或验证特定lintro工具(
      /lintro-add
      /lintro-verify
      工作流)时,允许运行单工具检查(
      --tools <tool>
      )。即便如此,提交代码前仍需运行完整的
      uv run lintro chk
      检查。
  • 代码检查必须确保零问题后,才能继续后续操作
  • 修复所有问题——无论是当前会话引入的还是预先存在的
  • 忽略规则——抑制问题提示不等于修复:
    1. 优先修复根本原因。
      # noqa
      # type: ignore
      # nosec
      # nosemgrep
      # yamllint disable-line
      等忽略注释仅作为最后手段,仅在无合理修复方案时使用。
    2. 若确实需要抑制提示,请使用范围最窄的忽略方式——指定规则代码、仅针对单行——并添加行内说明注释(例如
      # nosec B603 - fixed argv list, no shell
      )。无合理说明的忽略将被拒绝。
    3. 全局或文件级忽略(禁用整个文件、配置全局排除)需有文档记录的例外说明(例如在
      CONTRIBUTING.md
      中)。

Usage

使用流程

When asked to lint or format code:
  1. Run
    uv run lintro fmt
    FIRST to auto-fix formatting issues across the ENTIRE codebase (when lintro is available)
  2. Run
    uv run lintro chk
    to check for remaining issues (when lintro is available)
  3. If lintro is unavailable, use native tooling for the language and still aim for zero issues
  4. Manually fix any issues found — do not leave issues unfixed
  5. Re-run the check command to verify all fixes
  6. Only as a last resort, add ignore comments WITH justification
当需要进行代码检查或格式化时:
  1. 首先运行
    uv run lintro fmt
    ,自动修复整个代码库中的格式化问题(当lintro可用时)
  2. 运行
    uv run lintro chk
    检查剩余问题(当lintro可用时)
  3. 若lintro不可用,使用对应语言的原生工具,仍需确保零问题
  4. 手动修复所有发现的问题——不得遗留未修复的问题
  5. 重新运行检查命令,验证所有修复是否完成
  6. 仅作为最后手段,添加带有说明的忽略注释