Recipe XML Linter
A VS Code extension that provides linting and navigation for XML recipe files to identify and highlight common issues.
Features
🔍 Linting & Error Detection
This linter identifies the following issues in recipe XML files:
- Missing Goto Targets: Detects when
onfail="goto:TARGET"
or onpass="goto:TARGET"
references a target that doesn't exist
- Name-Anchor Mismatches: Warns when a test's
name
attribute differs from its anchor
attribute
- Missing Anchors: Identifies tests that are referenced in goto statements but lack anchor attributes
- Missing Return Code Checks: Warns when scripts are executed without
checkReturnCode="Yes"
🧭 Navigation & IntelliSense
Go to Definition (F12): Navigate directly to:
- Goto targets (
onfail="goto:TARGET"
→ jumps to anchor="TARGET"
)
- Recipe references (
command="recipe:module::path"
→ jumps to recipe file)
- Script references (
{{module::script.sh}}
→ opens the script file)
- Cross-file navigation across your entire workspace
Hover Information: Rich tooltips showing:
- Target test information for goto references
- Recipe module and file information
- Script file details and locations
- "Click to highlight, then press F12" instructions
- Error details for broken references
Installation
- Copy the
recipe-linter
folder to your VS Code extensions directory
- Run
npm install
in the extension folder
- Run
npm run compile
to build the extension
- Restart VS Code or reload the window
Configuration
Add these settings to your VS Code settings.json
:
{
"files.associations": {
"compute_recipe_*.xml": "recipe-xml",
"**/recipes/**/*.xml": "recipe-xml"
},
"recipeXmlLinter.enabled": true,
"recipeXmlLinter.checkMissingGotos": true,
"recipeXmlLinter.checkNameAnchorMismatch": true,
"recipeXmlLinter.checkMissingAnchors": true,
"recipeXmlLinter.checkReturnCodes": true,
"recipeXmlLinter.enableGoToDefinition": true,
"recipeXmlLinter.enableHover": true,
"recipeXmlLinter.searchInWorkspace": true,
"recipeXmlLinter.filePattern": "**/recipes/**/*.xml"
}
Settings
recipeXmlLinter.enabled
: Enable/disable the linter (default: true)
recipeXmlLinter.checkMissingGotos
: Check for missing goto targets (default: true)
recipeXmlLinter.checkNameAnchorMismatch
: Check for name-anchor mismatches (default: true)
recipeXmlLinter.checkMissingAnchors
: Check for missing anchors (default: true)
recipeXmlLinter.checkReturnCodes
: Check for missing return code checks (default: true)
recipeXmlLinter.enableGoToDefinition
: Enable F12 go-to-definition for goto and recipe references (default: true)
recipeXmlLinter.enableHover
: Enable hover tooltips for goto and recipe references (default: true)
recipeXmlLinter.searchInWorkspace
: Search for anchors and recipes across the entire workspace (default: true)
recipeXmlLinter.filePattern
: File pattern to match recipe XML files (default: "/recipes//*.xml")
Example Issues Detected
Missing Goto Target
<test name="TEST1" onfail="goto:NONEXISTENT_TARGET">
<!-- Error: Missing goto target 'NONEXISTENT_TARGET' -->
Name-Anchor Mismatch
<test name="TEST_NAME" anchor="DIFFERENT_ANCHOR">
<!-- Warning: Name-anchor mismatch -->
Missing Anchor
<test name="BOOT_TO_OS_INIT" onfail="goto:MISSING_ANCHOR_TEST">
<test name="MISSING_ANCHOR_TEST" command="...">
<!-- Error: Missing anchor for referenced test -->
Missing Return Code Check
<test name="SCRIPT_TEST" command="{{DIR_SCRIPTS}}/test.sh">
<!-- Warning: Should have checkReturnCode="Yes" -->
Navigation Features
F12 Go to Definition
Press F12 on any of these elements to navigate:
Goto References
<test name="TEST1" onfail="goto:BOOT_TO_OS_INIT">
<!-- F12 here jumps to anchor="BOOT_TO_OS_INIT" -->
Recipe References
<test name="INIT" command="recipe:server_fla::stage/initialize_variables">
<!-- F12 here finds the recipe file -->
Script References
<test name="RUN_SCRIPT" command="{{server_fla_config_gb200::run_onediag_FCT.sh}} {{PYTHON}}">
<!-- F12 here opens the script file -->
Cross-File Navigation
- Jump to anchors in other recipe files within your workspace
- Automatically searches common module patterns
- Works with both local and workspace-wide references
Hover over goto or recipe references to see:
- Target Information: Shows the destination test or recipe details
- Location: File and line number of the target
- Status: Whether the reference is valid or broken
- Quick Actions: "Press F12 to go to definition" hints
Goto Reference:
<test name="VERIFY_DUT_BMC_BOOT" anchor="VERIFY_DUT_BMC_BOOT">
📍 Location: Line 24 (current file)
🔗 Press F12 to go to definition
Recipe Reference:
recipe:server_fla::stage/initialize_variables
📁 Module: server_fla
📄 Recipe: stage/initialize_variables
📍 Location: initialize_variables.xml
🔗 Click to highlight recipe, then press F12 to go to definition
Script Reference:
run_onediag_FCT.sh
📜 Script File
📁 Module: server_fla_config_gb200
📄 Script: run_onediag_FCT.sh
📍 Location: run_onediag_FCT.sh
🔗 Click to highlight script, then press F12 to open script
Development
To modify or extend the linter:
- Edit
src/linter.ts
to add new linting rules
- Update
src/extension.ts
to modify activation behavior
- Run
npm run compile
to build
- Test with VS Code Extension Development Host
File Structure
recipe-linter/
├── package.json # Extension manifest
├── tsconfig.json # TypeScript configuration
├── language-configuration.json # Language support
├── src/
│ ├── extension.ts # Main extension entry point
│ └── linter.ts # Linting logic
└── README.md # This file