简体   繁体   中英

How do you get VSCode to use the per file ESLint options

I recently started switching to using VSCode instead of Brackets.io because I like the intelisense features... However, ESLint works perfectly in Brackets.io and it doesn't seem to work so well in VSCode.

I've installed the ESLint plugin for VSCode, and it is running, however it is not recognizing my options.

In Brackets.io I could specify the options per file in the head of the file like this:

/*eslint-env jquery, browser*/
/*eslint no-unused-vars:1*/
/*eslint-disable no-console*/

However VSCode is not recognizing the options. I also created a .eslintrc.json file that I put in the same directory with my code file:

{
    "env": {
        "browser": true,
        "jquery": true
    },
    "extends": "eslint:recommended",
    "rules": {
        "indent": [
            "error",
            "tab"
        ],
        "linebreak-style": [
            "error",
            "windows"
        ],
        "quotes": [
            "warn",
            "double"
        ],
        "semi": [
            "error",
            "always"
        ]
    }
}

However it is still giving me errors on my jQuery and Browser function calls.

What do I need to do to make it work?

I found out what was happening. Apparently I had a tsconfig.json file in a parent directory that had the option set:

"checkJS": true

And the ts checker errors were showing along with the ESLint errors. Once I changed checkJS to false, everything worked like it was suppose to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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