-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Description
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
yarnyarn 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:
vue-cli/packages/@vue/cli-plugin-typescript/lib/tslint.js
Lines 107 to 109 in f8a0a63
| 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.