English
@mmd-toolkit/block-no-undef
Disallow a class statement for an id that no block has.
✅ The recommended configuration enables this rule.
class A c gives class c to block A. When no block has the id, as when it is misspelled, mermaid.js gives no error. It creates an unplaced block with that id, leaving the intended block without the class.
Rule Details
This rule applies to block diagrams (block-beta and block). It reports each id in a class statement that no statement in the diagram declares, including repeated references to the same unknown id. Ids are case-sensitive.
Standalone blocks, composite heads, and edges declare blocks anywhere in the diagram, and root is declared from the start. A declaration after the class statement prevents a report, although mermaid.js then leaves the block unplaced. Blocks lost by an edge chain or a composite head with a link do not count as declared.
Class names are not checked: a class without a classDef can be used by the page's CSS. Ids starting with whitespace are reported by block-no-spaced-class-id.
Examples of incorrect code for this rule:
mmd
%% eslint @mmd-toolkit/block-no-undef: error
block
A
classDef c fill: #f00
class Typo cExamples of correct code for this rule:
mmd
%% eslint @mmd-toolkit/block-no-undef: error
block
A
classDef c fill: #f00
class A cOptions
This rule has no options.
Related Rules
Version
This rule was introduced in @mmd-toolkit/eslint-plugin v0.1.0.