zoukankan      html  css  js  c++  java
  • vs工程配置eslint检测环境

    vs工程打开一个js文件,会提示

    "No ESLint configuration (e.g .eslintrc) found for file ......."

    "Failed to load the ESLint library for the document ......."

    就是需要配置eslint检测环境

    • 首先使用npm 全局安装eslint
    • 在项目目录中执行eslint --init,这时候会让你选择项目的一些参数,比如模块类型(JavaScript modules (import/export) CommonJS (require/exports) ),框架(vue或react),执行完毕后生成.eslintrc.js(报的错不管)
    • 如果选择vue,还需要安装eslint-plugin-vue插件,这时需要本地安装这个插件

      npm i -save-dev eslint-plugin-vue

    • 需要对.eslintrc.js做一些配置,比如之前选择了JavaScript modules,后面又使用module.exports,必须再加上
    "commonjs": true
    比如:
    module.exports = {
    "env": {
    "browser": true,
    "es6": true,
    "commonjs": true
    },
    ........
    }
     
    • 如果需要在控制台打印调试信息,需要加上:
    "no-console":"off"
    比如:
    module.exports = {
    ......
    "rules": {
    "no-console":"off"
    }
    };
    off也可以用0替代
     "off" -> 0 关闭规则
     "warn" -> 1 开启警告规则
    "error" -> 2 开启错误规则
    • 允许使用一些全局变量,比如node里的__dirname
    "env": {
    ......
    "node": true
    },
    • Eslint中no-undef的检查报错

    有时候使用一些全局变量,会报这个错误,

    这个可以在eslint中增加一个global配置,用于标记哪些可以使用的全局对象

    "globals":{
      "document": true,
      "localStorage": true,
      "window": true
    }

     

     

  • 相关阅读:
    利用高斯金字塔制作图像显著图
    python实现图像高斯金字塔
    使用差分金字塔提取图像边缘 python实现
    使用色彩追踪和形态学运算得到图像中感兴趣区域
    图像掩膜讲解
    图像色彩追踪
    手动绘制方向梯度直方图(HOG)
    Zhang-Suen 图像细化算法python实现
    hilditch图像细化算法python实现
    P2256 一中校运会之百米跑
  • 原文地址:https://www.cnblogs.com/cowboybusy/p/10600686.html
Copyright © 2011-2022 走看看