简体   繁体   中英

Eslint is working from terminal, but not showing error in the editor UI (VSCode)

I've installed the ESlint by following these steps: https://travishorn.com/setting-up-eslint-on-vs-code-with-airbnb-javascript-style-guide-6eb78a535ba6

Now, my ESlint is working from the terminal, but errors/warnings are not displaying in the code window, here is my project structure and how it is looks like:

eslint 终端

and my eslintrc configs:

module.exports = {
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true,
  },
  extends: [
    'airbnb-base',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parserOptions: {
    ecmaVersion: 2018,
  },
  rules: {
  },
};

Why it couldn't show errors in the editor?

I ran into this recently, and fixed it by changing my .eslintrc.js file to just .eslintrc (JSON object only, no comments, everything quoted right, no extension). After restarting VSCode it picked up the file properly and gave me linter errors in VSCode.

for me it's work !

setting.json add this

"eslint.validate": [
    "vue",
    "html",
    "javascript",
    "typescript",
    "javascriptreact",
    "typescriptreact"
]

https://linuxpip.org/eslint-not-working-in-vscode/

I followed all the advice and still had issues. I am using Typescript + YARN 2 (w\ PnP).

The error I was receiving was Failed to load the ESLint library for the document [filename].ts

What fixed it for me was that I needed to create some editor SDKs and settings with the command:

yarn dlx @yarnpkg/sdks vscode .

My.vscode/settings.json for eslint looks like:

  "eslint.enable": true,
  "eslint.packageManager": "yarn",
  "eslint.alwaysShowStatus": true,
  "eslint.validate": [
    "html",
    "javascript",
    "typescript",
    "javascriptreact",
    "typescriptreact"
  ],
  "eslint.nodePath": ".yarn/sdks"

The command above added "eslint.nodePath": ".yarn/sdks"

I found this here (I followed this and this to get there).

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