mirror of
https://github.com/getpaseo/paseo.git
synced 2026-08-14 20:32:46 +00:00
refactor(app): remove unnecessary String() and Boolean() conversions from type-aware lint fixes (#696)
This commit is contained in:
@@ -31,7 +31,7 @@ test.beforeAll(async () => {
|
|||||||
if (!result.workspace) {
|
if (!result.workspace) {
|
||||||
throw new Error(result.error ?? "Failed to seed workspace");
|
throw new Error(result.error ?? "Failed to seed workspace");
|
||||||
}
|
}
|
||||||
workspaceId = String(result.workspace.id);
|
workspaceId = result.workspace.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterAll(async () => {
|
test.afterAll(async () => {
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ export async function createWorkspaceThroughDaemon(
|
|||||||
throw new Error(result.error ?? `Failed to create workspace for ${input.cwd}`);
|
throw new Error(result.error ?? `Failed to create workspace for ${input.cwd}`);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: String(result.workspace.id),
|
id: result.workspace.id,
|
||||||
name: result.workspace.name,
|
name: result.workspace.name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ export async function findWorktreeWorkspaceForProject(
|
|||||||
throw new Error(`Failed to find created worktree workspace for ${repoPath}`);
|
throw new Error(`Failed to find created worktree workspace for ${repoPath}`);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: String(workspace.id),
|
id: workspace.id,
|
||||||
name: workspace.name,
|
name: workspace.name,
|
||||||
projectRootPath: workspace.projectRootPath,
|
projectRootPath: workspace.projectRootPath,
|
||||||
workspaceDirectory: workspace.workspaceDirectory,
|
workspaceDirectory: workspace.workspaceDirectory,
|
||||||
@@ -308,7 +308,7 @@ export async function fetchWorkspaceById(
|
|||||||
projectRootPath: string;
|
projectRootPath: string;
|
||||||
}> {
|
}> {
|
||||||
const payload = await client.fetchWorkspaces();
|
const payload = await client.fetchWorkspaces();
|
||||||
const workspace = payload.entries.find((entry) => String(entry.id) === workspaceId) ?? null;
|
const workspace = payload.entries.find((entry) => entry.id === workspaceId) ?? null;
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
throw new Error(`Workspace not found: ${workspaceId}`);
|
throw new Error(`Workspace not found: ${workspaceId}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ test.beforeAll(async () => {
|
|||||||
seedClient = await connectTerminalClient();
|
seedClient = await connectTerminalClient();
|
||||||
const result = await seedClient.openProject(tempRepo.path);
|
const result = await seedClient.openProject(tempRepo.path);
|
||||||
if (!result.workspace) throw new Error(result.error ?? "Failed to seed workspace");
|
if (!result.workspace) throw new Error(result.error ?? "Failed to seed workspace");
|
||||||
workspaceId = String(result.workspace.id);
|
workspaceId = result.workspace.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterAll(async () => {
|
test.afterAll(async () => {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ async function openProjectViaDaemon(
|
|||||||
throw new Error(result.error ?? `Failed to open project ${cwd}`);
|
throw new Error(result.error ?? `Failed to open project ${cwd}`);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: String(result.workspace.id),
|
id: result.workspace.id,
|
||||||
name: result.workspace.name,
|
name: result.workspace.name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ test.describe("Workspace cwd correctness", () => {
|
|||||||
if (!workspaceResult.workspace) {
|
if (!workspaceResult.workspace) {
|
||||||
throw new Error(workspaceResult.error ?? `Failed to open project ${repo.path}`);
|
throw new Error(workspaceResult.error ?? `Failed to open project ${repo.path}`);
|
||||||
}
|
}
|
||||||
const workspaceId = String(workspaceResult.workspace.id);
|
const workspaceId = workspaceResult.workspace.id;
|
||||||
|
|
||||||
// Use sidebar navigation to avoid Expo Router hydration issues
|
// Use sidebar navigation to avoid Expo Router hydration issues
|
||||||
await openHomeWithProject(page, repo.path);
|
await openHomeWithProject(page, repo.path);
|
||||||
@@ -95,7 +95,7 @@ test.describe("Workspace cwd correctness", () => {
|
|||||||
if (!workspaceResult.workspace) {
|
if (!workspaceResult.workspace) {
|
||||||
throw new Error(workspaceResult.error ?? `Failed to open project ${worktreePath}`);
|
throw new Error(workspaceResult.error ?? `Failed to open project ${worktreePath}`);
|
||||||
}
|
}
|
||||||
const workspaceId = String(workspaceResult.workspace.id);
|
const workspaceId = workspaceResult.workspace.id;
|
||||||
|
|
||||||
// Use sidebar navigation to avoid Expo Router hydration issues
|
// Use sidebar navigation to avoid Expo Router hydration issues
|
||||||
// with direct URL navigation to the 2nd+ workspace.
|
// with direct URL navigation to the 2nd+ workspace.
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ test.describe("Workspace lifecycle", () => {
|
|||||||
if (!workspaceResult.workspace) {
|
if (!workspaceResult.workspace) {
|
||||||
throw new Error(workspaceResult.error ?? `Failed to open project ${repo.path}`);
|
throw new Error(workspaceResult.error ?? `Failed to open project ${repo.path}`);
|
||||||
}
|
}
|
||||||
const workspaceId = String(workspaceResult.workspace.id);
|
const workspaceId = workspaceResult.workspace.id;
|
||||||
|
|
||||||
await openHomeWithProject(page, repo.path);
|
await openHomeWithProject(page, repo.path);
|
||||||
await navigateToWorkspaceViaSidebar(page, workspaceId);
|
await navigateToWorkspaceViaSidebar(page, workspaceId);
|
||||||
@@ -77,7 +77,7 @@ test.describe("Workspace lifecycle", () => {
|
|||||||
if (!workspaceResult.workspace) {
|
if (!workspaceResult.workspace) {
|
||||||
throw new Error(workspaceResult.error ?? `Failed to open project ${repo.path}`);
|
throw new Error(workspaceResult.error ?? `Failed to open project ${repo.path}`);
|
||||||
}
|
}
|
||||||
const workspaceId = String(workspaceResult.workspace.id);
|
const workspaceId = workspaceResult.workspace.id;
|
||||||
|
|
||||||
await openHomeWithProject(page, repo.path);
|
await openHomeWithProject(page, repo.path);
|
||||||
await navigateToWorkspaceViaSidebar(page, workspaceId);
|
await navigateToWorkspaceViaSidebar(page, workspaceId);
|
||||||
@@ -120,7 +120,7 @@ test.describe("Workspace lifecycle", () => {
|
|||||||
if (!workspaceResult.workspace) {
|
if (!workspaceResult.workspace) {
|
||||||
throw new Error(workspaceResult.error ?? `Failed to open project ${worktreePath}`);
|
throw new Error(workspaceResult.error ?? `Failed to open project ${worktreePath}`);
|
||||||
}
|
}
|
||||||
const workspaceId = String(workspaceResult.workspace.id);
|
const workspaceId = workspaceResult.workspace.id;
|
||||||
|
|
||||||
await openHomeWithProject(page, repo.path);
|
await openHomeWithProject(page, repo.path);
|
||||||
await navigateToWorkspaceViaSidebar(page, workspaceId);
|
await navigateToWorkspaceViaSidebar(page, workspaceId);
|
||||||
@@ -170,7 +170,7 @@ test.describe("Workspace lifecycle", () => {
|
|||||||
if (!workspaceResult.workspace) {
|
if (!workspaceResult.workspace) {
|
||||||
throw new Error(workspaceResult.error ?? `Failed to open project ${worktreePath}`);
|
throw new Error(workspaceResult.error ?? `Failed to open project ${worktreePath}`);
|
||||||
}
|
}
|
||||||
const workspaceId = String(workspaceResult.workspace.id);
|
const workspaceId = workspaceResult.workspace.id;
|
||||||
|
|
||||||
await openHomeWithProject(page, repo.path);
|
await openHomeWithProject(page, repo.path);
|
||||||
await navigateToWorkspaceViaSidebar(page, workspaceId);
|
await navigateToWorkspaceViaSidebar(page, workspaceId);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ test.describe("Workspace setup runtime authority", () => {
|
|||||||
cwd: repo.path,
|
cwd: repo.path,
|
||||||
worktreeSlug: `setup-chat-${Date.now()}`,
|
worktreeSlug: `setup-chat-${Date.now()}`,
|
||||||
});
|
});
|
||||||
const workspaceId = String(workspace.id);
|
const workspaceId = workspace.id;
|
||||||
|
|
||||||
const wsInfo = await findWorktreeWorkspaceForProject(client, repo.path);
|
const wsInfo = await findWorktreeWorkspaceForProject(client, repo.path);
|
||||||
expect(wsInfo.workspaceDirectory).not.toBe(repo.path);
|
expect(wsInfo.workspaceDirectory).not.toBe(repo.path);
|
||||||
@@ -78,7 +78,7 @@ test.describe("Workspace setup runtime authority", () => {
|
|||||||
throw new Error(result.error ?? "Failed to create workspace");
|
throw new Error(result.error ?? "Failed to create workspace");
|
||||||
}
|
}
|
||||||
const workspaceDir = result.workspace.workspaceDirectory;
|
const workspaceDir = result.workspace.workspaceDirectory;
|
||||||
const workspaceId = String(result.workspace.id);
|
const workspaceId = result.workspace.id;
|
||||||
|
|
||||||
// Navigate to the worktree workspace via sidebar click (direct URL
|
// Navigate to the worktree workspace via sidebar click (direct URL
|
||||||
// navigation for freshly created worktree workspaces can race with
|
// navigation for freshly created worktree workspaces can race with
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ test.describe("Workspace setup streaming", () => {
|
|||||||
throw new Error(result.error ?? "Failed to create workspace");
|
throw new Error(result.error ?? "Failed to create workspace");
|
||||||
}
|
}
|
||||||
const workspaceDir = result.workspace.workspaceDirectory;
|
const workspaceDir = result.workspace.workspaceDirectory;
|
||||||
const workspaceId = String(result.workspace.id);
|
const workspaceId = result.workspace.id;
|
||||||
|
|
||||||
await completed;
|
await completed;
|
||||||
|
|
||||||
|
|||||||
@@ -228,8 +228,7 @@ export function ComboboxItem({
|
|||||||
const itemPressableStyle = useCallback(
|
const itemPressableStyle = useCallback(
|
||||||
({ pressed, hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => [
|
({ pressed, hovered = false }: PressableStateCallbackType & { hovered?: boolean }) => [
|
||||||
styles.comboboxItem,
|
styles.comboboxItem,
|
||||||
Boolean(hovered) &&
|
hovered && (elevated ? styles.comboboxItemHoveredElevated : styles.comboboxItemHovered),
|
||||||
(elevated ? styles.comboboxItemHoveredElevated : styles.comboboxItemHovered),
|
|
||||||
pressed && (elevated ? styles.comboboxItemPressedElevated : styles.comboboxItemPressed),
|
pressed && (elevated ? styles.comboboxItemPressedElevated : styles.comboboxItemPressed),
|
||||||
active && styles.comboboxItemActive,
|
active && styles.comboboxItemActive,
|
||||||
disabled && styles.comboboxItemDisabled,
|
disabled && styles.comboboxItemDisabled,
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function useControllableOpenState({
|
|||||||
}): [boolean, (next: boolean) => void] {
|
}): [boolean, (next: boolean) => void] {
|
||||||
const [internalOpen, setInternalOpen] = useState(Boolean(defaultOpen));
|
const [internalOpen, setInternalOpen] = useState(Boolean(defaultOpen));
|
||||||
const isControlled = typeof open === "boolean";
|
const isControlled = typeof open === "boolean";
|
||||||
const value = isControlled ? Boolean(open) : internalOpen;
|
const value = isControlled ? open : internalOpen;
|
||||||
const setValue = useCallback(
|
const setValue = useCallback(
|
||||||
(next: boolean) => {
|
(next: boolean) => {
|
||||||
if (!isControlled) setInternalOpen(next);
|
if (!isControlled) setInternalOpen(next);
|
||||||
@@ -748,12 +748,12 @@ export function DropdownMenuItem({
|
|||||||
return [
|
return [
|
||||||
styles.item,
|
styles.item,
|
||||||
selectedStyle,
|
selectedStyle,
|
||||||
selected && (Boolean(hovered) || pressed) && selectedVariant !== "accent"
|
selected && (hovered || pressed) && selectedVariant !== "accent"
|
||||||
? styles.itemSelectedInteractive
|
? styles.itemSelectedInteractive
|
||||||
: null,
|
: null,
|
||||||
isDisabled ? styles.itemDisabled : null,
|
isDisabled ? styles.itemDisabled : null,
|
||||||
muted && !isDisabled ? styles.itemMuted : null,
|
muted && !isDisabled ? styles.itemMuted : null,
|
||||||
Boolean(hovered) && !pressed && !isDisabled ? styles.itemHovered : null,
|
hovered && !pressed && !isDisabled ? styles.itemHovered : null,
|
||||||
pressed && !isDisabled ? styles.itemPressed : null,
|
pressed && !isDisabled ? styles.itemPressed : null,
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ function useControllableOpenState({
|
|||||||
}): [boolean, (next: boolean) => void] {
|
}): [boolean, (next: boolean) => void] {
|
||||||
const [internalOpen, setInternalOpen] = useState(Boolean(defaultOpen));
|
const [internalOpen, setInternalOpen] = useState(Boolean(defaultOpen));
|
||||||
const isControlled = typeof open === "boolean";
|
const isControlled = typeof open === "boolean";
|
||||||
const value = isControlled ? Boolean(open) : internalOpen;
|
const value = isControlled ? open : internalOpen;
|
||||||
const setValue = useCallback(
|
const setValue = useCallback(
|
||||||
(next: boolean) => {
|
(next: boolean) => {
|
||||||
if (!isControlled) setInternalOpen(next);
|
if (!isControlled) setInternalOpen(next);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export function polyfillCrypto(): void {
|
|||||||
if (typeof g.TextEncoder !== "function") {
|
if (typeof g.TextEncoder !== "function") {
|
||||||
class BufferTextEncoder {
|
class BufferTextEncoder {
|
||||||
encode(input = ""): Uint8Array {
|
encode(input = ""): Uint8Array {
|
||||||
return Uint8Array.from(Buffer.from(String(input), "utf8"));
|
return Uint8Array.from(Buffer.from(input, "utf8"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.TextEncoder = BufferTextEncoder as unknown as typeof TextEncoder;
|
g.TextEncoder = BufferTextEncoder as unknown as typeof TextEncoder;
|
||||||
|
|||||||
@@ -130,8 +130,8 @@ export function normalizeWorkspaceDescriptor(
|
|||||||
payload: WorkspaceDescriptorPayload,
|
payload: WorkspaceDescriptorPayload,
|
||||||
): WorkspaceDescriptor {
|
): WorkspaceDescriptor {
|
||||||
return {
|
return {
|
||||||
id: normalizeWorkspaceOpaqueId(String(payload.id)) ?? String(payload.id),
|
id: normalizeWorkspaceOpaqueId(payload.id) ?? payload.id,
|
||||||
projectId: String(payload.projectId),
|
projectId: payload.projectId,
|
||||||
projectDisplayName: payload.projectDisplayName,
|
projectDisplayName: payload.projectDisplayName,
|
||||||
projectRootPath: payload.projectRootPath,
|
projectRootPath: payload.projectRootPath,
|
||||||
workspaceDirectory: payload.workspaceDirectory,
|
workspaceDirectory: payload.workspaceDirectory,
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ function appendTodoList(
|
|||||||
): StreamItem[] {
|
): StreamItem[] {
|
||||||
const normalizedItems = items.map((item) => ({
|
const normalizedItems = items.map((item) => ({
|
||||||
text: item.text,
|
text: item.text,
|
||||||
completed: Boolean(item.completed),
|
completed: item.completed,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const lastItem = state[state.length - 1];
|
const lastItem = state[state.length - 1];
|
||||||
@@ -658,7 +658,7 @@ function reduceTimelineEvent(
|
|||||||
}
|
}
|
||||||
const items: TodoEntry[] = (item.items ?? []).map((todo) => ({
|
const items: TodoEntry[] = (item.items ?? []).map((todo) => ({
|
||||||
text: todo.text,
|
text: todo.text,
|
||||||
completed: Boolean(todo.completed),
|
completed: todo.completed,
|
||||||
}));
|
}));
|
||||||
return finalizeActiveThoughts(appendTodoList(state, event.provider, items, timestamp));
|
return finalizeActiveThoughts(appendTodoList(state, event.provider, items, timestamp));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user