markdown-preferences/emoji-notation β
enforce consistent emoji notation style in Markdown files.
- π§ The
--fixoption on the command line can automatically fix some of the problems reported by this rule.
π Rule Details β
This rule enforces a consistent style for emoji notation in Markdown documents. You can choose between the following styles:
unicode: Use Unicode emoji characters (e.g., π)colon: Use colon-style notation (e.g.,:smile:)
Enforcing a single notation helps maintain a consistent appearance and improves readability across your documentation, especially in collaborative or large-scale projects.
Examples β
prefer: "unicode" (Default) β
<!-- eslint markdown-preferences/emoji-notation: ["error", {"prefer": "unicode"}] -->
<!-- β GOOD -->
I love open source! π
<!-- β BAD -->
I love open source! :smile:prefer: "colon" β
<!-- eslint markdown-preferences/emoji-notation: ["error", {"prefer": "colon"}] -->
<!-- β GOOD -->
I love open source! :smile:
<!-- β BAD -->
I love open source! ππ§ Options β
{
"markdown-preferences/emoji-notation": [
"error",
{
"prefer": "unicode",
"ignoreUnknown": true,
"ignoreList": [":zzz:", "πΊ", "/^\\p{RGI_Emoji_Flag_Sequence}$/v"],
},
],
}prefer: Specifies the preferred emoji notation style. Default is"unicode"."unicode": Enforce Unicode emoji characters (e.g., π)"colon": Enforce colon-style emoji notation (e.g.,:smile:)
ignoreUnknown: Iftrue, ignores unknown or unrecognized emoji notations (e.g.,:my-original-emoji:or unknown Unicode emoji). Default istrue.ignoreList: An array of emoji (Unicode or colon-style) and/or regular expression patterns (as string).
The specified strings and regular expressions inignoreListare matched against both colon-style emoji names and their corresponding Unicode emoji, and vice versa. Any match will be suppressed and not reported as a violation.Specifically, specifying either
πΊor:smiley_cat:inignoreListhas the same effect.For example, if
ignoreListcontainsπΊ:- When
prefer: "unicode"is set, the colon-style emoji name:smiley_cat:will be suppressed. - When
prefer: "colon"is set, the Unicode emojiπΊwill be suppressed.
Similarly, if
ignoreListcontains:smiley_cat::- When
prefer: "unicode"is set, the colon-style emoji name:smiley_cat:will be suppressed. - When
prefer: "colon"is set, the Unicode emojiπΊwill be suppressed.
- When
ignoreUnknown β
<!-- eslint markdown-preferences/emoji-notation: ["error", {"prefer": "unicode", "ignoreUnknown": true}] -->
<!-- β GOOD -->
I love open source! π
I love open source! :my-original-emoji:
<!-- β BAD (if ignoreUnknown: false) -->
I love open source! :smile:With this option, custom or unknown emoji notations (e.g., :my-original-emoji:) will be ignored and not reported as violations, but known colon-style emoji (e.g., :smile:) will still be reported if not matching the preferred style.
ignoreList β
Behavior with "prefer": "unicode"
<!-- eslint markdown-preferences/emoji-notation: ["error", {"prefer": "unicode", "ignoreList": [":zzz:", "πΊ", "/^\\p{RGI_Emoji_Flag_Sequence}$/v"]}] -->
<!-- β GOOD -->
I love open source! π
I love open source! :zzz:
I love open source! :smiley_cat:
I love open source! :us:
I love open source! :jp:
<!-- β BAD -->
I love open source! :smile:In the above example, ignoreList is used with "prefer": "unicode" and contains the following elements. Each entry suppresses reporting for the corresponding colon-style emoji:
":zzz:": Suppresses reporting for the colon-style emoji name:zzz:."πΊ": Suppresses reporting for the colon-style emoji name:smiley_cat:(since both notations represent the same emoji)."/^\\p{RGI_Emoji_Flag_Sequence}$/v": Suppresses reporting for colon-style flag names such as:us:and:jp:because they correspond to Unicode flag emoji (e.g.,πΊπΈ,π―π΅) that match the pattern/^\p{RGI_Emoji_Flag_Sequence}$/v.
Behavior with "prefer": "colon"
<!-- eslint markdown-preferences/emoji-notation: ["error", {"prefer": "colon", "ignoreList": [":zzz:", "πΊ", "/^\\p{RGI_Emoji_Flag_Sequence}$/v"]}] -->
<!-- β GOOD -->
I love open source! :smile:
I love open source! π€
I love open source! πΊ
I love open source! πΊπΈ
I love open source! π―π΅
<!-- β BAD -->
I love open source! πIn the above example, ignoreList is used with "prefer": "colon" and contains the following elements. Each entry suppresses reporting for the corresponding Unicode emoji:
":zzz:": Suppresses reporting for the Unicode emojiπ€(since both notations represent the same emoji)."πΊ": Suppresses reporting for the Unicode emojiπΊ."/^\\p{RGI_Emoji_Flag_Sequence}$/v": Suppresses reporting for Unicode flag emoji such asπΊπΈandπ―π΅because they match the pattern/^\p{RGI_Emoji_Flag_Sequence}$/v.
π Further Reading β
- GitHub Docs - Basic writing and formatting syntax: Using emojis
- GitLab Docs - GitLab Flavored Markdown (GLFM): Emoji
π« Related Rules β
No direct related rules.
π Version β
This rule was introduced in eslint-plugin-markdown-preferences v0.13.0