«error: Unexpected console statement (no-console)»
by pluvet on Oct 5, 2019

最讨厌这些繁文缛节,去看 eslint 的官方破网站的解释:


In JavaScript that is designed to be executed in the browser, it’s considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client. In general, calls using console should be stripped before being pushed to production.

意思就是:js 这玩意儿是在浏览器用的,你搞些 console.log 和用户没关系,你别写 console.log 了。不过有趣的是,eslint 的官方 repo 中却大把大把地写 console.log (https://github.com/eslint/eslint/search?q=console.log&unscoped_q=console.log


// custom console
Console.log("Hello world!");

自己写一个 console。这?有病吧?

解决方法:禁用 eslint,或者禁用这一条规则。

"eslintConfig": {
    "rules": {
      "no-console": "off"