diff --git a/packages/typescript-estree/src/create-program/createWatchProgram.ts b/packages/typescript-estree/src/create-program/createWatchProgram.ts index 4bfde8d2ba87..a0a8eeefb485 100644 --- a/packages/typescript-estree/src/create-program/createWatchProgram.ts +++ b/packages/typescript-estree/src/create-program/createWatchProgram.ts @@ -194,7 +194,6 @@ function getProgramsForProjects( results.push(program); } - parsedFilesSeen.add(filePath); return results; } @@ -216,11 +215,13 @@ function createWatchProgram( // ensure readFile reads the code being linted instead of the copy on disk const oldReadFile = watchCompilerHost.readFile; - watchCompilerHost.readFile = (filePath, encoding): string | undefined => - path.normalize(filePath) === - path.normalize(currentLintOperationState.filePath) + watchCompilerHost.readFile = (filePath, encoding): string | undefined => { + parsedFilesSeen.add(filePath); + return path.normalize(filePath) === + path.normalize(currentLintOperationState.filePath) ? currentLintOperationState.code : oldReadFile(filePath, encoding); + }; // ensure process reports error on failure instead of exiting process immediately watchCompilerHost.onUnRecoverableConfigFileDiagnostic = diagnosticReporter; diff --git a/tests/integration/fixtures/vue-sfc/.eslintrc.yml b/tests/integration/fixtures/vue-sfc/.eslintrc.yml index f20f5baf1746..7b9b183b59bc 100644 --- a/tests/integration/fixtures/vue-sfc/.eslintrc.yml +++ b/tests/integration/fixtures/vue-sfc/.eslintrc.yml @@ -6,6 +6,9 @@ env: es6: true node: true +extends: + plugin:vue/essential + parserOptions: # Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser' diff --git a/tests/integration/fixtures/vue-sfc/World.vue b/tests/integration/fixtures/vue-sfc/World.vue new file mode 100644 index 000000000000..ade2b409a3b6 --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/World.vue @@ -0,0 +1,30 @@ + + + + diff --git a/tests/integration/fixtures/vue-sfc/test.js.snap b/tests/integration/fixtures/vue-sfc/test.js.snap index 49bd30cc3897..df23862a1253 100644 --- a/tests/integration/fixtures/vue-sfc/test.js.snap +++ b/tests/integration/fixtures/vue-sfc/test.js.snap @@ -59,5 +59,13 @@ export default Vue.extend({ ", "warningCount": 0, }, + Object { + "errorCount": 0, + "filePath": "/usr/linked/World.vue", + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "messages": Array [], + "warningCount": 0, + }, ] `; diff --git a/tests/integration/fixtures/vue-sfc/test.sh b/tests/integration/fixtures/vue-sfc/test.sh index ba89362dcd13..b61a140ff5be 100755 --- a/tests/integration/fixtures/vue-sfc/test.sh +++ b/tests/integration/fixtures/vue-sfc/test.sh @@ -14,6 +14,9 @@ npm install $(npm pack /usr/eslint-plugin | tail -1) # Install the latest vue-eslint-parser (this may break us occassionally, but it's probably good to get that feedback early) npm install vue-eslint-parser@latest +# Install the latest eslint-plugin-vue (this may break us occassionally, but it's probably good to get that feedback early) +npm install eslint-plugin-vue@latest + # Run the linting # (the "|| true" helps make sure that we run our tests on failed linting runs as well) npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.yml /usr/linked/**/*.vue || true diff --git a/tests/integration/fixtures/vue-sfc/tsconfig.json b/tests/integration/fixtures/vue-sfc/tsconfig.json index 86423f3e4aa2..861b7d99bedf 100644 --- a/tests/integration/fixtures/vue-sfc/tsconfig.json +++ b/tests/integration/fixtures/vue-sfc/tsconfig.json @@ -1,5 +1,8 @@ { "compilerOptions": { "strict": true - } -} \ No newline at end of file + }, + "include": [ + "*.vue" + ] +}