Skip to content

eslintrc.js parserOptions has no parser key after creating the project with eslint and typescript #5745

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

Closed
zhouxinyong opened this issue Aug 4, 2020 · 6 comments

Comments

@zhouxinyong
Copy link
Contributor

Version

4.5.0

Reproduction link

https://github.com/zhouxinyong/vue-cli-issue/blob/master/.eslintrc.js

Environment info

System:
    OS: macOS 10.15.6
    CPU: (6) x64 Intel(R) Core(TM) i5-8600 CPU @ 3.10GHz
  Binaries:
    Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
    Yarn: 1.21.1 - ~/.yarn/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.14.1/bin/npm
  Browsers:
    Chrome: 84.0.4147.105
    Edge: Not Found
    Firefox: Not Found
    Safari: 13.1.2
  npmPackages:
    @ant-design-vue/babel-helper-vue-transform-on:  1.0.1 
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.5.0 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.5.0 
    @vue/cli-plugin-babel: ~4.5.0 => 4.5.0 
    @vue/cli-plugin-eslint: ~4.5.0 => 4.5.0 
    @vue/cli-plugin-router: ~4.5.0 => 4.5.0 
    @vue/cli-plugin-typescript: ~4.5.0 => 4.5.0 
    @vue/cli-plugin-vuex: ~4.5.0 => 4.5.0 
    @vue/cli-service: ~4.5.0 => 4.5.0 
    @vue/cli-shared-utils:  4.5.0 
    @vue/compiler-core:  3.0.0-rc.5 
    @vue/compiler-dom:  3.0.0-rc.5 
    @vue/compiler-sfc: ^3.0.0-0 => 3.0.0-rc.5 
    @vue/compiler-ssr:  3.0.0-rc.5 
    @vue/component-compiler-utils:  3.2.0 
    @vue/eslint-config-standard: ^5.1.2 => 5.1.2 
    @vue/eslint-config-typescript: ^5.0.2 => 5.0.2 
    @vue/preload-webpack-plugin:  1.1.2 
    @vue/reactivity:  3.0.0-rc.5 
    @vue/runtime-core:  3.0.0-rc.5 
    @vue/runtime-dom:  3.0.0-rc.5 
    @vue/shared:  3.0.0-rc.5 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^7.0.0-0 => 7.0.0-beta.0 
    typescript: ~3.9.7 => 3.9.7 
    vue: ^3.0.0-0 => 3.0.0-rc.5 
    vue-eslint-parser:  7.1.0 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.9.3 (16.0.0-beta.4)
    vue-router: ^4.0.0-0 => 4.0.0-beta.4 
    vue-style-loader:  4.1.2 
    vue-template-es2015-compiler:  1.9.1 
    vuex: ^4.0.0-0 => 4.0.0-beta.4 
  npmGlobalPackages:
    @vue/cli: 4.5.0

Steps to reproduce

  1. yarn add @vue/cli@next
  2. vue ui
  3. choose vue version 3 (version 2 is the same)
  4. choose typescript, eslint with standard
  5. create

What is expected?

.eslintrc.js parserOptions has key parser
which value is @typescript-eslint/parser

What is actually happening?

.eslintrc.js parserOptions has no key parser

@zhouxinyong
Copy link
Contributor Author

I find code in https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-eslint/eslintOptions.js#L15
this line may lose the typescript plugin check.

@zhouxinyong
Copy link
Contributor Author

You can look at here https://github.com/zhouxinyong/vue-cli-issue/blob/master/.eslintrc.js .
The generated file has no parser: '@typescript-eslint/parser', is this a bug?
@sodatea

@haoqunjiang
Copy link
Member

The generated config extends from @vue/eslint-config-typescript/recommended, so the parserOptions from that package is merged into the final configuration. You don't have to explicitly set it.

@zhouxinyong
Copy link
Contributor Author

so the parserOptions from that package is merged into the final configuration. You don't have to explicitly set it.

but in the created repo above,when you clone and open in vscode

  1. yarn install
  2. edit a ts file like main.ts, add some blank lines at the end
    then you can see yarn serve can show error:

image

vscode has no error message:
image

after I edit .eslintrc.js, add parser: '@typescript-eslint/parser', then it work well as expected:
image
image

@sodatea something may be wrong in @vue/eslint-config-typescript/recommended?

@haoqunjiang
Copy link
Member

The error has nothing to do with the parser option. It disappears only because of this bug #3065 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants