Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error reported in the editor #1251

Closed
wenfangdu opened this issue May 10, 2021 · 7 comments
Closed

No error reported in the editor #1251

wenfangdu opened this issue May 10, 2021 · 7 comments
Labels
info-needed Issue requires more information from poster

Comments

@wenfangdu
Copy link

wenfangdu commented May 10, 2021

Error is reported in the terminal but is not reported in the editor:

image

.eslintrc.js

module.exports = {
  env: {
    node: true,
  },
  extends: [
    'plugin:vue/vue3-essential',
    'eslint:recommended',
    '@vue/typescript/recommended',
    '@vue/prettier',
    '@vue/prettier/@typescript-eslint',
  ],
  parserOptions: {
    ecmaVersion: 2020,
  },
  root: true,
  rules: {
    'object-shorthand': 'error',
  },
}
@dbaeumer
Copy link
Member

@wenfangdu when validating in the terminal which working directory are you using. If it is different than VS Code's workspace folder you opened then very likely you need to configure eslint.workingDirectories. If it is the same then please provide me with a GitHub repository I can clone that demos that.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label May 10, 2021
@wenfangdu
Copy link
Author

wenfangdu commented May 10, 2021

@dbaeumer The working directories are the same, I've added repro here, please take a look! The readme provides some info too.

@dbaeumer
Copy link
Member

I am a little puzzled with the example. What do you expect in main.ts to happen. If I change the code to

import { createApp } from "vue";
import App from "./App.vue";

createApp(App).mount("#app");

const a = "a";
// 👇 ts is not
console.log({ a: a });

to mirror what is in test.js I get the correct error

capture

@wenfangdu
Copy link
Author

wenfangdu commented May 10, 2021

@dbaeumer Oops, sorry, seems vue-cli-service lint fixed main.ts issue when committing, I've recovered the code in main.ts to the following (repro is updated), mine is not throwing 🤔:

image

My vscode-eslint config:

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

I'm using VSCode v1.56.0 and vscode-eslint v2.1.20, could you please post your vscode-eslint config?

@wenfangdu
Copy link
Author

wenfangdu commented May 11, 2021

@dbaeumer I've fixed this issue by adding parser: "@typescript-eslint/parser" into .eslintrc.js under parserOptions, the codebase was generated by vue-cli, it didn't generate this line. Have you added parser before trying, if you didn't, then this issue is weirder 🤔.

@dbaeumer
Copy link
Member

@wenfangdu no, I didn't change any configuration file. I agree it is wired but without being able to reproduce I opt to close for now. Ping if you disagree.

@wenfangdu
Copy link
Author

@dbaeumer I seem to have found the cause and open a new issue #1266, when using vue-eslint-parser, and with "eslint.validate": [], .ts and .tsx files aren't auto-detected, unless I explicitly specify:

{
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants