@salesforcedevs/sfdocs-remark-lint-no-liquid-directive-include
v1.0.1
Published
Lint rule that prevents remark ::include from referencing files that contain LiquidJS syntax.
Maintainers
Keywords
Readme
remark-lint-no-liquid-directive-include
Lint rule that prevents ::include directives from referencing files that contain LiquidJS syntax.
Why
When a file with LiquidJS syntax (e.g. {% capture %}, {{ variable }}) is pulled in via ::include, remark processes it as plain markdown — the LiquidJS is never evaluated. This rule catches that mistake at lint time.
How it works
Before linting runs, the validate pipeline scans the shared/ directory and builds a Set of file paths that contain LiquidJS syntax. When the rule encounters an ::include directive, it checks whether the resolved file path is in that set and reports an error if so.
Error
Cannot use remark-include to include "../shared/partials/company.md": the file contains LiquidJS syntax, which remark can't process.Example
<!-- triggers an error if company.md contains LiquidJS syntax -->
::include{src="../shared/partials/company.md"}What counts as LiquidJS syntax
A file is considered a liquid file if its body (outside fenced code blocks and inline code spans) contains {% or {{.
<!-- detected as liquid -->
{% capture name %}Salesforce{% endcapture %}
{{ platform }}
<!-- NOT detected — inside fenced code block -->
```liquid
{% if x %}Run the {% cycle %} tag.
