Skip to content

@mmd-toolkit/gitgraph-no-redefined-commit ​

Disallow a commit with the id of a commit or a merge written before it.

✅ The recommended configuration enables this rule.

A git graph keeps one commit per id. mermaid.js accepts a later commit with an earlier commit's id without an error and replaces the earlier commit. It writes only a log warning, hidden by the default configuration.

Rule Details ​

This rule applies to Git graphs (gitGraph). It reports a commit whose id belongs to an earlier commit or merge, even if its options are identical. The last id: option supplies the id; commits with no id: or an empty id receive generated ids and are not compared.

A merge that reuses an earlier commit id is not reported, because mermaid.js gives an error for it. A cherry-pick is neither reported nor counted: its id: names the commit that it copies and declares no id.

Ids are case-sensitive, and surrounding quotes are ignored.

Examples of incorrect code for this rule:

mmd
%% eslint @mmd-toolkit/gitgraph-no-redefined-commit: error
gitGraph
  commit id: "A" tag: "first"
  
commit id: "A" tag: "second"

Examples of correct code for this rule:

mmd
%% eslint @mmd-toolkit/gitgraph-no-redefined-commit: error
gitGraph
  commit id: "A" tag: "first"
  commit id: "B" tag: "second"

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.