Skip to content

Commit

Permalink
Fix #2249
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Sep 6, 2020
1 parent c2512c2 commit 8a59a06
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### 0.27.2

- Add a config `vetur.validation.props` to toggle props validation. Default to false. #2249.
- 🙌 Add HTML folding. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #2234 and #2244.
- 🙌 Fix array get error type in v-for. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #1790 and #2248.
- 🙌 Fix corner case and add v-model support when prop validation. Thanks to contribution from [@yoyo930021](https://github.com/yoyo930021). #2241.
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@
"default": true,
"description": "Validate vue-html in <template> using eslint-plugin-vue"
},
"vetur.validation.templateProps": {
"type": "boolean",
"default": false,
"description": "Validate props usage in <template> region. Show error/warning for not passing declared props to child components."
},
"vetur.validation.interpolation": {
"type": "boolean",
"default": true,
Expand Down
2 changes: 2 additions & 0 deletions server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface VLSConfig {
};
validation: {
template: boolean;
templateProps: boolean;
interpolation: boolean;
style: boolean;
script: boolean;
Expand Down Expand Up @@ -79,6 +80,7 @@ export function getDefaultVLSConfig(): VLSFullConfig {
useWorkspaceDependencies: false,
validation: {
template: true,
templateProps: false,
interpolation: true,
style: true,
script: true
Expand Down
8 changes: 5 additions & 3 deletions server/src/modes/template/htmlMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ export class HTMLMode implements LanguageMode {
doValidation(document: TextDocument) {
const diagnostics = [];

const info = this.vueInfoService ? this.vueInfoService.getInfo(document) : undefined;
if (info && info.componentInfo.childComponents) {
diagnostics.push(...doPropValidation(document, this.vueDocuments.refreshAndGet(document), info));
if (this.config.vetur.validation.templateProps) {
const info = this.vueInfoService ? this.vueInfoService.getInfo(document) : undefined;
if (info && info.componentInfo.childComponents) {
diagnostics.push(...doPropValidation(document, this.vueDocuments.refreshAndGet(document), info));
}
}

if (this.config.vetur.validation.template) {
Expand Down

0 comments on commit 8a59a06

Please sign in to comment.