Skip to content

Smart Forms plugin ​

The @aehrc/sdc-questionnaire-lint-plugin-smart-forms package, packages/plugin-smart-forms, reports where Smart Forms behaves differently from SDC, in the Smart Forms versions you select. For example, it reports an expression Smart Forms ignores, one it evaluates in the wrong language, or a reference to a variable it never supplies. It also gives core the names Smart Forms binds to a form's sourceQueries results, so sdc/undefined-variable accepts them.

Its rules never run Smart Forms code or evaluate an expression. They reason from core's analysis of the form and from runtime facts: what each Smart Forms version does, recorded in the plugin and backed by tests against the published packages. They assume the form is populated with sdc-populate and then rendered, as the Smart Forms app does.

The plugin is turned on by listing it in an .mjs config:

js
// sdc-questionnaire-lint.config.mjs
import { defineConfig } from '@aehrc/sdc-questionnaire-lint';
import smartForms from '@aehrc/sdc-questionnaire-lint-plugin-smart-forms';

export default defineConfig({ plugins: [smartForms] });

The plugin README covers installing it, choosing versions, the names it supplies and suppressions. The rules library has a page for each of its rules.

Where it fits in a run ​

Core owns the run: it checks the plugin and selects the versions, analyses each form, runs the rules and builds the report. The plugin owns only what it knows about Smart Forms. How the plugin is embedded in a run in the design plan has the full picture.

Blocks ​

#BlockCodeWhat it does
1Entry and compatindex.ts, facts/versions.tsRegisters the rules and the Smart Forms versions the plugin has verified; a rule reads the selected ones
2Runtime factsfacts/Records how each Smart Forms version behaves: languages, names, embeddings, variable storage, sourceQueries, extraction
3Site eligibilityeligibility.ts, facts/prerequisites.tsWorks out which Smart Forms component reads an expression, and under what conditions
4Population modelpopulation.ts, stored-names.tsWorks out what population binds, under which name, and in what order
5Form readerssource-queries.ts, launch-contexts.ts, templates.ts, document.tsRead sourceQueries, launchContexts and templates as Smart Forms reads them
6Supplied nameshost-variables.tsGives core the sourceQueries names, so sdc/undefined-variable accepts them
7Rulesrules/Lists each rule with the blocks and facts it uses
8Evidence and reproductionfacts/evidence.ts, test/reproduction/Backs each fact with a test or a source link, and explains how to verify a new Smart Forms version

Paths are relative to packages/plugin-smart-forms/src, except test/, which is relative to the package.