Agent Skillszed-industries/zed › lint-creator

lint-creator

GitHub

指导在 tooling/lints 中添加、修改或测试自定义 dylint。涵盖模块布局、注册方式、UI 测试规范(含负向用例)、夜间版本测试运行及基于真实代码库的验证流程,适用于编写新 lint 或调试现有 lint 场景。

.agents/skills/lint-creator/SKILL.md zed-industries/zed

Trigger Scenarios

用户要求编写新的 dylint lint 用户要求调试现有的 dylint lint

Install

npx skills add zed-industries/zed --skill lint-creator -g -y
More Options

Non-standard path

npx skills add https://github.com/zed-industries/zed/tree/main/.agents/skills/lint-creator -g -y

Use without installing

npx skills use zed-industries/zed@lint-creator

指定 Agent (Claude Code)

npx skills add zed-industries/zed --skill lint-creator -a claude-code -g -y

安装 repo 全部 skill

npx skills add zed-industries/zed --all -g -y

预览 repo 内 skill

npx skills add zed-industries/zed --list

SKILL.md

Frontmatter
{
    "name": "lint-creator",
    "description": "Add, modify, or test a custom dylint lint in `tooling\/lints`. Covers the module\/registration layout, UI test conventions (including negative tests and the gpui test fixture), how to run tests with the crate's pinned nightly and update `.stderr` files, and how to validate a lint against the real codebase with `single-lint`. Use whenever the user asks to write a new lint or debug an existing one."
}

Adding a dylint to tooling/lints

Before writing anything

  1. Check whether clippy already covers the pattern (search https://rust-lang.github.io/rust-clippy/master/). If it does, stop and report that to the user instead of writing a redundant lint.

Layout

  • One module per lint: src/<lint_name>.rs, declared in src/lib.rs.
  • Register the lint in register_lints in src/lib.rs: add it to the lint_store.register_lints(&[...]) slice and add a register_late_pass call.
  • Use src/notify_in_render.rs as the template: rustc_session::declare_lint! with ### What it does / ### Why is this bad? doc sections, impl_lint_pass!, and a LateLintPass impl that bails early with let ... else / early returns.
  • Do NOT copy the diagnostics style of shared_string_from_str_literal in lib.rs — it predates the rules below (it emits a machine-applicable suggestion). The two lints living directly in lib.rs also predate the one-module-per-lint rule.
  • Reuse the helpers in src/render_helpers.rs (is_directly_in_render_method, is_gpui_context) for render/gpui checks.

Diagnostics rules

  • Flag only; never suggest how to fix, and never use Applicability::MachineApplicable.
  • Keep detection and reporting as simple as possible: prefer span_lint with a one-sentence message over span_lint_and_then with notes.
  • Skip macro-expanded code (expr.span.from_expansion()).

UI tests (required)

  • Every lint needs ui/<lint_name>.rs and ui/<lint_name>.stderr.

  • The .rs file must include negative cases: code that resembles the bad pattern but must produce no diagnostic. Their absence from the .stderr file is the assertion.

  • UI tests that need gpui types use the fake gpui crate in test_fixture/ (wired up by gpui_fixture_rustc_flags in lib.rs). Extend the fixture if a type or method is missing — never add real gpui as a dependency.

  • The crate is deliberately not part of the zed workspace and pins its own nightly (rust-toolchain.toml). Run tests from inside the crate:

    cd tooling/lints && cargo test
    
  • To update a .stderr file after an intentional change: run the test, find the Actual stderr saved to PATH line in the failure report, and copy that file over the checked-in .stderr. There is no bless env var. A correct .stderr typically ends with one blank line.

After the lint works

  • Add the lint to the "Current lints" list in tooling/lints/README.md.

  • Smoke-test it against the real codebase:

    tooling/lints/single-lint <lint_name> -p <crate>
    

    (defaults to --workspace if no package is given; the script handles the --force-warn and cache-cleaning gotchas documented in the README).

UI fixture sections

Every lint-specific ui/*.rs fixture MUST put cases expected to trigger the lint first, followed by cases expected not to trigger it, using exactly these headings:

// ==================== SHOULD FIRE ====================
// ================== SHOULD NOT FIRE ==================

Version History

  • 2890c34 Current 2026-08-29 04:31

    2026-08-27: 强制 UI 测试夹具使用明确的 SHOULD FIRE / SHOULD NOT FIRE 分区标记;此前重写技能文档使其更具体。

  • 4d1935b 2026-08-20 16:56

Same Skill Collection

.agents/skills/gpui-bench/SKILL.md
.agents/skills/gpui-test/SKILL.md
.agents/skills/zed-cherry-pick/SKILL.md
.factory/skills/brand-writer/SKILL.md
.factory/skills/humanizer/SKILL.md
crates/agent_skills/builtin/create-skill/SKILL.md
docs/.conventions/brand-writer/SKILL.md

Metadata

Files
0
Version
2890c34
Hash
a0cc7ba5
Indexed
2026-08-20 16:56

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-30 01:41
浙ICP备14020137号-1 $Гость$