English
@mmd-toolkit/railroad-no-duplicate-title
Disallow an accTitle that replaces the title set before it.
✅ The recommended configuration enables this rule.
💡 This rule is manually fixable by editor suggestions.
A railroad diagram has one accessible title, which accTitle sets. A later accTitle replaces the title set before it without an error, and the earlier title is lost.
Rule Details
This rule applies to railroad diagrams (railroad-beta, railroad-ebnf-beta, railroad-abnf-beta, and railroad-peg-beta). It reports an accTitle that changes a nonempty accessible title set by the preceding accTitle. An empty or whitespace-only accTitle: clears the title without taking the next line, and is reported after a nonempty title. A statement after an empty title, or one that repeats the current title, is not reported. Going back to an earlier title is reported: after accTitle: a and accTitle: b, a third accTitle: a is reported.
A repeated title statement is not reported, because mermaid.js does not draw the title of a railroad diagram.
Titles are compared without whitespace at their ends and with a run of two or more spaces or tabs as one space. They are otherwise compared as written. mermaid.js converts character references such as #35; and HTML attribute quotes before reading a title. Titles differing only in these ways may be the same for mermaid.js and different for this rule.
Examples of incorrect code for this rule:
mmd
%% eslint @mmd-toolkit/railroad-no-duplicate-title: error
railroad-ebnf-beta
accTitle: First
accTitle: Second
word = "a";Examples of correct code for this rule:
mmd
%% eslint @mmd-toolkit/railroad-no-duplicate-title: error
railroad-ebnf-beta
accTitle: Second
word = "a";Options
This rule has no options.
Related Rules
Version
This rule was introduced in @mmd-toolkit/eslint-plugin v0.1.0.