Skip to content

[@vue/cli-plugin-typescript#lint]: Uses a hard-coded list instead of project file list #2912

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
DorianGrey opened this issue Nov 7, 2018 · 1 comment

Comments

@DorianGrey
Copy link

Version

3.1.1

Reproduction link

https://github.com/DorianGrey/vue-ts-playground/tree/cypress-ts

Node and OS info

Node 10.13 / yarn 1.12.1 / Manjaro 18

Steps to reproduce

  • Checkout the repository branch mentioned above
  • yarn
  • yarn lint

(Sorry it's not that minimal, but the required parts should be easy to find).

What is expected?

The linter should only pick up the files referenced by the typescript project, extended by .vue files in src.

As a result, yarn lint should not end up with any errors, like using tslint for the same purpose does.

What is actually happening?

Running yarn lint will yield an error like this:

 vue-cli-service lint --fix && stylelint "src/**/*.{scss,vue}"
 ERROR  FatalError: 
Invalid source file: [...]/tests/e2e/specs/test.ts. Ensure that the files supplied to lint have a .ts, .tsx, .d.ts, .js or .jsx extension.

On the branch linked above, I've followed the cypress doc for adding typescript support for the E2E spec files: https://docs.cypress.io/guides/tooling/typescript-support.html
(The default setup failed with a similar error as mentioned here: #2903)
For details about the changes made, see: https://github.com/DorianGrey/vue-ts-playground/pull/12/files

To get this working, it is required to create a separate typescript project that only covers the tests/e2e folder, due to different target and types requirements. Thus, it is also required to exclude this folder in the root project. However, the linter as configured by @vue/cli-plugin-typescript uses a hard-coded list of file patterns if none provided, and those also cover the tests/unit and tests/e2e folders:

const files = args._ && args._.length
? args._
: ['src/**/*.ts', 'src/**/*.vue', 'src/**/*.tsx', 'tests/**/*.ts', 'tests/**/*.tsx']

I'm wondering why you're not using program.getSourceFiles() (which correctly takes care of any include or exclude option) and just extend that list with the files yielded by the src/**/*.vue pattern. On a more general level, this hard-coded list causes any include, exclude or files restriction in the tsconfig.json to be ignored.

@DorianGrey DorianGrey changed the title [@vue/cli-plugin-typescript#lint]: Uses a hard-coded list [@vue/cli-plugin-typescript#lint]: Uses a hard-coded list instead of project file list Nov 7, 2018
@haoqunjiang
Copy link
Member

Now that TSLint is officially deprecated, TSLint support will be fully dropped in the next major version; as for the current major version, no more bug fixes or features will be implemented except for security reasons. So I'm closing this issue now.

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

No branches or pull requests

2 participants