Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set default error level to WARN

Tags:

eslint

It seems that default error level for all eslint rules are "error". This is annoying as my app doesn't compile even for an omitted semicolon.

How can I set it to "warn" so that my app compiles but shows warnings?

I know I can set each rule to warn manually but I'd prefer to do it globally. In the official docs I haven't found such option.

This my config in .eslingtrc.js:

// http://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parser: 'babel-eslint',
  parserOptions: {
    sourceType: 'module'
  },
  env: {
    browser: true,
  },
  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
  extends: 'standard',
  // required to lint *.vue files
  plugins: [
    'html'
  ],
  // add your custom rules here
  'rules': {
    // allow paren-less arrow functions
    'arrow-parens': 0,
    'indent': 1,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
    'padded-blocks': [1, {classes: 'always'}],
    'semi': 1
  }
}
like image 243
Amio.io Avatar asked Jun 01 '17 09:06

Amio.io


People also ask

How do I set the warning level of the error messages?

To set the /W0, /W1, /W2, /W3, /W4, or /Wall options, modify the Warning Level property. To set the /WX or /WX- options, modify the Treat Warnings as Errors property.

How do I set the warning level for compiler errors?

To set the /W0, /W1, /W2, /W3, /W4, or /Wall options, modify the Warning Level property. To set the /WX or /WX- options, modify the Treat Warnings as Errors property. To set the version for the /Wv option, enter the compiler version number in the Warning Version property.

What does the/w option do to a build error warning?

Warning pragma directives in source code are unaffected by the /w option. The build errors documentation describes the warnings and warning levels, and indicates why certain statements may not compile as you intend. Open the project's Property Pages dialog box.

How do I set the/we option in a warning?

To set the /we option, Select the Treat Specific Warnings As Errors property dropdown control and then choose Edit. In the edit box in the Treat Specific Warnings As Errors dialog, enter the warning number. To enter more than one warning, separate the values by using a semicolon (; ).


1 Answers

You can use eslint plugin eslint-plugin-only-warn or use the same method as it done in this plugin by patching verify function

like image 197
Yuriy Chachora Avatar answered Oct 12 '22 23:10

Yuriy Chachora