Automatically fix ESLint violations

This commit is contained in:
Koen Vlaswinkel
2023-12-11 17:00:16 +01:00
parent 7f332e3374
commit 01085e75ba
15 changed files with 42 additions and 53 deletions

View File

@@ -195,9 +195,8 @@ export class DistributionManager implements DistributionProvider {
if (process.env.PATH) { if (process.env.PATH) {
for (const searchDirectory of process.env.PATH.split(delimiter)) { for (const searchDirectory of process.env.PATH.split(delimiter)) {
const expectedLauncherPath = await getExecutableFromDirectory( const expectedLauncherPath =
searchDirectory, await getExecutableFromDirectory(searchDirectory);
);
if (expectedLauncherPath) { if (expectedLauncherPath) {
return { return {
codeQlPath: expectedLauncherPath, codeQlPath: expectedLauncherPath,

View File

@@ -1,11 +1,11 @@
export type DeepReadonly<T> = T extends Array<infer R> export type DeepReadonly<T> = T extends Array<infer R>
? DeepReadonlyArray<R> ? DeepReadonlyArray<R>
: // eslint-disable-next-line @typescript-eslint/ban-types : // eslint-disable-next-line @typescript-eslint/ban-types
T extends Function T extends Function
? T ? T
: T extends object : T extends object
? DeepReadonlyObject<T> ? DeepReadonlyObject<T>
: T; : T;
interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {} interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {}

View File

@@ -232,14 +232,14 @@ export function parseHighlightedLine(
const highlightStartColumn = isSingleLineHighlight const highlightStartColumn = isSingleLineHighlight
? highlightedRegion.startColumn ? highlightedRegion.startColumn
: isFirstHighlightedLine : isFirstHighlightedLine
? highlightedRegion.startColumn ? highlightedRegion.startColumn
: 0; : 0;
const highlightEndColumn = isSingleLineHighlight const highlightEndColumn = isSingleLineHighlight
? highlightedRegion.endColumn ? highlightedRegion.endColumn
: isLastHighlightedLine : isLastHighlightedLine
? highlightedRegion.endColumn ? highlightedRegion.endColumn
: line.length + 1; : line.length + 1;
const plainSection1 = line.substring(0, highlightStartColumn - 1); const plainSection1 = line.substring(0, highlightStartColumn - 1);
const highlightedSection = line.substring( const highlightedSection = line.substring(

View File

@@ -162,8 +162,8 @@ export class ExtensionTelemetryListener
const status = !error const status = !error
? CommandCompletion.Success ? CommandCompletion.Success
: error instanceof UserCancellationException : error instanceof UserCancellationException
? CommandCompletion.Cancelled ? CommandCompletion.Cancelled
: CommandCompletion.Failed; : CommandCompletion.Failed;
this.reporter.sendTelemetryEvent( this.reporter.sendTelemetryEvent(
"command-usage", "command-usage",

View File

@@ -424,9 +424,8 @@ export class DatabaseManager extends DisposableObject {
step: ++step, step: ++step,
}); });
const databaseItem = await this.createDatabaseItemFromPersistedState( const databaseItem =
database, await this.createDatabaseItemFromPersistedState(database);
);
try { try {
await this.refreshDatabase(databaseItem); await this.refreshDatabase(databaseItem);
await this.registerDatabase(databaseItem); await this.registerDatabase(databaseItem);

View File

@@ -542,8 +542,8 @@ async function installOrUpdateDistribution(
const messageText = willUpdateCodeQl const messageText = willUpdateCodeQl
? "Updating CodeQL CLI" ? "Updating CodeQL CLI"
: codeQlInstalled : codeQlInstalled
? "Checking for updates to CodeQL CLI" ? "Checking for updates to CodeQL CLI"
: "Installing CodeQL CLI"; : "Installing CodeQL CLI";
try { try {
await installOrUpdateDistributionWithProgressTitle( await installOrUpdateDistributionWithProgressTitle(
@@ -564,8 +564,8 @@ async function installOrUpdateDistribution(
willUpdateCodeQl willUpdateCodeQl
? "update" ? "update"
: codeQlInstalled : codeQlInstalled
? "check for updates to" ? "check for updates to"
: "install" : "install"
} CodeQL CLI`; } CodeQL CLI`;
if (e instanceof GithubRateLimitedError) { if (e instanceof GithubRateLimitedError) {

View File

@@ -106,9 +106,9 @@ function sortInterpretedResults(
a.message.text === undefined a.message.text === undefined
? 0 ? 0
: b.message.text === undefined : b.message.text === undefined
? 0 ? 0
: multiplier * : multiplier *
a.message.text?.localeCompare(b.message.text, env.language), a.message.text?.localeCompare(b.message.text, env.language),
); );
break; break;
default: default:

View File

@@ -507,9 +507,8 @@ export class SkeletonQueryWizard {
): Promise<DatabaseItem | undefined> { ): Promise<DatabaseItem | undefined> {
const defaultDatabaseNwo = QUERY_LANGUAGE_TO_DATABASE_REPO[language]; const defaultDatabaseNwo = QUERY_LANGUAGE_TO_DATABASE_REPO[language];
const dbItems = await SkeletonQueryWizard.sortDatabaseItemsByDateAdded( const dbItems =
databaseItems, await SkeletonQueryWizard.sortDatabaseItemsByDateAdded(databaseItems);
);
const defaultDatabaseItem = await SkeletonQueryWizard.findDatabaseItemByNwo( const defaultDatabaseItem = await SkeletonQueryWizard.findDatabaseItemByNwo(
language, language,

View File

@@ -85,9 +85,8 @@ export async function runAutoModelQueries({
// CodeQL needs to have access to the database to be able to retrieve the // CodeQL needs to have access to the database to be able to retrieve the
// snippets from it. The source location prefix is used to determine the // snippets from it. The source location prefix is used to determine the
// base path of the database. // base path of the database.
const sourceLocationPrefix = await databaseItem.getSourceLocationPrefix( const sourceLocationPrefix =
cliServer, await databaseItem.getSourceLocationPrefix(cliServer);
);
const sourceArchiveUri = databaseItem.sourceArchive; const sourceArchiveUri = databaseItem.sourceArchive;
const sourceInfo = const sourceInfo =
sourceArchiveUri === undefined sourceArchiveUri === undefined

View File

@@ -482,9 +482,8 @@ export class ModelEditorView extends AbstractWebview<
// In application mode, we need the database of a specific library to generate // In application mode, we need the database of a specific library to generate
// the modeled methods. In framework mode, we'll use the current database. // the modeled methods. In framework mode, we'll use the current database.
if (mode === Mode.Application) { if (mode === Mode.Application) {
addedDatabase = await this.promptChooseNewOrExistingDatabase( addedDatabase =
progress, await this.promptChooseNewOrExistingDatabase(progress);
);
if (!addedDatabase) { if (!addedDatabase) {
return; return;
} }
@@ -562,9 +561,8 @@ export class ModelEditorView extends AbstractWebview<
private async modelDependency(): Promise<void> { private async modelDependency(): Promise<void> {
return withProgress(async (progress, token) => { return withProgress(async (progress, token) => {
const addedDatabase = await this.promptChooseNewOrExistingDatabase( const addedDatabase =
progress, await this.promptChooseNewOrExistingDatabase(progress);
);
if (!addedDatabase || token.isCancellationRequested) { if (!addedDatabase || token.isCancellationRequested) {
return; return;
} }

View File

@@ -239,8 +239,8 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
const state = event.pass const state = event.pass
? "passed" ? "passed"
: event.messages?.length : event.messages?.length
? "errored" ? "errored"
: "failed"; : "failed";
let message: string | undefined; let message: string | undefined;
if (event.failureDescription || event.diff?.length) { if (event.failureDescription || event.diff?.length) {
message = message =

View File

@@ -45,9 +45,8 @@ export async function exportVariantAnalysisResults(
): Promise<void> { ): Promise<void> {
await withProgress( await withProgress(
async (progress: ProgressCallback, token: CancellationToken) => { async (progress: ProgressCallback, token: CancellationToken) => {
const variantAnalysis = await variantAnalysisManager.getVariantAnalysis( const variantAnalysis =
variantAnalysisId, await variantAnalysisManager.getVariantAnalysis(variantAnalysisId);
);
if (!variantAnalysis) { if (!variantAnalysis) {
void extLogger.log( void extLogger.log(
`Could not find variant analysis with id ${variantAnalysisId}`, `Could not find variant analysis with id ${variantAnalysisId}`,
@@ -61,9 +60,8 @@ export async function exportVariantAnalysisResults(
throw new UserCancellationException("Cancelled"); throw new UserCancellationException("Cancelled");
} }
const repoStates = await variantAnalysisManager.getRepoStates( const repoStates =
variantAnalysisId, await variantAnalysisManager.getRepoStates(variantAnalysisId);
);
void extLogger.log( void extLogger.log(
`Exporting variant analysis results for variant analysis with id ${variantAnalysis.id}`, `Exporting variant analysis results for variant analysis with id ${variantAnalysis.id}`,

View File

@@ -183,9 +183,8 @@ async function copyExistingQueryPack(
if ( if (
await cliServer.cliConstraints.supportsGenerateExtensiblePredicateMetadata() await cliServer.cliConstraints.supportsGenerateExtensiblePredicateMetadata()
) { ) {
const metadata = await cliServer.generateExtensiblePredicateMetadata( const metadata =
originalPackRoot, await cliServer.generateExtensiblePredicateMetadata(originalPackRoot);
);
metadata.extensible_predicates.forEach((predicate) => { metadata.extensible_predicates.forEach((predicate) => {
if (predicate.path.endsWith(".ql")) { if (predicate.path.endsWith(".ql")) {
toCopy.push(join(originalPackRoot, predicate.path)); toCopy.push(join(originalPackRoot, predicate.path));

View File

@@ -21,9 +21,8 @@ export const createVariantAnalysisContentProvider = (
} }
const variantAnalysisId = parseInt(variantAnalysisIdString); const variantAnalysisId = parseInt(variantAnalysisIdString);
const variantAnalysis = await variantAnalysisManager.getVariantAnalysis( const variantAnalysis =
variantAnalysisId, await variantAnalysisManager.getVariantAnalysis(variantAnalysisId);
);
if (!variantAnalysis) { if (!variantAnalysis) {
void showAndLogWarningMessage( void showAndLogWarningMessage(
extLogger, extLogger,

View File

@@ -180,9 +180,8 @@ export class VariantAnalysisResultsManager extends DisposableObject {
repositoryFullName, repositoryFullName,
); );
const repoTask: VariantAnalysisRepositoryTask = await readRepoTask( const repoTask: VariantAnalysisRepositoryTask =
storageDirectory, await readRepoTask(storageDirectory);
);
if (!repoTask.databaseCommitSha || !repoTask.sourceLocationPrefix) { if (!repoTask.databaseCommitSha || !repoTask.sourceLocationPrefix) {
throw new Error("Missing database commit SHA"); throw new Error("Missing database commit SHA");