Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump eslint-plugin-perfectionist from 3.9.1 to 4.0.3 #1823

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions __tests__/test-utils/stub-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ declare global {
}
}

declare function _logEndpointCall(
name: string,
params: Array<google.script.Parameter>,
): void;
type EndpointStub =
| { delay?: number; status: "failure"; value: Error }
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- The return value of the API can be anything
| { delay?: number; status: "success"; value: any };

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- From google.script types
type FailureHandlerType = (error: Error, object?: any) => void;

type Run = google.script.PublicEndpoints & google.script.RunnerFunctions;

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- From google.script types
type SuccessHandlerType = (value?: any, object?: any) => void;

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- From google.script types
type FailureHandlerType = (error: Error, object?: any) => void;

type EndpointStub =
| { delay?: number; status: "failure"; value: Error }
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- The return value of the API can be anything
| { delay?: number; status: "success"; value: any };
declare function _logEndpointCall(
name: string,
params: Array<google.script.Parameter>,
): void;

export async function setup(
page: Page,
Expand Down
7 changes: 5 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import js from "@eslint/js";
import eslintComments from "@eslint-community/eslint-plugin-eslint-comments";
import commentsConfig from "@eslint-community/eslint-plugin-eslint-comments/configs";
import js from "@eslint/js";
import jest from "eslint-plugin-jest";
import perfectionist from "eslint-plugin-perfectionist";
import playwright from "eslint-plugin-playwright";
Expand Down Expand Up @@ -84,7 +84,10 @@ export default tseslint.config(
"error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "none" }],
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-use-before-define": [
"error",
{ functions: false },
],
"@typescript-eslint/no-useless-empty-export": "error",
"@typescript-eslint/parameter-properties": "error",
"@typescript-eslint/prefer-enum-initializers": "error",
Expand Down
73 changes: 15 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-perfectionist": "^3.9.1",
"eslint-plugin-perfectionist": "^4.0.3",
"eslint-plugin-playwright": "^2.1.0",
"eslint-plugin-prefer-arrow-functions": "^3.4.1",
"eslint-plugin-prettier": "^5.2.1",
Expand Down
32 changes: 16 additions & 16 deletions src/backend/move/copyFileComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ import type {

import { paginationHelper_ } from "../utils/paginationHelper";

function listFileComments_(
fileID: string,
driveService: SafeDriveService_,
): Array<SafeComment> {
return paginationHelper_<SafeCommentList, SafeComment>(
(pageToken) =>
driveService.Comments.list(fileID, {
fields:
"nextPageToken, items(author(isAuthenticatedUser, displayName), content, status, context, anchor, replies(author(isAuthenticatedUser, displayName), content, verb))",
maxResults: 100,
pageToken,
}),
(response) => response.items,
);
}

export function copyFileComments_(
sourceID: string,
destinationID: string,
Expand All @@ -46,3 +30,19 @@ export function copyFileComments_(
}
}
}

function listFileComments_(
fileID: string,
driveService: SafeDriveService_,
): Array<SafeComment> {
return paginationHelper_<SafeCommentList, SafeComment>(
(pageToken) =>
driveService.Comments.list(fileID, {
fields:
"nextPageToken, items(author(isAuthenticatedUser, displayName), content, status, context, anchor, replies(author(isAuthenticatedUser, displayName), content, verb))",
maxResults: 100,
pageToken,
}),
(response) => response.items,
);
}
104 changes: 52 additions & 52 deletions src/backend/move/folderManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,38 @@ export interface ListFolderContentsFields {
title: true;
}

function listFolderContents_(
export function deleteFolderIfEmpty_(
folderID: string,
mimeTypeCondition: string,
driveService: SafeDriveService_,
): Array<DeepPick<SafeFile, ListFolderContentsFields>> {
return paginationHelper_<
SafeFileList<ListFolderContentsFields>,
DeepPick<SafeFile, ListFolderContentsFields>
>(
(pageToken) =>
driveService.Files.list(
{
capabilities: { canMoveItemOutOfDrive: true },
id: true,
title: true,
},
{
includeItemsFromAllDrives: true,
maxResults: 1000,
pageToken,
q: `"${folderID}" in parents and mimeType ${mimeTypeCondition} and trashed = false`,
supportsAllDrives: true,
},
),
(response) => response.items,
): void {
if (!isFolderEmpty_(folderID, driveService)) {
return;
}
const response = driveService.Files.get(folderID, {
userPermission: { role: true },
});
if (
response.userPermission.role === "owner" ||
response.userPermission.role === "organizer"
) {
driveService.Files.remove(folderID);
}
}

export function isFolderEmpty_(
folderID: string,
driveService: SafeDriveService_,
): boolean {
const response = driveService.Files.list(
{ id: true },
{
includeItemsFromAllDrives: true,
maxResults: 1,
q: `"${folderID}" in parents and trashed = false`,
supportsAllDrives: true,
},
);
return response.items.length === 0;
}

export function listFilesInFolder_(
Expand All @@ -63,36 +69,30 @@ export function listFoldersInFolder_(
);
}

export function isFolderEmpty_(
function listFolderContents_(
folderID: string,
mimeTypeCondition: string,
driveService: SafeDriveService_,
): boolean {
const response = driveService.Files.list(
{ id: true },
{
includeItemsFromAllDrives: true,
maxResults: 1,
q: `"${folderID}" in parents and trashed = false`,
supportsAllDrives: true,
},
): Array<DeepPick<SafeFile, ListFolderContentsFields>> {
return paginationHelper_<
SafeFileList<ListFolderContentsFields>,
DeepPick<SafeFile, ListFolderContentsFields>
>(
(pageToken) =>
driveService.Files.list(
{
capabilities: { canMoveItemOutOfDrive: true },
id: true,
title: true,
},
{
includeItemsFromAllDrives: true,
maxResults: 1000,
pageToken,
q: `"${folderID}" in parents and mimeType ${mimeTypeCondition} and trashed = false`,
supportsAllDrives: true,
},
),
(response) => response.items,
);
return response.items.length === 0;
}

export function deleteFolderIfEmpty_(
folderID: string,
driveService: SafeDriveService_,
): void {
if (!isFolderEmpty_(folderID, driveService)) {
return;
}
const response = driveService.Files.get(folderID, {
userPermission: { role: true },
});
if (
response.userPermission.role === "owner" ||
response.userPermission.role === "organizer"
) {
driveService.Files.remove(folderID);
}
}
Loading