Skip to content

Rules ​

The 9 smart-forms/ rules, and the blocks each one is built from. Each rule has its own page in the rules library, with what it checks, an example form and its lint cases.

Every rule works the same way. It reads the selected versions, finds the expressions a Smart Forms component actually reads, compares what that component does, from the facts, with what the form expects, from core's analysis, and reports where they differ. A rule never runs Smart Forms or evaluates an expression.

When it cannot tell, it stays silent. If core has no analysis for a site, for example because the text does not parse, the rule reports nothing there. It also leaves a problem to the core rule that reports the same cause; for example, a reference-only expression is sdc/external-expression's.

RuleSeverityReportsBuilt from
unsupported-expression-languageerrorAn expression Smart Forms ignores because of its languageSite eligibility, language facts
expression-evaluated-as-fhirpatherrorAn expression Smart Forms evaluates as FHIRPath, whatever its languageSite eligibility
questionnaire-variable-unavailableerrorA reference to %questionnaire or %qitem, which Smart Forms does not supplySite eligibility, name facts, core's references
unsupported-query-embeddingerrorA {{…}} embedding in an x-fhir-query that population does not fill as writtenSite eligibility, embedding facts, sourceQueries and launchContext readers
variable-name-collisionerrorA name declared on two elements, or named like a sourceQueries result, which Smart Forms stores as one valuePopulation model, stored names, variable facts
repeating-group-variablewarningA variable on or below a repeating group whose value differs between repetitions, of which Smart Forms keeps oneSite eligibility, variable facts, core's uses
named-expression-not-referenceableerrorA reference to a named expression Smart Forms does not make available, or a name an answerExpression cannot getSite eligibility, Population model, stored names, prerequisites, launchContext reader
forward-variable-referencewarningA variable that references a variable or itemPopulationContext population evaluates after itSite eligibility, Population model, core's dependencies
unsupported-template-extract-contexterrorA templateExtractContext written as a valueExpression, which template extraction ignoresTemplate reader, extraction facts. Runs only when template-extract is selected.

Findings of plugin rules can be suppressed like any other, but a suppression is never judged stale just because the rule reported nothing: only built-in rules record where they completed a check. See Suppressions and fingerprints.

Schema ​

Code ​

In packages/plugin-smart-forms/src/rules/:

  • one file per rule, named after it, such as variable-name-collision.ts. Each has meta: its description, default severity and the documentation sdc-lint explain prints.
  • language-sites.ts: which sites the rules that report at an expression check.

The lint cases are in test/cases/: a folder per rule, and source-queries for the supplied names. Adding a rule explains how to add one, and each slice of the design plan records why a rule works the way it does.