Eslint: how to name plugins

Mohamed Lamine Allal
3 min readNov 19, 2023

--

Eslint has a convention for plugins and module naming. In this article we gonna break it down, clear and simple.

The rule

▪️ plugins names are used in the name of rules 🔥🔥

  • plugin-name/some-rule-name
    ◌ is setting the rule for a plugin with the name plugin-name

▪️ Examples

  • "@typescript-eslint/quotes": 0,
    @typescript-eslint/eslint-plugin plugin package
  • "babel/quotes": 0,
    eslint-plugin-babel. plugin package
  • "vue/html-self-closing": 0,
    eslint-plugin-vue plugin package

If you see in some rules set "@typescript-eslint/quotes"

  • you would know that you need to name @typescript-eslint/eslint-plugin plugin as @typescript-eslint

you do it in such a manner

plugins: {
"@typescript-eslint": typescriptEslintPlugin
}

However, there is an eslint convention. And how eslint used to normalize the names

Naming convention when it comes to translating old plugins

  • There is more than one form
  • check below

✨ prefix

  • eslint-plugin
  • eslint-config

✨ Convention

  • {prefix}-{name}
    ◌ name {name}
  • @{scope}/{prefix}
    ◌ name @{scope}
  • Otherwise if @{scope}/{prefix}-{some_name}
    ◌ name @{scope}/{some_name}

✨ Example with eslint-plugin prefix

  • eslint-plugin-{name}
    ◌ name {name}
  • @{scope}/eslint-plugin
    ◌ name @{scope}
  • Otherwise if @{scope}/eslint-plugin-{some_name}
    ◌ name @{scope}/{some_name}

✨ Full Examples

  • eslint-plugin-prettier
    ◌ name prettier
  • @typescript-eslint/eslint-plugin
    ◌ name @typescript-eslint

✨ Details of normalization

Plugins that disable or override other plugins or configs settings

Example eslint-config-prettier

  • It’s saying you can name typescriptEslint 🔥🔥
    ◌ I guess that’s the go-to if no doc, outdated doc.Or if you want to be sharp.
  • I would say name it "@typescript-eslint": typescriptEslintPlugin
    ◌ it’s what FlatCompat do
    ◌ less confusing to people
    ◌ natural to match with the conventions

▪️ You can also verify that in rules

  • that’s what is used

▪️ but if typescriptEslint works

  • that means somehow eslint is converting that to match @typescript-eslint
    ◌ basically adding @ and converting the camel case to use -

▪️ Personally, I’ll go with the full name

  • "@typescript-eslint": typescriptEslintPlugin
  • and directly I would go check the rules
    ◌ and see what they used
    ctrl|cmd + F when you are searching to handle it fast

Example with FlatConfig and the importance of the naming for plugins

(FlatConfig, naming, plugins)

My Other Eslint related articles ✨

▪️ Flat config system

▪️ Eslint prettier

▪️ String, name resolution (plugin, config)

--

--

Mohamed Lamine Allal
Mohamed Lamine Allal

Written by Mohamed Lamine Allal

Developper, Entrepreneur, CTO, Writer! A magic chaser! And A passionate thinker! Obsessed with Performance! And magic for life! And deep thinking!

No responses yet