Skip to content

"A picture is worth a thousand words."

Require variables and properties to be named using emojis (prefer-emoji) ​

πŸ’Όβš οΈ This rule is enabled in the 🌐 all config. This rule warns in the βœ… recommended config.

πŸ”§ This rule is automatically fixable by the --fix CLI option.

πŸ“– Rule details ​

Emojis convey complex ideas succinctly and are universally recognized. Using them as variable names enhances code clarity and expressiveness. Unfortunately, the Javascript ecosystem doesn't embrace this potential as emojis can't be used as variable names.

πŸ’‘ Examples ​

js
// ❌ Incorrect
if (a) {
  b = c
  return foo(d, {
    e: f,
    g: h,
  })
}

// βœ… Correct
if (πŸͺ) {
  ⛺️ = 🧲
  return 🐷️(🀹, {
    πŸ¦„: 🍭,
    🌺: πŸ™ˆ,
  })
}
js
// ❌ Incorrect
if (a) {
  b = c
  return foo(d, {
    e: f,
    g: h,
  })
}

// βœ… Correct
if (a) {
  b = c
  return foo(d, {
    πŸ¦„: f,
    🌺: h,
  })
}

βš™οΈ Options ​

See eslint-plugin-unicorn/prevent-abbreviations, which this rule is copied from.

checkDefaultAndNamespaceImports ​

checkFilenames ​

checkProperties ​

checkShorthandImports ​

checkShorthandProperties ​

checkVariables ​

ignore ​

replacements ​

πŸ”§ Config ​

js
{ rules: { 'ninja/prefer-emoji': 2 } }

πŸ§‘β€πŸ’» Demo ​

Released under the MIT License