Lint
运行设计质量和无障碍检查。
Type reference
// Lint runs automated design quality and accessibility checks on a node tree.// ---// Rules: "all" (default), or filter by category or specific rule names.// Category meta-rules (expand to all rules in that category):// "component" — component property binding checks// "composition" — layout and positioning checks// "token" — design token / style usage checks// "naming" — layer naming checks// "wcag" / "accessibility" — all WCAG accessibility checks// ---// Severity levels (output is sorted by severity, highest first):// "error" — definite bug, must fix// "unsafe" — likely causes layout/accessibility problems// "heuristic" — probably worth fixing, context-dependent// "style" — opinionated, nice-to-have (leaf nodes, decorative elements often downgraded here)// Context-aware: leaf nodes (text, shapes, small frames) are treated differently from containers.// Small labels with HUG sizing, leaf nodes on cross-axis — downgraded to "style" instead of "heuristic".// Per-finding severity overrides appear on individual nodes when context changes the default.// ---// Component rules [component]:// "no-text-property" — component text not exposed as editable property [heuristic]// "component-bindings" — unbound text, orphaned properties, unexposed nested text [heuristic; orphaned→unsafe, nested→style]// Composition rules [composition]:// "no-autolayout" — frames with manually positioned children [heuristic; leaf-only containers→style]// "overlapping-children" — children stacked at same position [heuristic]// "shape-instead-of-frame" — shapes used as containers [style]// "fixed-in-autolayout" — FIXED-size children in auto-layout parents [heuristic]// "unbounded-hug" — HUG on both axes [unsafe; short leaf text→style]// "hug-cross-axis" — HUG on cross-axis of constrained parent [heuristic; leaf nodes→style]// "empty-container" — empty frames, excludes SLOT nodes [style]// Token rules [token]:// "hardcoded-color" — colors not using styles or variables [heuristic]// "hardcoded-token" — numeric values not bound to FLOAT variable [heuristic]// "no-text-style" — text without a text style [heuristic]// Naming rules [naming]:// "default-name" — default names like "Frame 1" [style]// "stale-text-name" — text node name doesn't match content [style]// Accessibility rules [wcag]:// "wcag-contrast" — AA contrast ratio [unsafe]// "wcag-contrast-enhanced" — AAA contrast ratio [style]// "wcag-non-text-contrast" — non-text 3:1 contrast [heuristic]// "wcag-target-size" — targets below 24x24px [unsafe]// "wcag-text-size" — text below 12px [unsafe]// "wcag-line-height" — line height below 1.5x [style]// ---// maxDepth limits how deep the tree traversal goes (default: 10). maxFindings caps total findings (default: 50).// fix: auto-converts frames to auto-layout. Use after lint.check identifies "no-autolayout" issues.2 methods available.
Run design linter on a node tree
| Parameter | Type | Required | Description |
|---|---|---|---|
nodeId | string | ✗ | Node ID to lint. If omitted: 1 selected node → lints that node, 2+ selected → lints entire page (not the selection), 0 selected → error. Always pass nodeId explicitly for reliable targeting. |
rules | string[] | ✗ | Rules to run. Default: ["all"]. Categories: "component", "composition", "token", "naming", "wcag"/"accessibility". Or specific rule names. |
maxDepth | number | ✗ | Max tree depth (default: 10) |
maxFindings | number | ✗ | Max findings (default: 50) |
minSeverity | "error" | "unsafe" | "heuristic" | "style" | "verbose" | ✗ | Minimum severity to report (default: style). Set to 'verbose' to include AAA contrast and line-height checks. |
skipInstances | boolean | ✗ | Skip instance internals — findings inside instances are owned by the component (default: true) |
Response
| Field | Type | Description |
|---|---|---|
nodeId | string | |
nodeName | string | |
categories | object[] | Sorted by severity (error > unsafe > heuristic > style) |
↳ rule | string | |
↳ severity | string | error | unsafe | heuristic | style |
↳ category | string | component | composition | token | accessibility | naming |
↳ count | number | |
↳ fix | string | |
↳ nodes | object[] | |
↳ id | string | |
↳ name | string | |
↳ severity | string | Per-finding override when context changes the default |
warning | string |
Auto-fix frames to auto-layout
| Parameter | Type | Required | Description |
|---|---|---|---|
items | object[] | ✓ | Array of {nodeId, layoutMode?, itemSpacing?} |
↳ nodeId | string | ✓ | Frame node ID |
↳ layoutMode | "VERTICAL" | "HORIZONTAL" | ✗ | Direction (default: auto-detected) |
↳ itemSpacing | number | ✗ | Spacing between children |
depth | number | ✗ | Response detail for fixed nodes: omit for stubs, 0=properties, -1=full tree |
Response
| Field | Type | Description |
|---|---|---|
results | any[] | Array of "ok" or {error} per item |