Skip to content

@mmd-toolkit/c4-no-duplicate-description ​

Disallow a description statement that replaces a different diagram description.

✅ The recommended configuration enables this rule.

accDescription, accDescr:, and nonempty accDescr { ... } set one shared description. mermaid.js accepts a different second description without an error, and the earlier description is lost.

Rule Details ​

This rule applies to C4 diagrams (C4Context, C4Container, C4Component, C4Dynamic, and C4Deployment). It reports a description that differs from the latest preceding nonempty description, comparing all three forms together, including inside boundaries. Repeating the same description is not reported. After accDescr: a and accDescr: b, a third accDescr: a is reported, because it replaces b.

CR and CRLF are compared as LF, and whitespace after a line feed is ignored. accDescription keeps extra spaces after its first separator, while colon and block forms trim whitespace at the ends.

An empty description block changes nothing and is neither reported nor used for later comparisons. A colon form whose value is on a later line still sets that value, including after blank, comment, or directive lines.

The last correct example is shown as written: its two descriptions are indented differently on the second line, which the formatter would print the same way, and that difference is what the example shows.

Examples of incorrect code for this rule:

mmd
%% eslint @mmd-toolkit/c4-no-duplicate-description: error
C4Context
  accDescr: Customers
  
accDescr: Administrators
mmd
%% eslint @mmd-toolkit/c4-no-duplicate-description: error
C4Context
  accDescription Customers
  
accDescr {
Administrators Auditors }
accDescr: Customers

Examples of correct code for this rule:

mmd
%% eslint @mmd-toolkit/c4-no-duplicate-description: error
C4Context
  accDescription Customers
  accDescr: Customers
mmd
%% eslint @mmd-toolkit/c4-no-duplicate-description: error
C4Context
  accDescr: Customers
  accDescr {}Person(a, "A")
mmd
%% eslint @mmd-toolkit/c4-no-duplicate-description: error
C4Context
  accDescr { Customers
  use the bank }
  accDescr { Customers
 use the bank }

Options ​

This rule has no options.

Version ​

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

Resources ​

Third-party tools for Mermaid diagram text.