Kim Stacks
Kim Stacks

Reputation: 10812

How to use eslint rule for no-multi-comp

I came across this style guide and trying to adopt some of its rules.

The first rule mentioned about

Only include one React component per file. However, multiple Stateless, or Pure, Components are allowed per file. eslint: react/no-multi-comp.

So in my .eslintrc

{
    "parser": "babel-eslint",
    "plugins": [
        "react"
    ],
    "extends": [
        "eslint:recommended",
        "plugin:react/recommended"
    ],
    "rules": {
       "no-set-state": "off"
    },

    "parserOptions": {
      "ecmaVersion": 6,
      "sourceType": "module",
      "ecmaFeatures": {
          "jsx": true,
          "modules": true
      }
  },
  "globals": {
    "localStorage": true,
    "fetch": true
},
  "settings": {
    "react": {
        "pragma": "React",
        "version": "16.4.1"
    }
    }
}

I added this to rules

"rules": {
   "no-set-state": "off",
   "react/no-multi-comp":  [true, { "ignoreStateless": true }]
},

Am I doing this correctly? Because when i read the docs, I saw a <enabled> I have no idea what that means.

Upvotes: 1

Views: 5069

Answers (2)

aravind_reddy
aravind_reddy

Reputation: 5476

<enabled> looks for value one of the 0,1,2 or one of the off,warn,error meaning:

From the docs:

"off" or 0 - turn the rule off

"warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)

"error" or 2 - turn the rule on as an error (exit code is 1 when
triggered)

Upvotes: 2

Kim Stacks
Kim Stacks

Reputation: 10812

Using Visual Studio Code, and installing the ESLint plugin, you should be able to look under Output > ESLint

enter image description here

That the <enabled> is looking for 0, 1, or 2.

Change accordingly.

Upvotes: 1

Related Questions