Eslint no-console

0

How to make sure that I do not get the error when I want to debug with console.log() using Eslint?

The question is also valid for alert()

Error message:

  

error: Unexpected console statement (no-console) at   src \ components \ example.vue: 1: 7:

    
asked by fcento 16.07.2018 в 19:21
source

1 answer

0

You can use this comment in the line that you put the console:

// eslint-disable-next-line no-console <-- esto desactiva el lint en la siguiente linea
console.error = function (message) {
  throw new Error(message);
};

or you can put it like this:

console.error = function (message) {  // eslint-disable-line no-console <-- desactiva el lint en esta linea
  throw new Error(message);
};

Some of the options above is the best practice because it prevents you from having console.log or any other in an unwanted place, however, if you still prefer to disable the option in your rules you must add this:

rules: {
    'no-console': 'off',
},
    
answered by 16.07.2018 / 20:24
source