Autofix @typescript-eslint/array-type

This commit is contained in:
Elena Tanasoiu
2022-11-30 12:18:42 +00:00
parent 0b9ba3cb94
commit dc5d8daa84
18 changed files with 27 additions and 26 deletions

View File

@@ -32,7 +32,6 @@ module.exports = {
ignoreRestSiblings: false,
},
],
"@typescript-eslint/array-type": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",

View File

@@ -32,7 +32,7 @@ export abstract class AbstractWebview<
> extends DisposableObject {
protected panel: WebviewPanel | undefined;
protected panelLoaded = false;
protected panelLoadedCallBacks: (() => void)[] = [];
protected panelLoadedCallBacks: Array<() => void> = [];
private panelResolves?: Array<(panel: WebviewPanel) => void>;

View File

@@ -209,7 +209,9 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
return await this._lookup(uri);
}
async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> {
async readDirectory(
uri: vscode.Uri,
): Promise<Array<[string, vscode.FileType]>> {
const ref = decodeSourceArchiveUri(uri);
const archive = await this.getArchive(ref.sourceArchiveZipPath);
const contents = archive.dirMap.get(ref.pathWithinSourceArchive);

View File

@@ -166,7 +166,7 @@ export class CodeQLCliServer implements Disposable {
/** The process for the cli server, or undefined if one doesn't exist yet */
process?: child_process.ChildProcessWithoutNullStreams;
/** Queue of future commands*/
commandQueue: (() => void)[];
commandQueue: Array<() => void>;
/** Whether a command is running */
commandInProcess: boolean;
/** A buffer with a single null byte. */
@@ -915,7 +915,7 @@ export class CodeQLCliServer implements Disposable {
// Warning: this function is untenable for large dot files,
async readDotFiles(dir: string): Promise<string[]> {
const dotFiles: Promise<string>[] = [];
const dotFiles: Array<Promise<string>> = [];
for await (const file of walkDirectory(dir)) {
if (file.endsWith(".dot")) {
dotFiles.push(fs.readFile(file, "utf8"));

View File

@@ -460,7 +460,7 @@ export class CachedOperation<U> {
private readonly lru: string[];
private readonly inProgressCallbacks: Map<
string,
[(u: U) => void, (reason?: any) => void][]
Array<[(u: U) => void, (reason?: any) => void]>
>;
constructor(
@@ -471,7 +471,7 @@ export class CachedOperation<U> {
this.lru = [];
this.inProgressCallbacks = new Map<
string,
[(u: U) => void, (reason?: any) => void][]
Array<[(u: U) => void, (reason?: any) => void]>
>();
this.cached = new Map<string, U>();
}
@@ -499,7 +499,7 @@ export class CachedOperation<U> {
}
// Otherwise compute the new value, but leave a callback to allow sharing work
const callbacks: [(u: U) => void, (reason?: any) => void][] = [];
const callbacks: Array<[(u: U) => void, (reason?: any) => void]> = [];
this.inProgressCallbacks.set(t, callbacks);
try {
const result = await this.operation(t, ...args);

View File

@@ -825,7 +825,7 @@ export class ResultsView extends AbstractWebview<
return;
}
const diagnostics: [Uri, ReadonlyArray<Diagnostic>][] = [];
const diagnostics: Array<[Uri, readonly Diagnostic[]]> = [];
for (const result of data.runs[0].results) {
const message = result.message.text;

View File

@@ -47,7 +47,7 @@ export class QueryServerClient extends DisposableObject {
nextProgress: number;
withProgressReporting: WithProgressReporting;
private readonly queryServerStartListeners = [] as ProgressTask<void>[];
private readonly queryServerStartListeners = [] as Array<ProgressTask<void>>;
// Can't use standard vscode EventEmitter here since they do not cause the calling
// function to fail if one of the event handlers fail. This is something that

View File

@@ -149,7 +149,7 @@ class JoinOrderScanner implements EvaluationLogScanner {
private readonly predicateSizes = new Map<string, number>();
private readonly layerEvents = new Map<
string,
(ComputeRecursive | InLayer)[]
Array<ComputeRecursive | InLayer>
>();
// Map a key of the form 'query-with-demand : predicate name' to its badness input.
private readonly maxTupleCountMap = new Map<string, number[]>();

View File

@@ -44,7 +44,7 @@ export class QueryServerClient extends DisposableObject {
nextProgress: number;
withProgressReporting: WithProgressReporting;
private readonly queryServerStartListeners = [] as ProgressTask<void>[];
private readonly queryServerStartListeners = [] as Array<ProgressTask<void>>;
// Can't use standard vscode EventEmitter here since they do not cause the calling
// function to fail if one of the event handlers fail. This is something that

View File

@@ -112,7 +112,7 @@ export class AnalysesResultsManager {
const taskResults = await Promise.allSettled(batchTasks);
const failedTasks = taskResults.filter(
(x) => x.status === "rejected",
) as Array<PromiseRejectedResult>;
) as PromiseRejectedResult[];
if (failedTasks.length > 0) {
const failures = failedTasks.map((t) => t.reason.message);
failures.forEach((f) => void this.logger.log(f));

View File

@@ -438,7 +438,7 @@ const repositoriesMetadataQuery = `query Stars($repos: String!, $pageSize: Int!,
type RepositoriesMetadataQueryResponse = {
search: {
edges: {
edges: Array<{
cursor: string;
node: {
name: string;
@@ -448,7 +448,7 @@ type RepositoriesMetadataQueryResponse = {
stargazerCount: number;
updatedAt: string; // Actually a ISO Date string
};
}[];
}>;
};
};

View File

@@ -34,7 +34,7 @@ export interface QlPack {
name: string;
version: string;
dependencies: { [key: string]: string };
defaultSuite?: Record<string, unknown>[];
defaultSuite?: Array<Record<string, unknown>>;
defaultSuiteFile?: string;
}

View File

@@ -4,9 +4,9 @@ import { VariantAnalysisState } from "../pure/interface-types";
import { VariantAnalysisViewManager } from "./variant-analysis-view-manager";
export class VariantAnalysisViewSerializer implements WebviewPanelSerializer {
private resolvePromises: ((
value: VariantAnalysisViewManager<VariantAnalysisView>,
) => void)[] = [];
private resolvePromises: Array<
(value: VariantAnalysisViewManager<VariantAnalysisView>) => void
> = [];
private manager?: VariantAnalysisViewManager<VariantAnalysisView>;

View File

@@ -147,7 +147,7 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
private static createTestOrSuiteInfos(
testNodes: readonly QLTestNode[],
): (TestSuiteInfo | TestInfo)[] {
): Array<TestSuiteInfo | TestInfo> {
return testNodes.map((childNode) => {
return QLTestAdapter.createTestOrSuiteInfo(childNode);
});

View File

@@ -4,7 +4,7 @@ export type EventHandler<T> = (event: T) => void;
* A set of listeners for events of type `T`.
*/
export class EventHandlers<T> {
private handlers: EventHandler<T>[] = [];
private handlers: Array<EventHandler<T>> = [];
public addListener(handler: EventHandler<T>) {
this.handlers.push(handler);

View File

@@ -10,14 +10,14 @@ import {
describe("config listeners", () => {
interface TestConfig<T> {
clazz: new () => ConfigListener;
settings: {
settings: Array<{
name: string;
property: string;
values: [T, T];
}[];
}>;
}
const testConfig: TestConfig<string | number | boolean>[] = [
const testConfig: Array<TestConfig<string | number | boolean>> = [
{
clazz: CliConfigListener,
settings: [

View File

@@ -137,7 +137,7 @@ describe("archive-filesystem-provider", () => {
});
describe("source archive uri encoding", () => {
const testCases: { name: string; input: ZipFileReference }[] = [
const testCases: Array<{ name: string; input: ZipFileReference }> = [
{
name: "mixed case and unicode",
input: {

View File

@@ -236,7 +236,7 @@ describe("helpers", () => {
class MockExtensionContext implements ExtensionContext {
extensionMode: ExtensionMode = 3;
subscriptions: { dispose(): unknown }[] = [];
subscriptions: Array<{ dispose(): unknown }> = [];
workspaceState: Memento = new MockMemento();
globalState = new MockGlobalStorage();
extensionPath = "";