preflight
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesepreflight
preflight
Change-gated, branch-scoped lint preflight. It lints only the categories relevant
to , on changed paths only — not a whole-repo —
then classifies each violation as introduced (on a line this branch added or
changed) or pre-existing (already there, in a file the branch happens to
touch).
origin/<base>...HEADpnpm lintThis skill is the single source of truth for the preflight loop. It is invoked
two ways:
- Standalone () — a quick "will my branch pass scoped lint?" check, leaving any fixes in the working tree.
/preflight - Inside a ship flow (e.g. ) — the lint gate that runs after commits and before the changelog/push steps.
/send-it
All bundled scripts use only Node built-ins — no , no build step.
They operate on the consumer repo's root (run them from the repo root, where
resolves the branch diff).
npm installgit基于变更校验的、分支范围的Lint预检工具。它仅针对相关的类别,只在变更路径上执行Lint——而非全仓库的——然后将每个违规项分为新增(分支添加或修改的行)或已有(文件中原本就存在,只是分支恰好触及该文件)。
origin/<base>...HEADpnpm lint这个Skill是预检循环的唯一可信来源。它有两种调用方式:
- 独立运行()——快速检查“我的分支能否通过范围化Lint?”,修复内容留在工作区。
/preflight - 在发布流程中运行(例如)——作为Lint校验关卡,在提交后、变更日志/推送步骤前执行。
/send-it
所有捆绑脚本仅使用Node内置模块——无需,无需构建步骤。它们在使用该工具的仓库根目录运行(从仓库根目录执行,会解析分支差异)。
npm installgitRunning it
运行步骤
- Make sure the base branch is up to date: (the base is auto-detected — see Configuration).
git fetch origin <base> - Run the preflight: (append
node skills/preflight/scripts/preflight.mjsto report categories and scoped file lists without classifying violations).--dry-runis a true preview — every linter reports--dry-runand nothing is written, includingwould-run..preflight-summary.json - Read for the categories run and the violation counts (
.preflight-summary.json,passed,deferred). Written only on a real run, not underblocking. It is a transient scratch artefact, never committed — consumer repos gitignore it (the--dry-runskill adds the entry when it reconciles a repo).initialise-skills
The script's exit code drives the loop:
- Exit 0 — pass. No introduced violations and every linter ran cleanly. Continue.
- Exit 1 — introduced violations (blocking). Run
on the branch-scoped paths, then re-run preflight. Repeat until introduced violations clear or the user aborts. (Inside a ship flow, commit the fixes; standalone, leave them in the working tree for the user to review and commit.) Only introduced errors block by default — introduced ESLint warnings are reported as a non-blocking notice and don't fail the gate, matching
node skills/preflight/scripts/lint-fix.mjs/ CI (which exit 0 on warnings). Setpnpm lintto gate on them too (see Configuration).blockOnWarnings: true - Exit 2 — pre-existing violations only. Show the list and ask the user to
choose:
- Fix now — apply the fixes, (commit if shipping), re-run preflight.
- Defer — open a debt issue in the project's tracker (assign the maintainer; link the branch/PR context), then decide whether to continue or abort.
Exit 1 can also signal a linter that failed to run (non-zero exit with no
parseable violations) — inspect its stderr; this is blocking too.
- 确保基准分支是最新的:(基准分支会自动检测——见配置部分)。
git fetch origin <base> - 运行预检:(添加
node skills/preflight/scripts/preflight.mjs参数可报告类别和范围化文件列表,但不会分类违规项)。--dry-run是真实预览——每个Linter都会报告--dry-run,不会写入任何内容,包括would-run。.preflight-summary.json - 读取获取已运行的类别和违规计数(
.preflight-summary.json、passed、deferred)。仅在真实运行时写入,blocking模式下不会生成。这是一个临时文件,永远不会提交——使用该工具的仓库会忽略它(--dry-runSkill在协调仓库时会添加忽略条目)。initialise-skills
脚本的退出码驱动循环:
- 退出码0——通过。没有新增违规,所有Linter运行正常。继续流程。
- 退出码1——新增违规(阻塞)。在分支范围路径上运行,然后重新运行预检。重复直到新增违规清除或用户中止。(在发布流程中,提交修复;独立运行时,修复内容留在工作区供用户审核和提交。)默认情况下仅新增_错误_会阻塞——新增的ESLint警告会作为非阻塞通知报告,不会导致校验关卡失败,与
node skills/preflight/scripts/lint-fix.mjs/CI的行为一致(警告时退出码为0)。如果需要也拦截警告,设置pnpm lint(见配置部分)。blockOnWarnings: true - 退出码2——仅存在已有违规。显示列表并让用户选择:
- 立即修复——应用修复,(如果是发布流程则提交),重新运行预检。
- 延迟处理——在项目跟踪器中创建一个债务问题(分配给维护者;关联分支/PR上下文),然后决定继续还是中止。
退出码1也可能表示Linter运行失败(非零退出且无可解析的违规)——检查其stderr;这也会阻塞流程。
Categories
类别
Each category is gated on what the branch changed (mirrors CI path triggers,
narrower scope):
| Category | Runs when | Skipped when |
|---|---|---|
| ESLint | Branch diff includes lintable code or eslint/tsconfig config paths | Markdown-only or non-lintable changes |
| markdownlint | Branch diff includes | No markdown changes; warns and skips if the |
| actionlint | Branch diff includes | No workflow changes; config-only changes lint all tracked workflows; warns and skips if |
ESLint runs per workspace (via ), plus a root/scripts bucket.
Typecheck, tests, and framework checks (e.g. ) are not part of
preflight — they stay in CI.
pnpm --filterastro check每个类别是否执行取决于分支的变更内容(镜像CI路径触发器,范围更窄):
| 类别 | 执行时机 | 跳过时机 |
|---|---|---|
| ESLint | 分支差异包含可Lint的代码或eslint/tsconfig配置路径时 | 仅Markdown变更或不可Lint的变更时 |
| markdownlint | 分支差异包含 | 无Markdown变更;如果 |
| actionlint | 分支差异包含 | 无工作流变更;仅配置变更时会Lint所有已跟踪的工作流;如果 |
ESLint按工作区运行(通过),加上根目录/脚本目录。类型检查、测试和框架检查(例如)不属于预检的一部分——它们留在CI中执行。
pnpm --filterastro checkStandalone vs inside a ship flow
独立运行 vs 发布流程中运行
- Standalone () does the lint preflight and the exit-code loop, then reports. On introduced violations it may run
/preflightand re-run, but it leaves fixes in the working tree — it never commits, writes a changelog, pushes, or opens a PR.node skills/preflight/scripts/lint-fix.mjs - Inside the same loop runs as the lint gate (after commits, before changelog work); fixes are committed so the branch is clean before the changelog is written. The changelog and its validation are separate gates owned by the ship flow — they are not part of this skill.
/send-it
- 独立运行()执行Lint预检和退出码循环,然后报告结果。如果有新增违规,它可能会运行
/preflight并重新运行,但修复内容留在工作区——它永远不会提交、写入变更日志、推送或打开PR。node skills/preflight/scripts/lint-fix.mjs - 在中运行时,同样的循环作为Lint校验关卡运行(提交后、变更日志编写前);修复内容会被提交,以便分支在编写变更日志前保持干净。变更日志及其验证是发布流程独立的校验关卡——不属于本Skill的一部分。
/send-it
Configuration
配置
The two repo-specific inputs are auto-detected — a consuming repo edits nothing in
the common case:
- Linted workspaces are derived from plus each package's
pnpm-workspace.yaml: a workspace is included only if it declares apackage.jsonscript. This auto-excludes intentionally-unlinted workspaces and non-package directories without a hand-maintained list.lint - Base branch is detected from (e.g.
origin/HEAD,main,master), falling back todevelopwhen that symbolic ref is absent.main
To override either, add a at the consumer repo root
(a ships beside this file as a
template):
preflight.config.jsonconfig.example.jsonjson
{
"baseBranch": "main",
"blockOnWarnings": false,
"workspaces": {
"web": { "filter": "@acme/web", "prefix": "apps/web/" }
}
}Any key may be supplied on its own; the others are still auto-detected/defaulted.
Use the override for non-pnpm repos, deliberate exclusions, or nested workspace
globs the detector does not expand.
- (default
blockOnWarnings) — whether introduced ESLint warning-severity findings block the gate. Off by default, preflight blocks only on introduced errors (and linters that fail to run); introduced warnings are surfaced non-blockingly, matchingfalse/ CI semantics. Setpnpm lintfor repos that want warn-level findings the branch adds to gate as well. markdownlint/actionlint findings always block — the warn/error split is ESLint-only.true
两个仓库特定的输入会自动检测——一般情况下使用该工具的仓库无需编辑任何内容:
- Lint工作区从以及每个包的
pnpm-workspace.yaml派生:只有声明了package.json脚本的工作区才会被包含。这会自动排除有意不Lint的工作区和没有lint的非包目录,无需手动维护列表。package.json - 基准分支从检测(例如
origin/HEAD、main、master),如果该符号引用不存在则回退到develop。main
要覆盖任意一项,在使用该工具的仓库根目录添加(本文件附带一个作为模板):
preflight.config.jsonconfig.example.jsonjson
{
"baseBranch": "main",
"blockOnWarnings": false,
"workspaces": {
"web": { "filter": "@acme/web", "prefix": "apps/web/" }
}
}可以只提供任意一个键;其他键仍会自动检测/使用默认值。对于非pnpm仓库、有意排除的工作区,或者检测器无法展开的嵌套工作区通配符,使用覆盖配置。
- (默认
blockOnWarnings)——新增的ESLint警告级别的发现是否会阻塞校验关卡。默认关闭,预检仅拦截新增的错误(以及运行失败的Linter);新增的警告会以非阻塞方式显示,与false/CI的语义一致。如果仓库希望分支新增的警告级发现也触发校验关卡拦截,设置为pnpm lint。markdownlint/actionlint的发现始终会阻塞——仅ESLint区分警告/错误。true
Implementation
实现细节
The bundled scripts live beside this file under
and are invoked directly with — no aliases,
no :
scripts/nodepnpmnpm install- — the change-gated preflight and exit-code contract.
scripts/preflight.mjs - — scoped
scripts/lint-fix.mjs/eslint --fixon the branch-changed paths.markdownlint-cli2 --fix - — parse + classify violations as introduced vs pre-existing.
scripts/classify-lint.mjs - — shared helpers (workspace/base-branch detection, diff-line mapping, path normalisation).
scripts/lib/{scope,diff-lines,paths}.mjs
They have no external npm dependencies (Node built-ins only).
捆绑的脚本位于本文件旁边的目录下,直接用调用——无需pnpm别名,无需:
scripts/nodenpm install- ——基于变更的预检和退出码约定。
scripts/preflight.mjs - ——对分支变更路径执行范围化的
scripts/lint-fix.mjs/eslint --fix。markdownlint-cli2 --fix - ——解析并将违规分类为新增或已有。
scripts/classify-lint.mjs - ——共享辅助工具(工作区/基准分支检测、差异行映射、路径规范化)。
scripts/lib/{scope,diff-lines,paths}.mjs
它们没有外部npm依赖(仅使用Node内置模块)。
Arguments
参数
$ARGUMENTS
$ARGUMENTS