首页 > 网站 > WEB开发 > 正文

eslint 相关积累

2024-04-27 15:04:53
字体:
来源:转载
供稿:网友

一、注释不要的扫描段落,特别是拷贝的网上的代码

/* eslint-disable */ var codeNotOk; /* eslint-enable */

二、 注释不要扫描的单行代码

var thing = new Thing(); // eslint-disable-line no-use-before-define// eslint-disable-next-line no-use-before-definevar thing = new Thing();

三、eslint 等级 “off”, “warn”, “error” 不重要的off, warn警告

四、批量扫描

// 扫描某个js文件夹下的所有js$ eslint webapp/js/**.js// 扫描某个js文件夹及其子文件夹下的所有js$ eslint webapp/js/**/**.js

五、.eslintrc.json放在相关的js目录下,当前.eslintrc.json示例:

{ "extends": "airbnb-es5", "rules": { "func-names": "off", "no-console": "off", "no-multi-str": "off", "linebreak-style": "off", "quotes": "off", "space-before-function-paren": "off", "no-param-reassign": "warn", "consistent-return": "off", "no-shadow": "off", "no-else-return": "off", "one-var": "off", "guard-for-in": "warn", "no-unused-vars": "warn", "spaced-commnet": "warn", "eol-last": "warn", "padded-blocks": "warn", "spaced-comment": "off", "yoda": "off" }}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表