Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 979
Vic Avatar asked Oct 01 '17 23:10

Vic


People also ask

How do you show an ESLint warning?

To show warnings instead of errors on all ESLint rules with React, we set each rule to 'warm' in . eslintrc. to set "prettier/prettier" to "warn' in "rules' to make ESLint return a warning instead of an error when the rule is violated.

How do I set up ESLint rules?

There are two primary ways to configure ESLint: Configuration Comments - use JavaScript comments to embed configuration information directly into a file. Configuration Files - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories.

Is Airbnb an ESLint?

Yes, with eslint-config-airbnb-typescript. It doesn't have TypeScript-specific rules, it is simply compatible.


Video Answer


1 Answers

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

like image 148
Oles Savluk Avatar answered Nov 12 '22 06:11

Oles Savluk