The Yell linter enforces structural rules and blocks anti-patterns in YAML.
The @yell/linter package validates Yell YAML documents against a set of rules designed to keep generated UI safe, predictable, and maintainable.
npm install @yell/linter
import { lint } from '@yell/linter';
const result = lint(yamlString);
if (!result.ok) {
console.error(result.errors);
}
Severity: error
Event handlers (onClick, onChange, etc.) must be named references — never inline functions.
# ✅ Valid
- type: Button
onClick: handleSubmit
# ❌ Invalid
- type: Button
onClick: () => setCount(count + 1)
Severity: error
Ternary expressions are not allowed in YAML. Use showWhen conditionals or separate nodes instead.
# ❌ Invalid
- type: Badge
showWhen: isAdmin ? true : false
# ✅ Valid
- type: Modal
showWhen: isOpen == true
Severity: error
Function calls are not allowed in expressions. Precompute values in event handlers.
# ❌ Invalid
- type: Text
showWhen: getStatus(user) == 'active'
# ✅ Valid
- type: Text
showWhen: user.isActive == true
Severity: warn
Warns when nesting depth exceeds 5 levels.
Severity: warn
Warns when any expression exceeds 100 characters.
import { lint } from '@yell/linter';
const result = lint(yamlString, {
maxNestingDepth: 8,
maxExpressionLength: 150,
rules: {
'no-inline-functions': { severity: 'error' },
'max-nesting-depth': { severity: 'warn' },
},
});