English
@mmd-toolkit/sequence-no-invalid-json
Disallow a links or properties statement whose text is not a JSON object.
✅ The recommended configuration enables this rule.
🔧 This rule is automatically fixable by the --fix CLI option.
links and properties give a participant links or properties from a JSON object. When the text is not JSON, mermaid.js accepts the statement without an error but does nothing with it. A trailing comma is enough to lose the links or properties.
Rule Details
This rule applies to sequence diagrams (sequenceDiagram). It reports a links or properties statement whose text is not a JSON object, including empty text. Other JSON values are reported too: strings and arrays give entries under their positions, while numbers, true, false, and null give nothing.
mermaid.js ends the text at #. A text that is a JSON object only with the # and what follows it, as one that holds a URL with a fragment, is not reported: it is correct JSON, and mermaid.js cutting it at the # looks like a defect (see Further Reading). A JSON object valid before the # is not reported either, because mermaid.js reads that object.
Examples of incorrect code for this rule:
mmd
%% eslint @mmd-toolkit/sequence-no-invalid-json: error
sequenceDiagram
participant A
links A: {"Dashboard": "https://x.example",}mmd
%% eslint @mmd-toolkit/sequence-no-invalid-json: error
sequenceDiagram
participant A
properties A: {"class": "internal",}Examples of correct code for this rule:
mmd
%% eslint @mmd-toolkit/sequence-no-invalid-json: error
sequenceDiagram
participant A
links A: {"Dashboard": "https://x.example"}Options
This rule has no options.
Related Rules
Further Reading
Version
This rule was introduced in @mmd-toolkit/eslint-plugin v0.1.0.