Skip to content

lintAsl

function lintAsl(params): LintDiagnostic[];

Defined in: src/lint.ts:300

Lint an ASL definition and return every finding, instead of throwing on the first.

Runs the same structural traversal as validateAsl (every fault that would make the render path throw comes back as an error), plus rules a definition can violate while still rendering (most of them also rejected by Step Functions itself):

code severity rule
unreachable-state warning no path from the scope’s StartAt reaches the state
missing-transition error a non-terminal state has neither Next nor End: true, or a Choices[] rule or Catch[] entry has no Next
dangling-transition error StartAt / Next / Default / Choices[].Next / Catch[].Next names a state missing from its scope
choice-without-choices error a Choice has no Choices, or an empty array
choice-without-default warning a Choice has no Default
duplicate-state-name warning a state name is reused in another States block
end-with-next error End: true together with Next
unsupported-transition error Next or End on a Choice, Succeed or Fail state
wait-without-duration error a Wait sets none of Seconds, SecondsPath, Timestamp, TimestampPath
wait-multiple-durations error a Wait sets more than one of those four fields
fail-conflicting-fields error a Fail sets both Error and ErrorPath, or both Cause and CausePath
state-name-too-long error a state name is longer than 80 characters (counted in Unicode code points)
unsupported-retry-catch error Retry / Catch on a Pass, Wait, Choice, Succeed or Fail state
query-language-mismatch error a JSONPath-only field (InputPath, Parameters, ResultPath, …) in a JSONata state, or Arguments / Output / Items in a JSONPath state, judged by the resolved QueryLanguage

Structural codes (invalid-structure, invalid-state-type, invalid-field, missing-transition) mirror validateAsl’s messages one to one. A string that is not valid JSON yields a single invalid-json error.

LintAslParams

Object parameters

LintDiagnostic[]

Diagnostics in traversal order; empty when the definition is clean

const diagnostics = lintAsl({ definition: asl });
const errors = diagnostics.filter((diagnostic) => diagnostic.severity === 'error');
for (const { path, code, message } of diagnostics) {
console.log(`${path} [${code}] ${message}`);
}