简体   繁体   English

ESLint 不适用于项目中的 existing.eslintrc.json 文件

[英]ESLint not working with existing .eslintrc.json file in project

I've tried a number of things on VS Code like unintstalling/reinstalling ESLint.我在 VS Code 上尝试了很多东西,比如卸载/重新安装 ESLint。 npm install eslint -g , and manually putting in npm install eslint -g ,手动放入

{
  "eslint.options": { "configFile": "C:/mydirectory/.eslintrc.json" }
}

into my settings.json file which is:进入我的 settings.json 文件,即:

{
    "window.zoomLevel": 1,
    "editor.wordWrap": true,
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "[json]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "workbench.iconTheme": "vscode-icons",
    "yaml.schemas": {
        "REDACTED"
    },
    "atlascode.jira.jqlList": [
        {
            REDACTED
        }
    ],
    "vsicons.dontShowNewVersionMessage": true,
    "workbench.colorTheme": "Dark++",
    "emmet.showSuggestionsAsSnippets": true,
    "emmet.triggerExpansionOnTab": true,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "editor.fontSize": 15,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "[html]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "atlascode.jira.lastCreateSiteAndProject": {
        "siteId": REDACTED,
        "projectKey": ""
    },
    "highlightLine.borderColor": "#65EAB9",
    "highlightLine.borderStyle": "inset",
    "highlightLine.borderWidth": "2px",
    "editor.renderWhitespace": "boundary",
    "git.autofetch": true,
    "[typescriptreact]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "eslint.alwaysShowStatus": true
}

Here is my eslintrc.json file:这是我的 eslintrc.json 文件:

{
    "extends": [
        "plugin:react/recommended",
        "plugin:@typescript-eslint/recommended",
        "eslint:recommended"
    ],
    "plugins": [
        "@typescript-eslint",
        "react",
        "react-hooks"
    ],
    "env": {
        "browser": true,
        "jest": true,
        "es6": true
    },
    "rules": {
        "max-len": ["error", { "code": 120 }],
        "quotes": [2, "single", { "avoidEscape": true }],
        "object-curly-spacing": ["error", "always"],
        "array-bracket-spacing": ["error", "never"],
        "react/jsx-uses-react": "error",
        "react/prop-types": [2, { "ignore": ["children"] }],
        "react-hooks/rules-of-hooks": "error",
        "react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }]
    },
    "settings": {
        "react": {
            "pragma": "React",
            "version": "detect"
        }
    },
    "parser": "@typescript-eslint/parser"
}

I am basically trying to have VSCode shout out me for having double quotes (rule #2) in my Routes.tsx file which has the following code block:我基本上是想让 VSCode 在我的 Routes.tsx 文件中有双引号(规则 #2)大喊大叫,该文件具有以下代码块:

<Route exact path={`${Constants.Routes.Recruit.MODULE}${Constants.Routes.App.REDIRECT_URI}`} render={() => {
                let cookies = document.cookie.split(";");
                for (let i = 0; i < cookies.length; i++) {
                    let cookie = cookies[i];
                    let eqPos = cookie.indexOf("=");
                    let name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
                    document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
                }
                document.location.href = urlRedirectIfUnauthenticated;
                return null
            }} >

What am I doing wrong here?我在这里做错了什么?

Okay it is working now.好的,它现在正在工作。 After updating VSCode, adding "eslint.alwaysShowStatus": true to my settings.json file, and then enabling ESLint to Allow Everywhere for all workspaces.更新 VSCode 后,将"eslint.alwaysShowStatus": true添加到我的 settings.json 文件中,然后启用 ESLint 以允许所有工作空间的无处不在。 ESLint highlighted the code that needed to be changed up. ESLint 突出显示了需要更改的代码。 I can finally be at peace.我终于可以安心了。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM