Eslint: How to disable “unexpected console statement” in Node.js?

后端 未结 17 1592
遇见更好的自我
遇见更好的自我 2020-12-07 07:39

I\'m using eslint with Sublime Text 3 and I am writing gulpfile.js.

/*eslint-env node*/
var gulp = require(\'gulp\');

gulp.task(\'default\', fu         


        
17条回答
  •  北海茫月
    2020-12-07 08:30

    My 2 cents contribution:

    Besides removing the console warning (as shown above), it's best to remove yours logs from PROD environments (for security reasons). The best way I found to do so, is by adding this to nuxt.config.js

      build: {
       terser: {
          terserOptions: {
            compress: {
              //this removes console.log from production environment
              drop_console: true
            }
          }
        }
      }
    

    How it works: Nuxt already uses terser as minifier. This config will force terser to ignore/remove all console logs commands during compression.

提交回复
热议问题