checked const value for the Boolean type#1066
Conversation
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
| export function equals(one: any, other: any): boolean { | ||
| export function equals(one: any, other: any, type?: any): boolean { |
Check warning
Code scanning / ESLint
Disallow the `any` type Warning
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
| export function equals(one: any, other: any): boolean { | ||
| export function equals(one: any, other: any, type?: any): boolean { |
Check warning
Code scanning / ESLint
Disallow the `any` type Warning
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
| export function equals(one: any, other: any): boolean { | ||
| export function equals(one: any, other: any, type?: any): boolean { |
Check warning
Code scanning / ESLint
Disallow the `any` type Warning
There was a problem hiding this comment.
The quickfix is still broken ( there is a quickfix entry with no label that does nothing when the value is wrong ).
eg. if you have
prop: falsewith the existing schema it will not suggest changing it to true
I couldn't find an existing test case that has a schema with "const": true, "type": "boolean". It would be nice to have one so that we can detect any regressions.
|
For the quickfix, something like this could solve it. We should add a test case too, though. diff --git a/src/languageservice/services/yamlCodeActions.ts b/src/languageservice/services/yamlCodeActions.ts
index da0c7ee..85eba90 100644
--- a/src/languageservice/services/yamlCodeActions.ts
+++ b/src/languageservice/services/yamlCodeActions.ts
@@ -348,10 +348,11 @@ export class YamlCodeActions {
continue;
}
for (const value of values) {
+ const cleanedValue = typeof value === 'boolean' ? `${value}` : value;
results.push(
CodeAction.create(
- value,
- createWorkspaceEdit(document.uri, [TextEdit.replace(diagnostic.range, value)]),
+ cleanedValue,
+ createWorkspaceEdit(document.uri, [TextEdit.replace(diagnostic.range, cleanedValue)]),
CodeActionKind.QuickFix
)
); |
…ub.com/msivasubramaniaan/yaml-language-server into fix-boolean-validation-with-cont-value
datho7561
left a comment
There was a problem hiding this comment.
This fixes the validation issue. The quickfix can be fixed later. Thanks, Muthu!

What does this PR do?
This PR do the validation for the const value of Boolean type
What issues does this PR fix or reference?
redhat-developer/vscode-yaml#1116
Is it tested? How?
Yes with existing test case