From 4769045f0015c52ed1c370363b20a9a1a5cf8937 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 24 Mar 2022 00:32:05 +0800 Subject: [PATCH] build: fix typescript version of vls --- package.json | 10 +- .../__tests__/e2e/Sandbox/Sandbox.ts | 6 +- .../unit/__snapshots__/vlsConfig.spec.ts.snap | 2 + .../unit/fixtures/eslintDiagnostic.ts | 1 + packages/vite-plugin-checker/package.json | 3 +- .../src/checkers/vls/diagnostics.ts | 1 + .../src/checkers/vueTsc/prepareVueTsc.ts | 19 +- .../__snapshots__/overlay-true.spec.ts.snap | 16 +- playground/basic/package.json | 6 +- playground/eslint/package.json | 6 +- playground/multiple-hmr/package.json | 2 +- playground/multiple-reload/package.json | 2 +- playground/react-ts/package.json | 2 +- playground/vue2-vls/package.json | 6 +- .../__tests__/__snapshots__/test.spec.ts.snap | 16 +- .../vue3-vue-tsc/__tests__/test.spec.ts | 4 +- playground/vue3-vue-tsc/package.json | 2 +- pnpm-lock.yaml | 4659 +++++++---------- pnpm-workspace.yaml | 2 +- 19 files changed, 1994 insertions(+), 2771 deletions(-) diff --git a/package.json b/package.json index 1b076d98..e21c844b 100644 --- a/package.json +++ b/package.json @@ -39,13 +39,13 @@ "@types/rimraf": "^3.0.0", "@types/semver": "^7.3.6", "@types/ws": "^8.5.3", - "@typescript-eslint/eslint-plugin": "^4.15.2", - "@typescript-eslint/parser": "^4.15.2", + "@typescript-eslint/eslint-plugin": "^5.16.0", + "@typescript-eslint/parser": "^5.16.0", "chalk": "^4.1.1", "conventional-changelog-cli": "^2.1.1", "cross-env": "^7.0.3", - "eslint": "^7.28.0", - "eslint-config-alloy": "^3.10.0", + "eslint": "^8.11.0", + "eslint-config-alloy": "^4.5.1", "eslint-plugin-svelte3": "^3.4.0", "execa": "^5.1.1", "fast-json-stable-stringify": "^2.1.0", @@ -68,7 +68,7 @@ "strip-ansi": "^7.0.0", "svelte": "^3.46.3", "ts-jest": "^27.1.3", - "typescript": "^4.6.2", + "typescript": "~4.5.5", "vite": "^2.7.13", "vite-plugin-checker": "workspace:*", "ws": "^8.5.0", diff --git a/packages/vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox.ts b/packages/vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox.ts index a11d8576..7c9f08f2 100644 --- a/packages/vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox.ts +++ b/packages/vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox.ts @@ -28,11 +28,11 @@ export function proxyConsoleInTest(accumulate = true) { } export async function sleepForServerReady(ratio = 1) { - await sleep(process.env.CI ? 10000 * ratio : 5000 * ratio) + await sleep(process.env.CI ? 10e3 * ratio : 5e3 * ratio) } -export async function sleepForEdit() { - await sleep(process.env.CI ? 4000 : 2000) +export async function sleepForEdit(ratio = 1) { + await sleep(process.env.CI ? 4e3 * ratio : 2e3 * ratio) } export function resetReceivedLog() { diff --git a/packages/vite-plugin-checker/__tests__/unit/__snapshots__/vlsConfig.spec.ts.snap b/packages/vite-plugin-checker/__tests__/unit/__snapshots__/vlsConfig.spec.ts.snap index a1024c73..56bb7827 100644 --- a/packages/vite-plugin-checker/__tests__/unit/__snapshots__/vlsConfig.spec.ts.snap +++ b/packages/vite-plugin-checker/__tests__/unit/__snapshots__/vlsConfig.spec.ts.snap @@ -10,6 +10,7 @@ Object { "javascript": Object { "format": Object {}, }, + "languageStylus": Object {}, "stylusSupremacy": Object {}, "typescript": Object { "format": Object {}, @@ -78,6 +79,7 @@ Object { "javascript": Object { "format": Object {}, }, + "languageStylus": Object {}, "stylusSupremacy": Object {}, "typescript": Object { "format": Object {}, diff --git a/packages/vite-plugin-checker/__tests__/unit/fixtures/eslintDiagnostic.ts b/packages/vite-plugin-checker/__tests__/unit/fixtures/eslintDiagnostic.ts index 6b7ca2ce..5ced9a28 100644 --- a/packages/vite-plugin-checker/__tests__/unit/fixtures/eslintDiagnostic.ts +++ b/packages/vite-plugin-checker/__tests__/unit/fixtures/eslintDiagnostic.ts @@ -45,6 +45,7 @@ export const eslintResult1: ESLint.LintResult = { }, ], errorCount: 2, + fatalErrorCount: 2, warningCount: 0, fixableErrorCount: 2, fixableWarningCount: 0, diff --git a/packages/vite-plugin-checker/package.json b/packages/vite-plugin-checker/package.json index 402ca320..30394fe0 100644 --- a/packages/vite-plugin-checker/package.json +++ b/packages/vite-plugin-checker/package.json @@ -59,8 +59,9 @@ "esbuild": "^0.14.13", "npm-run-all": "^4.1.5", "optionator": "^0.9.1", - "vls": "^0.7.2", + "vls": "^0.7.6", "vue-tsc": "0.33.5", + "typescript": "~4.5.5", "@volar/vue-typescript": "^0.33.0" } } diff --git a/packages/vite-plugin-checker/src/checkers/vls/diagnostics.ts b/packages/vite-plugin-checker/src/checkers/vls/diagnostics.ts index c0668b36..bac317c0 100644 --- a/packages/vite-plugin-checker/src/checkers/vls/diagnostics.ts +++ b/packages/vite-plugin-checker/src/checkers/vls/diagnostics.ts @@ -36,6 +36,7 @@ import { DeepPartial } from '../../types' import { getInitParams, VlsOptions } from './initParams' import { FileDiagnosticManager } from '../../FileDiagnosticManager' + enum DOC_VERSION { init = -1, } diff --git a/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts b/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts index 8cb9d37b..47f0c9eb 100644 --- a/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts +++ b/packages/vite-plugin-checker/src/checkers/vueTsc/prepareVueTsc.ts @@ -45,7 +45,7 @@ export function prepareVueTsc() { const tsVersion = require('typescript/package.json').version if (toDirVersion !== tsVersion) { shouldPrepare = true - fs.rmdirSync(tsDirTo) + rimraf(tsDirTo) } } else { shouldPrepare = true @@ -88,3 +88,20 @@ function modifyFileText( } fs.writeFileSync(filePath, newText) } + +/** + * https://stackoverflow.com/a/42505874 + */ +function rimraf(dir_path: string) { + if (fs.existsSync(dir_path)) { + fs.readdirSync(dir_path).forEach(function (entry) { + var entry_path = path.join(dir_path, entry) + if (fs.lstatSync(entry_path).isDirectory()) { + rimraf(entry_path) + } else { + fs.unlinkSync(entry_path) + } + }) + fs.rmdirSync(dir_path) + } +} diff --git a/playground/basic/__tests__/__snapshots__/overlay-true.spec.ts.snap b/playground/basic/__tests__/__snapshots__/overlay-true.spec.ts.snap index 65e484e7..c694598f 100644 --- a/playground/basic/__tests__/__snapshots__/overlay-true.spec.ts.snap +++ b/playground/basic/__tests__/__snapshots__/overlay-true.spec.ts.snap @@ -5,21 +5,29 @@ exports[`overlay-true overlay prompts and changes 1`] = `"Unexpected var, use le exports[`overlay-true overlay prompts and changes 2`] = `"/temp/basic/src/main.ts:3:1"`; exports[`overlay-true overlay prompts and changes 3`] = ` -" 1 | import { text } from './text' +" + + 1 | import { text } from './text' 2 | > 3 | var hello = 'Hello' | ^^^^^^^^^^^^^^^^^^^ 4 | 5 | const rootDom = document.querySelector('#root')! as HTMLElement - 6 | rootDom.innerHTML = hello + text" + 6 | rootDom.innerHTML = hello + text + + " `; exports[`overlay-true overlay prompts and changes 4`] = ` -" 1 | import { text } from './text' +" + + 1 | import { text } from './text' 2 | > 3 | var hello = 'Hello1' | ^^^^^^^^^^^^^^^^^^^^ 4 | 5 | const rootDom = document.querySelector('#root')! as HTMLElement - 6 | rootDom.innerHTML = hello + text" + 6 | rootDom.innerHTML = hello + text + + " `; diff --git a/playground/basic/package.json b/playground/basic/package.json index a1452900..338209ed 100644 --- a/playground/basic/package.json +++ b/playground/basic/package.json @@ -15,9 +15,9 @@ "devDependencies": { "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", - "eslint": "^7.28.0", - "@typescript-eslint/eslint-plugin": "^4.15.2", - "typescript": "^4.6.2", + "eslint": "^8.11.0", + "@typescript-eslint/eslint-plugin": "^5.16.0", + "typescript": "~4.5.5", "vite": "^2.7.13", "vite-plugin-checker": "workspace:*" } diff --git a/playground/eslint/package.json b/playground/eslint/package.json index fb854e2f..9ec98784 100644 --- a/playground/eslint/package.json +++ b/playground/eslint/package.json @@ -15,9 +15,9 @@ "devDependencies": { "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", - "eslint": "^7.28.0", - "@typescript-eslint/eslint-plugin": "^4.15.2", - "typescript": "^4.6.2", + "eslint": "^8.11.0", + "@typescript-eslint/eslint-plugin": "^5.16.0", + "typescript": "~4.5.5", "vite": "^2.7.13", "vite-plugin-checker": "workspace:*" } diff --git a/playground/multiple-hmr/package.json b/playground/multiple-hmr/package.json index 92803d48..4bb73605 100644 --- a/playground/multiple-hmr/package.json +++ b/playground/multiple-hmr/package.json @@ -16,7 +16,7 @@ "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@vitejs/plugin-react": "^1.1.4", - "typescript": "^4.6.2", + "typescript": "~4.5.5", "vite": "^2.7.13", "vite-plugin-checker": "workspace:*" } diff --git a/playground/multiple-reload/package.json b/playground/multiple-reload/package.json index 42db9009..7a530a96 100644 --- a/playground/multiple-reload/package.json +++ b/playground/multiple-reload/package.json @@ -16,7 +16,7 @@ "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@vitejs/plugin-react-refresh": "^1.3.1", - "typescript": "^4.6.2", + "typescript": "~4.5.5", "vite": "^2.7.13", "vite-plugin-checker": "workspace:*" } diff --git a/playground/react-ts/package.json b/playground/react-ts/package.json index cf1f85e8..59918d24 100644 --- a/playground/react-ts/package.json +++ b/playground/react-ts/package.json @@ -16,7 +16,7 @@ "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@vitejs/plugin-react": "^1.1.4", - "typescript": "^4.6.2", + "typescript": "~4.5.5", "vite": "^2.7.13", "vite-plugin-checker": "workspace:*" } diff --git a/playground/vue2-vls/package.json b/playground/vue2-vls/package.json index 2af3af9d..044b9b47 100644 --- a/playground/vue2-vls/package.json +++ b/playground/vue2-vls/package.json @@ -25,12 +25,12 @@ "eslint-plugin-vue": "^7.6.0", "prettier": "2.3.0", "sass": "^1.32.7", - "typescript": "^4.6.2", "vite": "^2.7.13", - "vite-plugin-checker": "workspace:*", "vite-plugin-components": "^0.12.2", "vite-plugin-vue2": "^1.9.0", - "vls": "^0.7.2", + "typescript": "~4.3.2", + "vite-plugin-checker": "workspace:*", + "vls": "^0.7.6", "vue-template-compiler": "^2.6.14" } } diff --git a/playground/vue3-vue-tsc/__tests__/__snapshots__/test.spec.ts.snap b/playground/vue3-vue-tsc/__tests__/__snapshots__/test.spec.ts.snap index 2913d7c6..c8ccf489 100644 --- a/playground/vue3-vue-tsc/__tests__/__snapshots__/test.spec.ts.snap +++ b/playground/vue3-vue-tsc/__tests__/__snapshots__/test.spec.ts.snap @@ -1,11 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`vue3-vue-tsc serve get initial error and subsequent error 1`] = `"[{\\"checkerId\\":\\"TypeScript\\",\\"frame\\":\\" 1 | /n 5 |/n 6 |