From 8d37ddcabdc28f8a6038e44ece2b92c8d91aaf96 Mon Sep 17 00:00:00 2001 From: unvalley Date: Sat, 22 Jun 2024 22:12:51 +0900 Subject: [PATCH 1/8] chore: remove rome and use biome --- rome.json => biome.json | 0 package-lock.json | 257 ++++++++++++++++++++++++---------------- package.json | 35 ++---- 3 files changed, 169 insertions(+), 123 deletions(-) rename rome.json => biome.json (100%) diff --git a/rome.json b/biome.json similarity index 100% rename from rome.json rename to biome.json diff --git a/package-lock.json b/package-lock.json index fdaaf39..be2ddc4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "vscode-languageclient": "^8.0.2" }, "devDependencies": { + "@biomejs/biome": "^1.8.2", "@types/glob": "^8.0.0", "@types/mocha": "^10.0.1", "@types/node": "18.x", @@ -19,7 +20,6 @@ "@vscode/test-electron": "^2.2.1", "glob": "^8.0.3", "mocha": "^10.2.0", - "rome": "^10.0.1", "ts-loader": "^9.4.2", "typescript": "^4.9.4", "webpack": "^5.75.0", @@ -29,6 +29,161 @@ "vscode": "^1.70.0" } }, + "node_modules/@biomejs/biome": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.8.2.tgz", + "integrity": "sha512-XafCzLgs0xbH0bCjYKxQ63ig2V86fZQMq1jiy5pyLToWk9aHxA8GAUxyBtklPHtPYZPGEPOYglQHj4jyfUp+Iw==", + "dev": true, + "hasInstallScript": true, + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.8.2", + "@biomejs/cli-darwin-x64": "1.8.2", + "@biomejs/cli-linux-arm64": "1.8.2", + "@biomejs/cli-linux-arm64-musl": "1.8.2", + "@biomejs/cli-linux-x64": "1.8.2", + "@biomejs/cli-linux-x64-musl": "1.8.2", + "@biomejs/cli-win32-arm64": "1.8.2", + "@biomejs/cli-win32-x64": "1.8.2" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.8.2.tgz", + "integrity": "sha512-l9msLsTcSIAPqMsPIhodQmb50sEfaXPLQ0YW4cdj6INmd8iaOh/V9NceQb2366vACTJgcWDQ2RzlvURek1T68g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.8.2.tgz", + "integrity": "sha512-Fc4y/FuIxRSiB3TJ+y27vFDE/HJt4QgBuymktsIKEcBZvnKfsRjxvzVDunccRn4xbKgepnp+fn6BoS+ZIg/I3Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.8.2.tgz", + "integrity": "sha512-Q99qwP0qibkZxm2kfnt37OxeIlliDYf5ogi3zX9ij2DULzc+KtPA9Uj0wCljcJofOBsBYaHc7597Q+Bf/251ww==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.8.2.tgz", + "integrity": "sha512-WpT41QJJvkZa1eZq0WmD513zkC6AYaMI39HJKmKeiUeX2NZirG+bxv1YRDhqkns1NbBqo3+qrJqBkPmOW+xAVA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.8.2.tgz", + "integrity": "sha512-bjhhUVFchFid2gOjrvBe4fg8BShcpyFQTHuB/QQnfGxs1ddrGP30yq3fHfc6S6MoCcz9Tjd3Zzq1EfWfyy5iHA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.8.2.tgz", + "integrity": "sha512-rk1Wj4d3LIlAlIAS1m2jlyfOjkNbuY1lfwKvWIAeZC51yDMzwhRD7cReE5PE+jqLDtq60PX38hDPeKd7nA1S6A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.8.2.tgz", + "integrity": "sha512-EUbqmCmNWT5xhnxHrCAEBzJB1AnLqxTYoRjlxiCMzGvsy5jQzhCanJ8CT9kNsApW3pfPWBWkoTa7qrwWmwnEGA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.8.2.tgz", + "integrity": "sha512-n9H5oRUCk1uNezMgyJh9+hZdtfD8PXLLeq8DUzTycIhl0I1BulIoZ/uxWgRVDFDwAR1JHu1AykISCRFNGnc4iA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, "node_modules/@discoveryjs/json-ext": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", @@ -103,84 +258,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@rometools/cli-darwin-arm64": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-arm64/-/cli-darwin-arm64-10.0.1.tgz", - "integrity": "sha512-MwQjk3uhZrCu6LgIwJHREAsVt/mUQTGv7p8iosfaF8lCIxMVjyS+akbF/QcBufyW5sFtHYNWUEe/uKPHK4E//A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rometools/cli-darwin-x64": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/@rometools/cli-darwin-x64/-/cli-darwin-x64-10.0.1.tgz", - "integrity": "sha512-n010Wc/z9L8wRkRnR5boMhdWgDVGrTG/i7zL8u/3+F5aSUgLCywf9F/b3ex74tCJJfcwBLlhaAqAVQX6U1bIkA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rometools/cli-linux-arm64": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-arm64/-/cli-linux-arm64-10.0.1.tgz", - "integrity": "sha512-JljZsnud1KCfe36VNsVh/LrYdAzgbKbcsCTzeCjW9ROkMyNj8pmQ/gIUFxZ+PyhMFgowHIDGihoNf4m+pgpxkA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rometools/cli-linux-x64": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/@rometools/cli-linux-x64/-/cli-linux-x64-10.0.1.tgz", - "integrity": "sha512-jXIqd9iDyZUexk63CRfAXDA4zNDUHpErUmCejjGab3dhDt1KA40fDqKb+kxZpAhY3tQoWNSNQyo750zX5NawLw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rometools/cli-win32-arm64": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-arm64/-/cli-win32-arm64-10.0.1.tgz", - "integrity": "sha512-G/toRrKPhhi7SMYMyROq/E2c8/4xRX/67vFhVihuMvDDzhanIb99hEt5MMbM4HbYK1nnZBPyLN6LxVsxm9M9hA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rometools/cli-win32-x64": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/@rometools/cli-win32-x64/-/cli-win32-x64-10.0.1.tgz", - "integrity": "sha512-y299+VGoBufZntZj0Xz7w9DODU+6E5giXStfBDoa0fspXGNkYyYfD+HC6j9gUv4zpMZJ607XVvVHjpfwM/3ftA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@types/eslint": { "version": "8.56.10", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", @@ -2323,28 +2400,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/rome": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/rome/-/rome-10.0.1.tgz", - "integrity": "sha512-RfaDa+cSustBsjX6bj3fWqEhoNxXrK1uNgKHpkCHAqp20QMJXnCRtbokhirNMe0utyGI9GTO/sDoK7hJP7O8Bw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "rome": "bin/rome" - }, - "engines": { - "node": ">=14.*" - }, - "optionalDependencies": { - "@rometools/cli-darwin-arm64": "10.0.1", - "@rometools/cli-darwin-x64": "10.0.1", - "@rometools/cli-linux-arm64": "10.0.1", - "@rometools/cli-linux-x64": "10.0.1", - "@rometools/cli-win32-arm64": "10.0.1", - "@rometools/cli-win32-x64": "10.0.1" - } - }, "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", diff --git a/package.json b/package.json index 38bb252..0f6abd1 100644 --- a/package.json +++ b/package.json @@ -7,18 +7,14 @@ "engines": { "vscode": "^1.70.0" }, - "categories": [ - "Programming Languages" - ], + "categories": ["Programming Languages"], "icon": "images/icon.jpg", "repository": { "type": "git", "url": "https://github.com/erg-lang/vscode-erg.git" }, "main": "./dist/extension.js", - "activationEvents": [ - "onLanguage:erg" - ], + "activationEvents": ["onLanguage:erg"], "contributes": { "commands": [ { @@ -30,13 +26,8 @@ "languages": [ { "id": "erg", - "aliases": [ - "Erg", - "erg" - ], - "extensions": [ - ".er" - ], + "aliases": ["Erg", "erg"], + "extensions": [".er"], "configuration": "./language-configuration.json" } ], @@ -111,17 +102,18 @@ "pretest": "npm run compile-tests && npm run compile && npm run lint", "test": "node ./out/test/runTest.js", "type-check": "tsc --noEmit", - "lint": "rome check .", - "format": "rome format .", - "lint:fix": "rome check --apply .", - "lint:fix-suggested": "rome check --apply-suggested .", - "format:fix": "rome format --write ." + "lint": "biome check .", + "format": "biome format .", + "lint:fix": "biome check --write .", + "lint:fix-suggested": "biome check --write .", + "format:fix": "biome format --write ." }, "dependencies": { - "vscode-languageclient": "^8.0.2", - "compare-versions": "^6.1.0" + "compare-versions": "^6.1.0", + "vscode-languageclient": "^8.0.2" }, "devDependencies": { + "@biomejs/biome": "^1.8.2", "@types/glob": "^8.0.0", "@types/mocha": "^10.0.1", "@types/node": "18.x", @@ -129,13 +121,12 @@ "@vscode/test-electron": "^2.2.1", "glob": "^8.0.3", "mocha": "^10.2.0", - "rome": "^10.0.1", "ts-loader": "^9.4.2", "typescript": "^4.9.4", "webpack": "^5.75.0", "webpack-cli": "^5.0.1" }, "lint-staged": { - "*": "rome format --write" + "*": "biome format --write" } } From a5e6776fd958170fc6dd39deae4f9cd68c4e459c Mon Sep 17 00:00:00 2001 From: unvalley Date: Sat, 22 Jun 2024 22:13:51 +0900 Subject: [PATCH 2/8] chore: apply format:fix --- language-configuration.json | 86 ++++++++++++++++++------------------- src/commands.ts | 28 ++++++------ src/extension.ts | 41 +++++++++++++----- src/update.ts | 12 ++++-- 4 files changed, 94 insertions(+), 73 deletions(-) diff --git a/language-configuration.json b/language-configuration.json index 9c1410b..41d44b8 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -1,48 +1,44 @@ // guide: https://code.visualstudio.com/api/language-extensions/language-configuration-guide { - "comments": { - "lineComment": "#", - "blockComment": ["#[", "]#"] - }, - "brackets": [ - ["{", "}"], - ["[", "]"], - ["(", ")"] - ], - "autoClosingPairs": [ - { "open": "{", "close": "}" }, - { "open": "[", "close": "]" }, - { "open": "(", "close": ")" }, - { "open": "'", "close": "'", "notIn": ["string", "comment"] }, - { "open": "\"", "close": "\"", "notIn": ["string"] }, - { "open": "#[", "close": "]#", "notIn": ["string"] } - ], - "surroundingPairs": [ - ["{", "}"], - ["[", "]"], - ["(", ")"], - ["'", "'"], - ["\"", "\""], - ["|", "|"] - ], - "onEnterRules": [ - { - // indent at `:`, `=`, `->`, `=>`, `.`, `\` - "beforeText": "^\\s*.*?(?::|=|->|=>|\\.|\\\\)\\s*$", - "action": { "indent": "indent" } - }, - { - // e.g. `#[|]#`, `#[|` (`|` is the cursor) - "beforeText": { - "pattern": "^\\s*.*#\\[.*$" - }, - // If this is present, it is indented. e.g. `#[|` - // "afterText": { - // "pattern": "^\\s*.*\\]#.*$" - // }, - "action": { - "indent": "none" - } - } - ] + "comments": { + "lineComment": "#", + "blockComment": ["#[", "]#"] + }, + "brackets": [["{", "}"], ["[", "]"], ["(", ")"]], + "autoClosingPairs": [ + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "(", "close": ")" }, + { "open": "'", "close": "'", "notIn": ["string", "comment"] }, + { "open": "\"", "close": "\"", "notIn": ["string"] }, + { "open": "#[", "close": "]#", "notIn": ["string"] } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["'", "'"], + ["\"", "\""], + ["|", "|"] + ], + "onEnterRules": [ + { + // indent at `:`, `=`, `->`, `=>`, `.`, `\` + "beforeText": "^\\s*.*?(?::|=|->|=>|\\.|\\\\)\\s*$", + "action": { "indent": "indent" } + }, + { + // e.g. `#[|]#`, `#[|` (`|` is the cursor) + "beforeText": { + "pattern": "^\\s*.*#\\[.*$" + }, + // If this is present, it is indented. e.g. `#[|` + // "afterText": { + // "pattern": "^\\s*.*\\]#.*$" + // }, + "action": { + "indent": "none" + } + } + ] } diff --git a/src/commands.ts b/src/commands.ts index efc7194..f2d0eb8 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,19 +1,19 @@ // copied and modified from https://github.com/rust-lang/rust-analyzer/blob/27239fbb58a115915ffc1ce65ededc951eb00fd2/editors/code/src/commands.ts -import { LanguageClient, Location, Position } from 'vscode-languageclient/node'; -import { Uri, commands } from 'vscode'; +import { LanguageClient, Location, Position } from "vscode-languageclient/node"; +import { Uri, commands } from "vscode"; export async function showReferences( - client: LanguageClient | undefined, - uri: string, - position: Position, - locations: Location[] + client: LanguageClient | undefined, + uri: string, + position: Position, + locations: Location[], ) { - if (client) { - await commands.executeCommand( - "editor.action.showReferences", - Uri.parse(uri), - client.protocol2CodeConverter.asPosition(position), - locations.map(client.protocol2CodeConverter.asLocation) - ); - } + if (client) { + await commands.executeCommand( + "editor.action.showReferences", + Uri.parse(uri), + client.protocol2CodeConverter.asPosition(position), + locations.map(client.protocol2CodeConverter.asLocation), + ); + } } diff --git a/src/extension.ts b/src/extension.ts index d7524ca..8526499 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -26,13 +26,25 @@ async function startLanguageClient(context: ExtensionContext) { } return buildFeatures; })(); - const enableInlayHints = workspace.getConfiguration("vscode-erg").get("lsp.inlayHints", true); - const enableSemanticTokens = workspace.getConfiguration("vscode-erg").get("lsp.semanticTokens", true); - const enableHover = workspace.getConfiguration("vscode-erg").get("lsp.hover", true); - const smartCompletion = workspace.getConfiguration("vscode-erg").get("lsp.smartCompletion", true); + const enableInlayHints = workspace + .getConfiguration("vscode-erg") + .get("lsp.inlayHints", true); + const enableSemanticTokens = workspace + .getConfiguration("vscode-erg") + .get("lsp.semanticTokens", true); + const enableHover = workspace + .getConfiguration("vscode-erg") + .get("lsp.hover", true); + const smartCompletion = workspace + .getConfiguration("vscode-erg") + .get("lsp.smartCompletion", true); /* optional features */ - const checkOnType = workspace.getConfiguration("vscode-erg").get("lsp.checkOnType", false); - const lint = workspace.getConfiguration("vscode-erg").get("lsp.lint", false); + const checkOnType = workspace + .getConfiguration("vscode-erg") + .get("lsp.checkOnType", false); + const lint = workspace + .getConfiguration("vscode-erg") + .get("lsp.lint", false); let args = ["language-server", "--"]; if (!enableInlayHints) { args.push("--disable"); @@ -101,17 +113,24 @@ async function restartLanguageClient() { } export async function activate(context: ExtensionContext) { - const checkForUpdates = workspace.getConfiguration("vscode-erg").get("checkForUpdates", true); + const checkForUpdates = workspace + .getConfiguration("vscode-erg") + .get("checkForUpdates", true); if (checkForUpdates) { await checkForUpdate(); } context.subscriptions.push( - commands.registerCommand("erg.restartLanguageServer", () => restartLanguageClient()) + commands.registerCommand("erg.restartLanguageServer", () => + restartLanguageClient(), + ), ); context.subscriptions.push( - commands.registerCommand("erg.showReferences", async (uri, position, locations) => { - await showReferences(client, uri, position, locations) - }) + commands.registerCommand( + "erg.showReferences", + async (uri, position, locations) => { + await showReferences(client, uri, position, locations); + }, + ), ); await startLanguageClient(context); } diff --git a/src/update.ts b/src/update.ts index 847a928..4008e1e 100644 --- a/src/update.ts +++ b/src/update.ts @@ -48,14 +48,18 @@ export async function checkForUpdate() { return; } if (currentVersion === undefined) { - let selection = await window.showInformationMessage("Erg is not installed.", "Install"); + let selection = await window.showInformationMessage( + "Erg is not installed.", + "Install", + ); if (selection === "Install") { await updateToolchain(); } } else if (compare(currentVersion, latestVersion, "<")) { let selection = await window.showInformationMessage( `A new version of Erg is available. Current version: ${currentVersion}, Latest version: ${latestVersion}`, - "Update", "Not now", + "Update", + "Not now", ); if (selection === "Update") { await updateToolchain(); @@ -74,6 +78,8 @@ async function updateToolchain() { } }); }); - terminal.sendText("echo y | python3 <(curl -L https://github.com/mtshiba/ergup/raw/main/ergup.py) && exit"); + terminal.sendText( + "echo y | python3 <(curl -L https://github.com/mtshiba/ergup/raw/main/ergup.py) && exit", + ); await result; } From 6c97b7b55098bf37e4f3a95ddd50667d767133ad Mon Sep 17 00:00:00 2001 From: unvalley Date: Sat, 22 Jun 2024 22:14:41 +0900 Subject: [PATCH 3/8] chore: apply lint:fix --- package.json | 4 ++-- src/commands.ts | 2 +- src/extension.ts | 10 +++++----- src/update.ts | 8 ++++---- webpack.config.js | 2 -- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 0f6abd1..0db277d 100644 --- a/package.json +++ b/package.json @@ -104,8 +104,8 @@ "type-check": "tsc --noEmit", "lint": "biome check .", "format": "biome format .", - "lint:fix": "biome check --write .", - "lint:fix-suggested": "biome check --write .", + "lint:fix": "biome lint --write .", + "lint:fix-unsafe": "biome lint --write --unsafe .", "format:fix": "biome format --write ." }, "dependencies": { diff --git a/src/commands.ts b/src/commands.ts index f2d0eb8..eb977c1 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,5 +1,5 @@ // copied and modified from https://github.com/rust-lang/rust-analyzer/blob/27239fbb58a115915ffc1ce65ededc951eb00fd2/editors/code/src/commands.ts -import { LanguageClient, Location, Position } from "vscode-languageclient/node"; +import type { LanguageClient, Location, Position } from "vscode-languageclient/node"; import { Uri, commands } from "vscode"; export async function showReferences( diff --git a/src/extension.ts b/src/extension.ts index 8526499..067ae20 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,8 +1,8 @@ -import { ExtensionContext, commands, window, workspace } from "vscode"; +import { type ExtensionContext, commands, window, workspace } from "vscode"; import { LanguageClient, - LanguageClientOptions, - ServerOptions, + type LanguageClientOptions, + type ServerOptions, } from "vscode-languageclient/node"; import { spawn } from "child_process"; import { showReferences } from "./commands"; @@ -13,7 +13,7 @@ let client: LanguageClient | undefined; async function startLanguageClient(context: ExtensionContext) { try { const executablePath = (() => { - let executablePath = workspace + const executablePath = workspace .getConfiguration("vscode-erg") .get("executablePath", ""); return executablePath === "" ? "erg" : executablePath; @@ -45,7 +45,7 @@ async function startLanguageClient(context: ExtensionContext) { const lint = workspace .getConfiguration("vscode-erg") .get("lsp.lint", false); - let args = ["language-server", "--"]; + const args = ["language-server", "--"]; if (!enableInlayHints) { args.push("--disable"); args.push("inlayHints"); diff --git a/src/update.ts b/src/update.ts index 4008e1e..e257230 100644 --- a/src/update.ts +++ b/src/update.ts @@ -5,7 +5,7 @@ import { compare } from "compare-versions"; async function currentErgVersion() { let version = ""; const executablePath = (() => { - let executablePath = workspace + const executablePath = workspace .getConfiguration("vscode-erg") .get("executablePath", ""); return executablePath === "" ? "erg" : executablePath; @@ -48,7 +48,7 @@ export async function checkForUpdate() { return; } if (currentVersion === undefined) { - let selection = await window.showInformationMessage( + const selection = await window.showInformationMessage( "Erg is not installed.", "Install", ); @@ -56,7 +56,7 @@ export async function checkForUpdate() { await updateToolchain(); } } else if (compare(currentVersion, latestVersion, "<")) { - let selection = await window.showInformationMessage( + const selection = await window.showInformationMessage( `A new version of Erg is available. Current version: ${currentVersion}, Latest version: ${latestVersion}`, "Update", "Not now", @@ -71,7 +71,7 @@ async function updateToolchain() { const terminal = window.createTerminal("Erg Update"); terminal.show(true); setTimeout(() => {}, 500); - let result = new Promise((resolve) => { + const result = new Promise((resolve) => { window.onDidCloseTerminal((t) => { if (t === terminal) { resolve(true); diff --git a/webpack.config.js b/webpack.config.js index 6afa5b9..07b8d45 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,4 @@ -//@ts-check -"use strict"; const path = require("path"); From 13a12ba32fd912576ad52e85818c93ebb1b6336d Mon Sep 17 00:00:00 2001 From: unvalley Date: Sat, 22 Jun 2024 22:21:09 +0900 Subject: [PATCH 4/8] chore: update biome.json --- biome.json | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/biome.json b/biome.json index 8bcf6a9..6d42e83 100644 --- a/biome.json +++ b/biome.json @@ -1,11 +1,15 @@ { + "$schema": "node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, "linter": { - "rules": { - "recommended": true - }, - "ignore": ["/dist/", "/out/", "/.vscode-test/"] + "enabled": true, + "rules": { "recommended": true }, + "ignore": [".vscode"] }, - "formatter": { - "ignore": ["/dist/", "/out/", "/.vscode-test/"] - } + "formatter": { "enabled": true, "ignore": [".vscode"] }, + "organizeImports": { "enabled": false } } From 3a185da7be51403d12b1fddbe77e1d4474c4a2ff Mon Sep 17 00:00:00 2001 From: unvalley Date: Sat, 22 Jun 2024 22:21:30 +0900 Subject: [PATCH 5/8] chore: apply format and lint fix --- src/commands.ts | 6 +++++- src/extension.ts | 2 +- src/test/runTest.ts | 2 +- src/test/suite/extension.test.ts | 2 +- src/test/suite/index.ts | 2 +- src/update.ts | 4 ++-- webpack.config.js | 4 +--- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index eb977c1..03d92f1 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,5 +1,9 @@ // copied and modified from https://github.com/rust-lang/rust-analyzer/blob/27239fbb58a115915ffc1ce65ededc951eb00fd2/editors/code/src/commands.ts -import type { LanguageClient, Location, Position } from "vscode-languageclient/node"; +import type { + LanguageClient, + Location, + Position, +} from "vscode-languageclient/node"; import { Uri, commands } from "vscode"; export async function showReferences( diff --git a/src/extension.ts b/src/extension.ts index 067ae20..98cff61 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,7 +4,7 @@ import { type LanguageClientOptions, type ServerOptions, } from "vscode-languageclient/node"; -import { spawn } from "child_process"; +import { spawn } from "node:child_process"; import { showReferences } from "./commands"; import { checkForUpdate } from "./update"; diff --git a/src/test/runTest.ts b/src/test/runTest.ts index f6867cc..3314201 100644 --- a/src/test/runTest.ts +++ b/src/test/runTest.ts @@ -1,4 +1,4 @@ -import * as path from "path"; +import * as path from "node:path"; import { runTests } from "@vscode/test-electron"; diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts index 8857ba1..45ab914 100644 --- a/src/test/suite/extension.test.ts +++ b/src/test/suite/extension.test.ts @@ -1,4 +1,4 @@ -import * as assert from "assert"; +import * as assert from "node:assert"; // You can import and use all API from the 'vscode' module // as well as import your extension to test it diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts index 44c0027..b4a35d7 100644 --- a/src/test/suite/index.ts +++ b/src/test/suite/index.ts @@ -1,4 +1,4 @@ -import * as path from "path"; +import * as path from "node:path"; import Mocha from "mocha"; import glob from "glob"; diff --git a/src/update.ts b/src/update.ts index e257230..c81e82d 100644 --- a/src/update.ts +++ b/src/update.ts @@ -1,5 +1,5 @@ import { window, workspace } from "vscode"; -import { spawn } from "child_process"; +import { spawn } from "node:child_process"; import { compare } from "compare-versions"; async function currentErgVersion() { @@ -37,7 +37,7 @@ async function latestErgVersion(): Promise { if (versionProcess.exitCode !== 0) { return undefined; } - return JSON.parse(version)["tag_name"]; + return JSON.parse(version).tag_name; } export async function checkForUpdate() { diff --git a/webpack.config.js b/webpack.config.js index 07b8d45..7d521a4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,4 @@ - - -const path = require("path"); +const path = require("node:path"); //@ts-check /** @typedef {import('webpack').Configuration} WebpackConfig **/ From 5ea0f49ad878419072090cded92ec8a237debb1f Mon Sep 17 00:00:00 2001 From: unvalley Date: Sat, 22 Jun 2024 22:22:59 +0900 Subject: [PATCH 6/8] chore: lint should be check --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0db277d..2d503ff 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,8 @@ "pretest": "npm run compile-tests && npm run compile && npm run lint", "test": "node ./out/test/runTest.js", "type-check": "tsc --noEmit", - "lint": "biome check .", + "check": "biome check .", + "lint": "biome lint .", "format": "biome format .", "lint:fix": "biome lint --write .", "lint:fix-unsafe": "biome lint --write --unsafe .", From 214f27002c248dbd745051c0c4417cc9f228dbaf Mon Sep 17 00:00:00 2001 From: unvalley Date: Sat, 22 Jun 2024 22:24:23 +0900 Subject: [PATCH 7/8] chore: recommend biomejs.biome extension --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 6fb3218..0b46678 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["amodio.tsl-problem-matcher", "rome.rome"] + "recommendations": ["amodio.tsl-problem-matcher", "biomejs.biome"] } From 3c22259ad78383e088af71ad06d3fabc92dc9fc7 Mon Sep 17 00:00:00 2001 From: unvalley Date: Sat, 22 Jun 2024 22:25:04 +0900 Subject: [PATCH 8/8] chore: ignore biome.json in .vscodeignore --- .vscodeignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscodeignore b/.vscodeignore index c6baa42..b8f80b0 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -10,4 +10,4 @@ src/** .gitignore vsc-extension-quickstart.md webpack.config.js -rome.json +biome.json