在VSCode中禁止ESLint警告 [英] Suppress ESLint warnings in VSCode

查看:94
本文介绍了在VSCode中禁止ESLint警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VSCode中使用ESLint

如果您确实配置了该配置,但仍然无法正常工作,我建议您从一个新的小型配置文件开始,并逐步每次都添加一个新配置,并检查它是否不会破坏其他配置.

这是我正在使用的基本文件:

  module.exports = {"env":{浏览器":是的,"es6":是},"extends":"eslint:recommended",全局变量":{"Atomics":只读","SharedArrayBuffer":只读"},"parserOptions":{"ecmaFeatures":{"jsx":true},"ecmaVersion":2018年,"sourceType":模块"},插件":[反应"],规则":{无内部声明":0,}}; 

I am using ESLint extension in VSCode to format and check my JavaScript code. However, I don't want ESLint to show me warnings (red lines below code), esp. the ones related to code formatting, but still do the formatting every time I save the file. Is it possible to do this?

Here is my VSCode config:

{
  "editor.fontSize": 14,
  "explorer.openEditors.visible": 0,
  "files.autoSave": "onFocusChange",
  "terminal.integrated.fontSize": 14,
  "terminal.integrated.lineHeight": 1.3,
  "terminal.integrated.shell.osx": "zsh",
  "editor.codeLens": true,
  "editor.occurrencesHighlight": true,
  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.formatOnSave": false
  },
  "eslint.enable": true,
  "eslint.autoFixOnSave": true,
  "eslint.alwaysShowStatus": false,
  "eslint.run": "onType",
  "javascript.updateImportsOnFileMove.enabled": "always",
  "explorer.confirmDelete": false,
  "diffEditor.ignoreTrimWhitespace": false
}

解决方案

You should set your settings in the .eslintrc file (it can either be js, json, or yaml file, the best way to be sure you have the right file is to use the "eslint --init" command), Head into the "rules" sections and just add the name of the rule that you do not want to use, following by a comma and "0", for example:

"rules": {
    "no-inner-declarations": 0,
}

If you want to find the right settings name, you can stand with your mouse on the error indicated by esLint and the floating window that says what is the problem will contain the setting name.

you can also refer to this YouTube video for complete explanation: https://www.youtube.com/watch?v=cMrDePs86Uo

In the video it looks a bit different then now (I think this is an old version of VSCode) Today it looks like that:

Also in case you did configure that and it still doesn't work I recommend you to start with a new small configuration file and step-by-step adding a new config each time and checking to see if it does not break the rest of the configurations.

This is my basic file that is working:

module.exports = {
    "env": {
        "browser": true,
        "es6": true
    },
    "extends": "eslint:recommended",
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 2018,
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules": {
        "no-inner-declarations": 0,
    }
};

这篇关于在VSCode中禁止ESLint警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆