我在写一个 node.js 的项目的时候设置了 eslint,但是当我写 console 的时候,他却显示报错,这是怎么回事?虽然运行正常但是就是无法直视红字报错。
还有就是 node.js 现在支持 es6 的写法了吗?
1
noe132 2018-04-15 22:01:27 +08:00
eslint 默认是没有规则的。
你的规则设置了不允许使用 console 语句才会报错。 |
2
ghostgril OP module.exports = {
"env": { "es6": true, "node": true }, "extends": "eslint:recommended", "parserOptions": { "ecmaFeatures": { "experimentalObjectRestSpread": true, "jsx": true }, "sourceType": "module" }, "plugins": [ "react" ], "rules": { "indent": [ "error", "tab" ], "linebreak-style": [ "error", "windows" ], "quotes": [ "error", "single" ], "semi": [ "error", "always" ] } }; 我的配置就是这样 |
3
ghostgril OP @noe132
``` module.exports = { "env": { "es6": true, "node": true }, "extends": "eslint:recommended", "parserOptions": { "ecmaFeatures": { "experimentalObjectRestSpread": true, "jsx": true }, "sourceType": "module" }, "plugins": [ "react" ], "rules": { "indent": [ "error", "tab" ], "linebreak-style": [ "error", "windows" ], "quotes": [ "error", "single" ], "semi": [ "error", "always" ] } }; ``` |
5
yagokoro 2018-04-15 22:11:33 +08:00 via Android
建议你去搜一下 eslint 的规则列表,有一条是 noconsole,手动加上改 false 试试(
|
6
kslr 2018-04-16 00:37:25 +08:00
|
7
zhwithsweet 2018-04-16 08:51:54 +08:00 via iPhone
no-console:0
|