ESLint报错解决方案(error: No ESLint configuration found)

##ESLint使用的时候报错:error: No ESLint configuration found
在项目部署中出现报错error: No ESLint configuration found,编辑器vscode。
###解决方案:
造成这种报错的原因是因为项目中缺少.eslintrc.js文件。添加上就可以了。
####添加.eslintrc.js文件方法:

  1. 手动添加,直接手动添加.eslintrc.js文件在项目中,并进行相应的配置就行了。
  2. 使用命令添加,如果eslint是全局安装的话,使用命令eslint --init安装。
    ####配置信息(简单版)
    module.exports = {
    “env”: {
    “browser”: true,
    “es6”: true,
    “node”: true
    },
    “extends”: “eslint:recommended”,
    “parserOptions”: {
    “ecmaVersion”: 2015,
    “sourceType”: “module”
    },
    “rules”: {
    // 缩进
    “indent”: [
    “error”,
    4 //我的是编辑器自动格式化,不是使用tabs,而是四个空格
    ],
    “linebreak-style”: [
    “error”,
    “windows”
    ],
    // 引号
    “quotes”: [
    1,
    “single”
    ],
    // 分号结尾
    “semi”: [
    “error”,
    “always”
    ],
    “no-unused-vars”: [2, {
    // 允许声明未使用变量
    “vars”: “local”,
    // 参数不检查
    “args”: “none”
    }],
    // 最大空行100
    “no-multiple-empty-lines”: [0, { “max”: 100 }],
    “no-mixed-spaces-and-tabs”: [0],
    //不能使用console
    “no-console”: ‘off’,
    //未定义变量不能使用
    “no-undef”: 0,
    //一行结束后面不要有空格
    “no-trailing-spaces”: 1,
    //强制驼峰法命名
    “camelcase”: 2,
    //对象字面量项尾不能有逗号
    “comma-dangle”: [2, “never”],
    //this别名
    “consistent-this”: [2, “that”],
    }
    };
    #####说明:
  • "no-undef": 0,"no-undef": 'off',一样,表示关闭该功能
  • "no-undef": 1, 表示仅提示
  • "no-undef": 2, 表示报错
    ####配置信息(完整版)
    #####见下一篇文章

新博客地址:http://www.caomage.com

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值