Skip to content

Commit

Permalink
fix(vls): enable VLS check features
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Jul 27, 2021
1 parent 4f7abbe commit 52e94dd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/vite-plugin-checker/src/checkers/vls/initParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export function getInitParams(workspaceUri: URI): InitializeParams {
const defaultVLSConfig = getDefaultVLSConfig()

defaultVLSConfig.vetur.validation = {
template: false,
style: false,
script: false,
template: true,
style: true,
script: true,
interpolation: true,
templateProps: true,
}
Expand All @@ -33,17 +33,18 @@ export function getInitParams(workspaceUri: URI): InitializeParams {
export function getDefaultVLSConfig() {
return {
vetur: {
ignoreProjectWarning: false,
useWorkspaceDependencies: false,
validation: {
template: true,
templateProps: false,
templateProps: true,
interpolation: true,
style: true,
script: true,
},
completion: {
autoImport: false,
tagCasing: 'kebab',
tagCasing: 'initial',
scaffoldSnippetSources: {
workspace: '💼',
user: '🗒️',
Expand All @@ -66,6 +67,8 @@ export function getDefaultVLSConfig() {
},
languageFeatures: {
codeActions: true,
updateImportOnFileMove: true,
semanticTokens: true,
},
trace: {
server: 'off',
Expand Down
48 changes: 48 additions & 0 deletions playground/vue2-vls/__tests__/__snapshots__/test.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ exports[`vue2-vls serve get initial error and subsequent error 4`] = `
Loading Vetur in workspace path: <PROJECT_ROOT>/temp/vue2-vls
ERROR(VLS) Type 'number' is not assignable to type 'string'.
FILE <PROJECT_ROOT>/temp/vue2-vls/src/views/Home.vue:10:1
8 | <script lang=\\"ts\\">
9 | let a: string = 'ok'
> 10 | a = 123
| ^
11 |
12 | export default {}
13 | </script>
SUGGESTION(VLS) 'a' is declared but its value is never read.
FILE <PROJECT_ROOT>/temp/vue2-vls/src/views/Home.vue:9:5
7 |
8 | <script lang=\\"ts\\">
> 9 | let a: string = 'ok'
| ^
10 | a = 123
11 |
12 | export default {}
ERROR(VLS) Property 'msg1' does not exist on type 'CombinedVueInstance<{ msg: string; } & Vue, object, object, object, Record<never, any>>'. Did you mean 'msg'?
FILE <PROJECT_ROOT>/temp/vue2-vls/src/components/HelloWorld.vue:3:12
Expand Down Expand Up @@ -85,6 +109,30 @@ exports[`vue2-vls serve overlay: false 1`] = `
Loading Vetur in workspace path: <PROJECT_ROOT>/temp/vue2-vls
ERROR(VLS) Type 'number' is not assignable to type 'string'.
FILE <PROJECT_ROOT>/temp/vue2-vls/src/views/Home.vue:10:1
8 | <script lang=\\"ts\\">
9 | let a: string = 'ok'
> 10 | a = 123
| ^
11 |
12 | export default {}
13 | </script>
SUGGESTION(VLS) 'a' is declared but its value is never read.
FILE <PROJECT_ROOT>/temp/vue2-vls/src/views/Home.vue:9:5
7 |
8 | <script lang=\\"ts\\">
> 9 | let a: string = 'ok'
| ^
10 | a = 123
11 |
12 | export default {}
ERROR(VLS) Property 'msg1' does not exist on type 'CombinedVueInstance<{ msg: string; } & Vue, object, object, object, Record<never, any>>'. Did you mean 'msg'?
FILE <PROJECT_ROOT>/temp/vue2-vls/src/components/HelloWorld.vue:3:12
Expand Down
3 changes: 3 additions & 0 deletions playground/vue2-vls/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
</template>

<script lang="ts">
let a: string = 'ok'
a = 123
export default {}
</script>

0 comments on commit 52e94dd

Please sign in to comment.