From 0d155ee0cd15a471745b658c9986077afa9bc529 Mon Sep 17 00:00:00 2001 From: GreasySlug <9619abgoni@gmail.com> Date: Wed, 22 May 2024 00:08:05 +0900 Subject: [PATCH] style: auto format and fix --- extension/src/commands.ts | 28 +++++++++++----------- extension/src/extension.ts | 20 +++++----------- extension/src/test/runTest.ts | 2 +- extension/src/test/suite/extension.test.ts | 2 +- extension/src/test/suite/index.ts | 8 ++++--- extension/webpack.config.js | 4 +--- 6 files changed, 28 insertions(+), 36 deletions(-) diff --git a/extension/src/commands.ts b/extension/src/commands.ts index efc7194..5c0e8bb 100644 --- a/extension/src/commands.ts +++ b/extension/src/commands.ts @@ -1,19 +1,19 @@ +import { Uri, commands } from "vscode"; // 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 type { LanguageClient, Location, Position } from "vscode-languageclient/node"; 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/extension/src/extension.ts b/extension/src/extension.ts index a5dc391..60683ee 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -1,9 +1,5 @@ -import { ExtensionContext, commands, window, workspace } from "vscode"; -import { - LanguageClient, - LanguageClientOptions, - ServerOptions, -} from "vscode-languageclient/node"; +import { type ExtensionContext, commands, window, workspace } from "vscode"; +import { LanguageClient, type LanguageClientOptions, type ServerOptions } from "vscode-languageclient/node"; import { showReferences } from "./commands"; let client: LanguageClient | undefined; @@ -11,9 +7,7 @@ let client: LanguageClient | undefined; async function startLanguageClient(context: ExtensionContext) { try { const executablePath = (() => { - const executablePath = workspace - .getConfiguration("pylyzer") - .get("executablePath", ""); + const executablePath = workspace.getConfiguration("pylyzer").get("executablePath", ""); return executablePath === "" ? "pylyzer" : executablePath; })(); const enableDiagnostics = workspace.getConfiguration("pylyzer").get("diagnostics", true); @@ -84,13 +78,11 @@ async function restartLanguageClient() { } export async function activate(context: ExtensionContext) { - context.subscriptions.push( - commands.registerCommand("pylyzer.restartLanguageServer", () => restartLanguageClient()) - ); + context.subscriptions.push(commands.registerCommand("pylyzer.restartLanguageServer", () => restartLanguageClient())); context.subscriptions.push( commands.registerCommand("pylyzer.showReferences", async (uri, position, locations) => { - await showReferences(client, uri, position, locations) - }) + await showReferences(client, uri, position, locations); + }), ); await startLanguageClient(context); } diff --git a/extension/src/test/runTest.ts b/extension/src/test/runTest.ts index f6867cc..3314201 100644 --- a/extension/src/test/runTest.ts +++ b/extension/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/extension/src/test/suite/extension.test.ts b/extension/src/test/suite/extension.test.ts index 8857ba1..45ab914 100644 --- a/extension/src/test/suite/extension.test.ts +++ b/extension/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/extension/src/test/suite/index.ts b/extension/src/test/suite/index.ts index 44c0027..a26616e 100644 --- a/extension/src/test/suite/index.ts +++ b/extension/src/test/suite/index.ts @@ -1,6 +1,6 @@ -import * as path from "path"; -import Mocha from "mocha"; +import * as path from "node:path"; import glob from "glob"; +import Mocha from "mocha"; export function run(): Promise { // Create the mocha test @@ -18,7 +18,9 @@ export function run(): Promise { } // Add files to the test suite - files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); + for (const f of files) { + mocha.addFile(path.resolve(testsRoot, f)); + } try { // Run the mocha test diff --git a/extension/webpack.config.js b/extension/webpack.config.js index 6afa5b9..7be87c7 100644 --- a/extension/webpack.config.js +++ b/extension/webpack.config.js @@ -1,8 +1,6 @@ //@ts-check -"use strict"; - -const path = require("path"); +const path = require("node:path"); //@ts-check /** @typedef {import('webpack').Configuration} WebpackConfig **/