diff --git a/src/commands/expandMacro.ts b/src/commands/expandMacro.ts index 518b700..a027c96 100644 --- a/src/commands/expandMacro.ts +++ b/src/commands/expandMacro.ts @@ -75,7 +75,7 @@ export function configureExpandMacro( } const command = - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: server capabilities guarantee this command exists client.initializeResult.capabilities.executeCommandProvider?.commands.find( (c) => c.startsWith("expandMacro:"), )!; diff --git a/src/commands/manipulatePipes.ts b/src/commands/manipulatePipes.ts index 6cf707e..48a5d02 100644 --- a/src/commands/manipulatePipes.ts +++ b/src/commands/manipulatePipes.ts @@ -43,7 +43,7 @@ export function configureManipulatePipes( } const command = - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: server capabilities guarantee this command exists client.initializeResult.capabilities.executeCommandProvider?.commands.find( (c: string) => c.startsWith("manipulatePipes:"), )!; diff --git a/src/commands/mixClean.ts b/src/commands/mixClean.ts index a702a94..a7890af 100644 --- a/src/commands/mixClean.ts +++ b/src/commands/mixClean.ts @@ -35,7 +35,7 @@ export function configureMixClean( return; } const command = - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: server capabilities guarantee this command exists client.initializeResult.capabilities.executeCommandProvider?.commands.find( (c) => c.startsWith("mixClean:"), )!; diff --git a/src/debugAdapter.ts b/src/debugAdapter.ts index 304e7c3..9b60074 100644 --- a/src/debugAdapter.ts +++ b/src/debugAdapter.ts @@ -201,7 +201,7 @@ class DebugAdapterTrackerFactory if (event.event === "initialized") { const elapsed = - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: start time exists for active sessions performance.now() - this.startTimes.get(session.id)!; reporter.sendTelemetryEvent( "debug_session_initialized", diff --git a/src/extension.ts b/src/extension.ts index 1da9e6c..7947049 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -24,7 +24,7 @@ export const languageClientManager = new LanguageClientManager( ); const startClientsForOpenDocuments = (context: vscode.ExtensionContext) => { - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: iterating with forEach keeps the initialization straightforward vscode.workspace.textDocuments.forEach((value) => { languageClientManager.handleDidOpenTextDocument(value, context); }); diff --git a/src/languageClientManager.ts b/src/languageClientManager.ts index e98cf26..3cf621e 100644 --- a/src/languageClientManager.ts +++ b/src/languageClientManager.ts @@ -1,6 +1,7 @@ import * as vscode from "vscode"; import { type Disposable, + type DocumentSelector, type Executable, LanguageClient, type LanguageClientOptions, @@ -69,8 +70,7 @@ function startClient( debug: serverOpts, }; - // biome-ignore lint/suspicious/noImplicitAnyLet: - let displayName; + let displayName: string; if (clientOptions.workspaceFolder) { console.log( `ElixirLS: starting LSP client for ${clientOptions.workspaceFolder.uri.fsPath} with server options`, @@ -320,7 +320,7 @@ export class LanguageClientManager { folder = vscode.workspace.workspaceFolders[0]; } else { // no folders - use default client - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: a default client is always started when no workspace folders exist return this.defaultClientPromise!; } } @@ -328,7 +328,7 @@ export class LanguageClientManager { // If we have nested workspace folders we only start a server on the outer most workspace folder. folder = this._workspaceTracker.getOuterMostWorkspaceFolder(folder); - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: the client promise is set when the workspace folder's client is started return this.clientsPromises.get(folder.uri.toString())!; } @@ -399,8 +399,8 @@ export class LanguageClientManager { folder = this._workspaceTracker.getOuterMostWorkspaceFolder(folder); if (!this.clients.has(folder.uri.toString())) { - // biome-ignore lint/suspicious/noImplicitAnyLet: - let documentSelector; + // The document selector will be assigned based on workspace mode + let documentSelector: DocumentSelector = defaultDocumentSelector; if (this._workspaceTracker.mode === WorkspaceMode.MULTI_ROOT) { // multi-root workspace // create document selector with glob pattern that will match files @@ -450,9 +450,9 @@ export class LanguageClientManager { const clientsToDispose: LanguageClient[] = []; let changed = false; if (this.defaultClient) { - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach this.defaultClientDisposables?.forEach((d) => d.dispose()); - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: defaultClientPromise is defined whenever defaultClient is clientStartPromises.push(this.defaultClientPromise!); clientsToDispose.push(this.defaultClient); this.defaultClient = null; @@ -462,9 +462,9 @@ export class LanguageClientManager { } for (const [uri, client] of this.clients.entries()) { - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach this.clientsDisposables.get(uri)?.forEach((d) => d.dispose()); - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: a promise exists for every started client clientStartPromises.push(this.clientsPromises.get(uri)!); clientsToDispose.push(client); changed = true; @@ -498,9 +498,9 @@ export class LanguageClientManager { const client = this.clients.get(uri); if (client) { console.log("ElixirLS: Stopping LSP client for", folder.uri.fsPath); - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach this.clientsDisposables.get(uri)?.forEach((d) => d.dispose()); - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: a promise exists for every started client const clientPromise = this.clientsPromises.get(uri)!; this.clients.delete(uri); @@ -520,7 +520,7 @@ export class LanguageClientManager { ); reporter.sendTelemetryErrorEvent("language_client_stop_error", { "elixir_ls.language_client_stop_error": String(e), - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: error may not be typed, cast to access stack trace "elixir_ls.language_client_start_error_stack": (e)?.stack ?? "", }); } @@ -531,7 +531,7 @@ export class LanguageClientManager { console.warn("ElixirLS: error during LSP client dispose", e); reporter.sendTelemetryErrorEvent("language_client_stop_error", { "elixir_ls.language_client_stop_error": String(e), - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: error may not be typed, cast to access stack trace "elixir_ls.language_client_start_error_stack": (e)?.stack ?? "", }); } diff --git a/src/telemetry.ts b/src/telemetry.ts index 8411781..da3fa21 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -284,21 +284,21 @@ class EnvironmentReporter extends TelemetryReporter { const label = `elixir_ls.${eventName}_count`; if (!measurements) { const measurementsWithCount: TelemetryEventMeasurements = {}; - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: dynamic property access requires an explicit any cast (measurementsWithCount)[label] = 1 / samplingFactor; return measurementsWithCount; } let countFound = false; - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: forEach provides a concise way to modify the object in place Object.keys(measurements).forEach((key) => { if (key.endsWith("_count")) { - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: dynamic property access requires an explicit any cast (measurements)[key] /= samplingFactor; countFound = true; } }); if (!countFound) { - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: dynamic property access requires an explicit any cast (measurements)[label] = 1 / samplingFactor; } return measurements; @@ -373,7 +373,7 @@ export function preprocessStacktrace(originalStack: string) { "pwd", "android:value", ]; - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: forEach simplifies keyword replacement logic sensitiveKeywords.forEach((keyword) => { const regex = new RegExp(`(${keyword})[^a-zA-Z0-9]`, "gi"); const encodeKeyword = `${keyword[0]}_${keyword.slice(1)}`; @@ -393,9 +393,9 @@ export function preprocessStacktraceInProperties( return properties; } - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: properties may contain arbitrary values for (const key in properties) { - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: values may be of unknown type (properties)[key] = preprocessStacktrace((properties)[key]); } return properties; diff --git a/src/terminalLinkProvider.ts b/src/terminalLinkProvider.ts index b59310b..2321bea 100644 --- a/src/terminalLinkProvider.ts +++ b/src/terminalLinkProvider.ts @@ -35,7 +35,7 @@ export function configureTerminalLinkProvider( return [ { - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: matches is defined because we return early when the regex does not match startIndex: matches.index!, length: matches[0].length, data: { diff --git a/src/test/multiRoot/extension.test.ts b/src/test/multiRoot/extension.test.ts index c1ed247..529fabd 100644 --- a/src/test/multiRoot/extension.test.ts +++ b/src/test/multiRoot/extension.test.ts @@ -152,7 +152,7 @@ suite("Multi root workspace tests", () => { assert.equal(extension.exports.languageClientManager.clients.size, 3); const addedWorkspaceFolder = - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: the workspace folder exists because it was added above vscode.workspace.getWorkspaceFolder(addedFolderUri)!; await waitForLanguageClientManagerUpdate(extension, async () => { @@ -189,7 +189,7 @@ suite("Multi root workspace tests", () => { assert.equal(extension.exports.languageClientManager.clients.size, 2); const addedWorkspaceFolder = - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: the workspace folder exists because it was added above vscode.workspace.getWorkspaceFolder(addedFolderUri)!; await waitForWorkspaceUpdate(() => { diff --git a/src/test/multiRoot/index.ts b/src/test/multiRoot/index.ts index 7769856..133215f 100644 --- a/src/test/multiRoot/index.ts +++ b/src/test/multiRoot/index.ts @@ -15,7 +15,7 @@ export async function run( try { const files = await glob("**/**.test.js", { cwd: testsRoot }); // Add files to the test suite - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); try { diff --git a/src/test/noWorkspace/index.ts b/src/test/noWorkspace/index.ts index 7769856..133215f 100644 --- a/src/test/noWorkspace/index.ts +++ b/src/test/noWorkspace/index.ts @@ -15,7 +15,7 @@ export async function run( try { const files = await glob("**/**.test.js", { cwd: testsRoot }); // Add files to the test suite - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); try { diff --git a/src/test/noWorkspaceElixirFile/index.ts b/src/test/noWorkspaceElixirFile/index.ts index 7769856..133215f 100644 --- a/src/test/noWorkspaceElixirFile/index.ts +++ b/src/test/noWorkspaceElixirFile/index.ts @@ -15,7 +15,7 @@ export async function run( try { const files = await glob("**/**.test.js", { cwd: testsRoot }); // Add files to the test suite - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); try { diff --git a/src/test/singleFolderMix/index.ts b/src/test/singleFolderMix/index.ts index 7769856..133215f 100644 --- a/src/test/singleFolderMix/index.ts +++ b/src/test/singleFolderMix/index.ts @@ -15,7 +15,7 @@ export async function run( try { const files = await glob("**/**.test.js", { cwd: testsRoot }); // Add files to the test suite - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); try { diff --git a/src/test/singleFolderNoMix/index.ts b/src/test/singleFolderNoMix/index.ts index 7769856..133215f 100644 --- a/src/test/singleFolderNoMix/index.ts +++ b/src/test/singleFolderNoMix/index.ts @@ -15,7 +15,7 @@ export async function run( try { const files = await glob("**/**.test.js", { cwd: testsRoot }); // Add files to the test suite - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); try { diff --git a/src/testController.ts b/src/testController.ts index fa5866e..8ab4cc0 100644 --- a/src/testController.ts +++ b/src/testController.ts @@ -35,7 +35,7 @@ export function configureTestController( reporter.sendTelemetryErrorEvent("test_controller_resolve_error", { "elixir_ls.test_controller_resolve_error": String(e), "elixir_ls.test_controller_resolve_error_stack": - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: error may be of an unknown type (e)?.stack ?? "", }); } @@ -51,7 +51,7 @@ export function configureTestController( reporter.sendTelemetryErrorEvent("test_controller_resolve_error", { "elixir_ls.test_controller_resolve_error": String(e), "elixir_ls.test_controller_resolve_error_stack": - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: error may be of an unknown type (e)?.stack ?? "", }); } @@ -207,7 +207,7 @@ export function configureTestController( } const command = - // biome-ignore lint/style/noNonNullAssertion: + // biome-ignore lint/style/noNonNullAssertion: the command is guaranteed by the language server client.initializeResult.capabilities.executeCommandProvider?.commands.find( (c) => c.startsWith("getExUnitTestsInFile:"), )!; @@ -219,7 +219,7 @@ export function configureTestController( arguments: [file.uri?.toString()], }; - // biome-ignore lint/suspicious/noExplicitAny: + // biome-ignore lint/suspicious/noExplicitAny: response structure is defined by the server let res: any[] = []; try { res = await client.sendRequest(ExecuteCommandRequest.type, params); @@ -407,7 +407,7 @@ export function configureTestController( ): vscode.TestItem | undefined { if (type === "doctest") { let foundDoctest: vscode.TestItem | undefined; - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach allows iterating over the children collection directly describeTest.children.forEach((doctestGroupItem) => { if (getType(doctestGroupItem) === ItemType.Doctest) { const candidate = doctestGroupItem.children.get(name); @@ -474,13 +474,13 @@ export function configureTestController( // Loop through all included tests, or all known tests, and add them to our queue if (request.include) { - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach simplifies queuing requested tests request.include.forEach((test) => { queue.push(test); run.enqueued(test); }); } else { - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach simplifies queuing all known tests controller.items.forEach((test) => { queue.push(test); run.enqueued(test); @@ -522,7 +522,7 @@ export function configureTestController( // If we're running a workspace and any of the files is not parsed yet, parse them now { const childrenToCheck: Array> = []; - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: using forEach is convenient for iterating over the children set test.children.forEach((fileTest) => { if (fileTest.children.size === 0) { childrenToCheck.push(parseTestsInFileContents(fileTest)); @@ -705,7 +705,7 @@ export function configureTestController( } if (includeChildren) { - // biome-ignore lint/complexity/noForEach: + // biome-ignore lint/complexity/noForEach: forEach makes enqueueing child tests straightforward test.children.forEach((test) => { queue.push(test); run.enqueued(test);