Skip to content

@mmd-toolkit/state-no-ignored-text ​

Disallow text that mermaid.js drops.

✅ The recommended configuration enables this rule.

🔧 This rule is automatically fixable by the --fix CLI option.

A direction statement is written on a line of its own. When other text shares the line, mermaid.js reads the whole line as the direction statement and drops the rest without an error. State diagrams also have other places where text is dropped.

Rule Details ​

This rule applies to state diagrams (stateDiagram and stateDiagram-v2). It reports text before direction or after its direction value on the same line, including direction written in a state's description, as in B : x direction LR. Text after the direction that starts with %% is not reported, because it is written as a comment and mermaid.js drops it as intended.

It also reports:

  • Text from the second : of an alias definition, such as : y in state "d" as A : x : y.
  • %% before a body's {, as in state "d" as %% c {, where the alias has no id.
  • The character immediately after : in a one-line note, such as h in note left of A:hi. Write a space after : to keep the whole note text.
  • Empty strings mermaid.js skips, such as "" in state x "", and empty description blocks or a second state before a body's { on a later line.

Examples of incorrect code for this rule:

mmd
%% eslint @mmd-toolkit/state-no-ignored-text: error
stateDiagram-v2
  
A --> B
direction LR
mmd
%% eslint @mmd-toolkit/state-no-ignored-text: error
stateDiagram-v2
  direction TB
X
A --> B

Examples of correct code for this rule:

mmd
%% eslint @mmd-toolkit/state-no-ignored-text: error
stateDiagram-v2
  direction LR
  A --> B
mmd
%% eslint @mmd-toolkit/state-no-ignored-text: error
stateDiagram-v2
  direction LR %% c
  A --> B

Options ​

This rule has no options.

Further Reading ​

Version ​

This rule was introduced in @mmd-toolkit/eslint-plugin v0.1.0.

Resources ​

Third-party tools for Mermaid diagram text.