Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It this the correct way of extending eslint rules?

Tags:

yaml

eslint

In my eslint config (YAML format), I'm extending 3 different configurations:

extends:
- airbnb-base
- plugin:angular/johnpapa
- ionic

My questions are as follows:

  • Is this the correct format in YAML?
  • Some of these extensions have overlapping rules (or multiple of them extend eslint:recommended): will I get the same error multiple times if the error is related to one of these "shared" rules?
like image 746
dragonmnl Avatar asked Oct 03 '17 11:10

dragonmnl


People also ask

What is extend in ESLint?

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.

How many ESLint rules are there?

Keep in mind that we have over 200 rules, and that is daunting both for end users and the ESLint team (who has to maintain them). As such, any new rules must be deemed of high importance to be considered for inclusion in ESLint.

What does 2 mean in ESLint rules?

I defines the severity of a rule. Severity should be one of the following: 0 = off, 1 = warning, 2 = error (you passed "3"). Documentation: https://eslint.org/docs/user-guide/configuring/rules.


1 Answers

At first, Yes, it's the correct format in YAML (see for example ESLint - Configuring Plugins). As JSON, it would be

{
  "extends": [
    "airbnb-base",
    "plugin:angular/johnpapa",
    "ionic"
  ]
}

If you have multiple rulesets in your extend section, each following ruleset will extend or overwrite the previous ones. So you will only have one setting for each rule (see ESLint - Extending Configuration Files) Sometimes when the rules from the shareable configs are conflicting and you can't define a specific order for the extend section you have to manually define this specific rule in you rules section.

So the answer to you second question is: No, you won't get the same error multiple times.

like image 133
Sven 31415 Avatar answered Oct 27 '22 10:10

Sven 31415