From cbba4c9bf2c463dd9a23383b9d99a745dddec41a Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Fri, 31 May 2024 17:48:00 +0200 Subject: [PATCH] Fix eslint warnings --- .../workflow-tests-language-service/src/schema/adapter.ts | 2 +- .../src/services/completion/helper.ts | 8 ++++---- .../yaml-language-service/src/parser/yamlDocument.ts | 2 +- .../yaml-language-service/src/services/yamlFormatter.ts | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/packages/workflow-tests-language-service/src/schema/adapter.ts b/server/packages/workflow-tests-language-service/src/schema/adapter.ts index 9a512c7..9ca59f7 100644 --- a/server/packages/workflow-tests-language-service/src/schema/adapter.ts +++ b/server/packages/workflow-tests-language-service/src/schema/adapter.ts @@ -1342,7 +1342,7 @@ export function safeCreateUnicodeRegExp(pattern: string): RegExp { // fall back to regular regexp if we cannot create Unicode one try { return new RegExp(pattern, "u"); - } catch (ignore) { + } catch (_ignore) { return new RegExp(pattern); } } diff --git a/server/packages/workflow-tests-language-service/src/services/completion/helper.ts b/server/packages/workflow-tests-language-service/src/services/completion/helper.ts index c0ec3b6..2e6c922 100644 --- a/server/packages/workflow-tests-language-service/src/services/completion/helper.ts +++ b/server/packages/workflow-tests-language-service/src/services/completion/helper.ts @@ -920,8 +920,8 @@ ${this.indentation}${this.indentation}$0 .map((m) => +m.replace(/\${([0-9]+)[:|]/g, "$1").replace("$", "")) // get numbers form $1 or ${1:...} .reduce((p, n) => (n > p ? n : p), 0); // find the max one const reindexedStr = text - .replace(/\$([0-9]+)/g, (s, args) => "$" + (+args + max$index)) // increment each by max$index - .replace(/\${([0-9]+)[:|]/g, (s, args) => "${" + (+args + max$index) + ":"); // increment each by max$index + .replace(/\$([0-9]+)/g, (_s, args) => "$" + (+args + max$index)) // increment each by max$index + .replace(/\${([0-9]+)[:|]/g, (_s, args) => "${" + (+args + max$index) + ":"); // increment each by max$index max$index += max$indexLocal; return reindexedStr; }); @@ -950,7 +950,7 @@ ${this.indentation}${this.indentation}$0 completionItem.textEdit.newText = insertText; } // remove $x or use {$x:value} in documentation - const mdText = insertText.replace(/\${[0-9]+[:|](.*)}/g, (s, arg) => arg).replace(/\$([0-9]+)/g, ""); + const mdText = insertText.replace(/\${[0-9]+[:|](.*)}/g, (_s, arg) => arg).replace(/\$([0-9]+)/g, ""); const originalDocumentation = completionItem.documentation ? [completionItem.documentation, "", "----", ""] @@ -1330,7 +1330,7 @@ ${this.indentation}${this.indentation}$0 let res: string | MarkupContent = documentation; if (this.doesSupportMarkdown()) { insertText = insertText - .replace(/\${[0-9]+[:|](.*)}/g, (s, arg) => { + .replace(/\${[0-9]+[:|](.*)}/g, (_s, arg) => { return arg; }) .replace(/\$([0-9]+)/g, ""); diff --git a/server/packages/yaml-language-service/src/parser/yamlDocument.ts b/server/packages/yaml-language-service/src/parser/yamlDocument.ts index 14deeac..d12c164 100644 --- a/server/packages/yaml-language-service/src/parser/yamlDocument.ts +++ b/server/packages/yaml-language-service/src/parser/yamlDocument.ts @@ -267,7 +267,7 @@ export class YAMLSubDocument { let offsetDiff = this.parsedDocument.range?.[2] ?? 0; let maxOffset = this.parsedDocument.range?.[0] ?? 0; let closestNode: YamlNode | undefined = undefined; - visit(this.parsedDocument, (key, node) => { + visit(this.parsedDocument, (_key, node) => { if (!node) { return; } diff --git a/server/packages/yaml-language-service/src/services/yamlFormatter.ts b/server/packages/yaml-language-service/src/services/yamlFormatter.ts index af28c09..d7291c3 100644 --- a/server/packages/yaml-language-service/src/services/yamlFormatter.ts +++ b/server/packages/yaml-language-service/src/services/yamlFormatter.ts @@ -1,7 +1,7 @@ -import { Range, Position, TextEdit, FormattingOptions } from "vscode-languageserver-types"; -import { CustomFormatterOptions, LanguageSettings } from "../yamlLanguageService"; import { TextDocument } from "vscode-languageserver-textdocument"; -import { parse, stringify, ToStringOptions } from "yaml"; +import { FormattingOptions, Position, Range, TextEdit } from "vscode-languageserver-types"; +import { ToStringOptions, parse, stringify } from "yaml"; +import { CustomFormatterOptions, LanguageSettings } from "../yamlLanguageService"; export class YAMLFormatter { private formatterEnabled? = true; @@ -29,6 +29,7 @@ export class YAMLFormatter { return [TextEdit.replace(Range.create(Position.create(0, 0), document.positionAt(text.length)), formatted)]; } catch (error) { + console.debug("Error formatting YAML document", error); return []; } }