Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
128
rated 0 times [  133] [ 5]  / answers: 1 / hits: 20556  / 6 Years ago, wed, november 7, 2018, 12:00:00

I don't understand why we have plugins and extends. What is the difference between them and do I need one or the other?


More From » eslint

 Answers
6

extends uses a config file which applies set of rules when you add that to the extends options. A plugin on the other hand provides you with a set of rules that you can individually apply depending on your need. Just having a plugin does not enforce any rule. You have to choose which rules you need.
A plugin may provide you with zero, one, or more configuration files. If the plugin provides configuration file, then you can load that in your extends section after adding the plugin in the plugins section.


So essentially, plugins given you some rules that have been coded and you can choose which ones are relevant. It may also provide config files to apply rules that the authors think are logically grouped/relevant but providing a config file is not mandatory for a plugin. extends, on the other hand, provides you the ability to apply rules in bulk based on config file specifications.


Example Plugin - eslint-plugin-react


{
"plugins": [
"react"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended"
]
}

Example Config - eslint-config-google


{
"extends": [
"google"
]
}

[#53160] Thursday, November 1, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
robinh

Total Points: 371
Total Questions: 105
Total Answers: 89

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
;