@salesforcedevs/sfdocs-liquid-lint-variables-config
v1.1.3
Published
Validate repository-level 'variables' declarations in content-config.yml (well-formed namespace map and valid referenced files).
Maintainers
Keywords
Readme
@salesforcedevs/sfdocs-liquid-lint-variables-config
Lint rule that validates the repository-level variables declarations in content-config.yml.
The runtime (loadVariables) reads variables as a namespace → YAML-file map and exposes each file as
{{ variables.<namespace>.<key> }}. A missing or malformed file is skipped with only a warning, so
pages can break silently in production. This rule surfaces those problems at lint time instead.
What it checks
AC1 — declarations are well-formed (every declared entry):
variablesis a map of namespace → file path (not a list or scalar).- Each path is a non-empty string.
- Each namespace is a valid identifier (
^[A-Za-z_][A-Za-z0-9_]*$) so it can be referenced as{{ variables.<namespace>.<key> }}— no dots, hyphens, spaces, or leading digits.
AC2 — referenced files are valid (only for files that resolve under a /variables/ folder):
- The file exists.
- It is valid YAML.
- It contains a non-empty set of key/value pairs — not empty, not a single scalar, not a list.
Scope note: AC2 only validates files whose resolved path is under a
/variables/folder. Files declared pointing anywhere else (for example avalidationfolder, or DDRA's non-variablesfiles) are skipped for the key/value check. AC1 still applies to every declared entry.
Errors are reported once per repository (keyed on the content-config.yml path) rather than repeated
for every .md file, with positions pointing into content-config.yml.
Example
Valid:
# content/en-us/content-config.yml
variables:
platform: variables/platform.yml# content/en-us/variables/platform.yml
name: Salesforce
url: https://developer.salesforce.comInvalid — reported:
variables:
my-ns: variables/x.yml # bad namespace: hyphen not allowed
platform: variables/gone.yml # AC2: file does not existUsage
const variablesConfig = require('@salesforcedevs/sfdocs-liquid-lint-variables-config');
remark().use(variablesConfig);