@salesforcedevs/sfdocs-liquid-lint-capture
v1.0.8
Published
Validates the usage of LiquidJS capture block
Maintainers
Keywords
Readme
@salesforcedevs/sfdocs-liquid-lint-capture
Overview
This plugin validates Liquid {% capture %} blocks in markdown files.
Installation
yarn add @salesforcedevs/sfdocs-liquid-lint-captureRules
Rule 1 — Location (Error)
Capture blocks outside shared/partials/ triggers an error. Capture blocks should live in reusable partials.
Rule 2 — Content Validation (Error)
In shared/partials/, only frontmatter and HTML/Liquid comments are allowed outside capture blocks. Any other content triggers an error. Also, include tag is not allowed inside capture block.
<!-- shared/partials/company.md -->
{% capture company-name %}Salesforce{% endcapture %} <!-- valid -->
Some stray text <!-- error -->
{% capture company-product %}
{% include "shared/partials/product.md" %} <!-- error -->
{% endcapture %}Rule 3 — Variable Naming (Error)
In shared/partials/, every capture variable must start with <filename>-.
<!-- shared/partials/company.md -->
{% capture company-name %}Salesforce{% endcapture %} <!-- valid -->
{% capture title %}Salesforce{% endcapture %} <!-- error: must start with "company-" -->Usage
Basic Usage
Register the plugin in your lintConfig.ts:
const internalPluginsConf = {
'liquid-capture-outside-partials': [
require('@salesforcedevs/sfdocs-liquid-lint-capture'),
['error']
],
};