Skip to content

Commit

Permalink
Fix eslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed May 31, 2024
1 parent b647038 commit cbba4c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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, "", "----", ""]
Expand Down Expand Up @@ -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, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 [];
}
}
Expand Down

0 comments on commit cbba4c9

Please sign in to comment.