跳转到内容

Lint & Export

用于检查设计和自动修复问题的工具

此分类共 2 个工具。

Run design linter on a node tree. Returns issues grouped by category with affected node IDs and fix instructions. Lint child nodes individually for large trees.

ParameterTypeRequiredDescription
nodeIdstringNode ID to lint. Omit to lint current selection.
rulesstring[]Rules to run. Default: ["all"]. Options: no-autolayout, shape-instead-of-frame, hardcoded-color, no-text-style, fixed-in-autolayout, default-name, empty-container, stale-text-name, no-text-property, all, wcag-contrast, wcag-contrast-enhanced, wcag-non-text-contrast, wcag-target-size, wcag-text-size, wcag-line-height, wcag
maxDepthnumberMax depth to recurse (default: 10)
maxFindingsnumberStop after N findings (default: 50)
JSON Schema
{
  "type": "object",
  "properties": {
    "nodeId": {
      "description": "Node ID to lint. Omit to lint current selection.",
      "type": "string"
    },
    "rules": {
      "description": "Rules to run. Default: [\"all\"]. Options: no-autolayout, shape-instead-of-frame, hardcoded-color, no-text-style, fixed-in-autolayout, default-name, empty-container, stale-text-name, no-text-property, all, wcag-contrast, wcag-contrast-enhanced, wcag-non-text-contrast, wcag-target-size, wcag-text-size, wcag-line-height, wcag",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "no-autolayout",
          "shape-instead-of-frame",
          "hardcoded-color",
          "no-text-style",
          "fixed-in-autolayout",
          "default-name",
          "empty-container",
          "stale-text-name",
          "no-text-property",
          "wcag-contrast",
          "wcag-contrast-enhanced",
          "wcag-non-text-contrast",
          "wcag-target-size",
          "wcag-text-size",
          "wcag-line-height",
          "wcag",
          "all"
        ]
      }
    },
    "maxDepth": {
      "description": "Max depth to recurse (default: 10)",
      "type": "number"
    },
    "maxFindings": {
      "description": "Stop after N findings (default: 50)",
      "type": "number"
    }
  }
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
nodeIdstring
nodeNamestring
categoriesobject[]
rulestringLint rule name
countnumber
fixstringHuman-readable fix instructions
nodesobject[]Affected nodes with rule-specific extra fields
idstring
namestring
warningstringPresent when results truncated
示例返回
{
  "nodeId": "1:2",
  "nodeName": "Card",
  "categories": [
    {
      "rule": "hardcoded-color",
      "count": 2,
      "fix": "Use set_fill_color with styleName or set_variable_binding.",
      "nodes": [
        {
          "id": "1:5",
          "name": "Background",
          "hex": "#3b82f6",
          "property": "fill",
          "matchType": "style",
          "matchName": "Primary/Blue"
        }
      ]
    }
  ]
}
返回值 JSON Schema
{
  "type": "object",
  "properties": {
    "nodeId": {
      "type": "string"
    },
    "nodeName": {
      "type": "string"
    },
    "categories": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "rule": {
            "type": "string",
            "description": "Lint rule name"
          },
          "count": {
            "type": "number"
          },
          "fix": {
            "type": "string",
            "description": "Human-readable fix instructions"
          },
          "nodes": {
            "type": "array",
            "description": "Affected nodes with rule-specific extra fields",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "warning": {
      "type": "string",
      "description": "Present when results truncated"
    }
  },
  "required": [
    "nodeId",
    "nodeName",
    "categories"
  ]
}
edit

Auto-fix: convert frames with multiple children to auto-layout. Takes node IDs from lint_node 'no-autolayout' results.

ParameterTypeRequiredDescription
itemsobject[]Array of frames to convert to auto-layout
nodeIdstringNode ID
layoutMode"HORIZONTAL" | "VERTICAL"Layout direction (default: auto-detect based on child positions)
itemSpacingnumberSpacing between children (default: 0)
depthnumberResponse detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.
JSON Schema
{
  "type": "object",
  "properties": {
    "items": {
      "description": "Array of frames to convert to auto-layout",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "nodeId": {
            "type": "string",
            "description": "Node ID"
          },
          "layoutMode": {
            "description": "Layout direction (default: auto-detect based on child positions)",
            "type": "string",
            "enum": [
              "HORIZONTAL",
              "VERTICAL"
            ]
          },
          "itemSpacing": {
            "description": "Spacing between children (default: 0)",
            "type": "number"
          }
        },
        "required": [
          "nodeId"
        ]
      }
    },
    "depth": {
      "description": "Response detail: omit for id+name only. 0=properties + child stubs. N=recurse N levels. -1=unlimited.",
      "type": "number"
    }
  },
  "required": [
    "items"
  ]
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
results(success | error)[]Per-item results.
layoutMode"VERTICAL" | "HORIZONTAL"
skippedbooleanTrue if node already has auto-layout
reasonstringReason for skipping
errorstringError message for this item
warningsstring[]Deduplicated warnings hoisted from individual results
示例返回
{
  "results": [
    {
      "layoutMode": "VERTICAL"
    },
    {
      "skipped": true,
      "reason": "Already has auto-layout"
    }
  ]
}
返回值 JSON Schema
{
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "description": "Per-item results.",
      "items": {
        "oneOf": [
          {
            "title": "success",
            "type": "object",
            "properties": {
              "layoutMode": {
                "type": "string",
                "enum": [
                  "VERTICAL",
                  "HORIZONTAL"
                ]
              },
              "skipped": {
                "type": "boolean",
                "description": "True if node already has auto-layout"
              },
              "reason": {
                "type": "string",
                "description": "Reason for skipping"
              }
            }
          },
          {
            "title": "error",
            "type": "object",
            "properties": {
              "error": {
                "type": "string",
                "description": "Error message for this item"
              }
            },
            "required": [
              "error"
            ]
          }
        ]
      }
    },
    "warnings": {
      "type": "array",
      "description": "Deduplicated warnings hoisted from individual results",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "results"
  ]
}