How to extend airbnb eslint but with warnings instead of errors?
Asked Answered
P

2

17

I'm using airbnb's eslint with webpack like this:

.eslintrc:

{
  "extends": "airbnb"
}

webpack.config.js:

...
module: {
  rules: [
    {
      test: /\.js$/,
      use: ['babel-loader', 'eslint-loader'],
      include: path.join(__dirname, 'src')
    },
    ...
  ]
}
...

This works, but all the eslint rules show up as errors, eg:

1:28   error  Missing semicolon                             semi
2:45   error  Missing semicolon                             semi
5:7    error  Unexpected space before function parentheses  space-before-function-paren

How can I set it up so that all the rules from airbnb's eslint are warnings instead of errors?

Perigordian answered 1/10, 2017 at 23:26 Comment(0)
P
13

Approach #1 adjust specific rules in .eslintrc:

{
  "extends": "airbnb"
  "rules": {
    "camelcase": "warn",
    ...
  }
} 

see Configuring Rules

Approach #2 adjust eslint-loader to emit warnings instead of errors for all rules:

{
  ...
  loader: "eslint-loader",
  options: {
    emitWarning: true,
  }
}

see Errors and Warning

Philippa answered 2/10, 2017 at 1:50 Comment(2)
hmm I don't know why but adding emitWarning: true doesn't work, it still shows errors...Perigordian
but webpack updates is no longer skipped because of eslint-loader? what is the problem then?Philippa
N
-1

To make the Oles Savluk's second solution work you may need to use failOnWarning flag:

{
    loader: 'eslint-loader',
    options: {
        emitWarning: true,
        failOnWarning: false,
    }
}
Nickelsen answered 28/10, 2019 at 13:22 Comment(1)
Is there a way to have it only treat the airbnb rules as warnings, so that our other eslint rules can still be treated as errors?Supercilious

© 2022 - 2024 — McMap. All rights reserved.