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

fix: sonar maintain linting #3 #403

Merged
merged 8 commits into from
Nov 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const QuizContent = ({
potentialNewQuestions,
isLoading: suggestedQuestionsLoading,
hasError: suggestedQuestionsHasError,
setPotentialNewQuestion,
setPotentialNewQuestions,
} = useSuggestedQuestions({
state,
dispatch,
Expand Down Expand Up @@ -85,7 +85,7 @@ const QuizContent = ({
potentialNewQuestions={potentialNewQuestions}
dispatch={dispatch}
suggestedQuestionsGeneration={suggestedQuestionsGeneration}
setPotentialNewQuestions={setPotentialNewQuestion}
setPotentialNewQuestions={setPotentialNewQuestions}
questionsWrapperRef={questionsWrapperRef}
questionRefs={questionRefs}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const QuizDesignerPageContent = ({
potentialNewQuestions,
isLoading: suggestedQuestionsLoading,
hasError: suggestedQuestionsHasError,
setPotentialNewQuestion,
setPotentialNewQuestions,
} = useSuggestedQuestions({
state,
dispatch,
Expand Down Expand Up @@ -101,7 +101,7 @@ const QuizDesignerPageContent = ({
suggestedQuestionsHasError={suggestedQuestionsHasError}
potentialNewQuestions={potentialNewQuestions}
dispatch={dispatch}
setPotentialNewQuestions={setPotentialNewQuestion}
setPotentialNewQuestions={setPotentialNewQuestions}
suggestedQuestionsGeneration={suggestedQuestionsGeneration}
questionRefs={questionRefs}
questionsWrapperRef={questionsWrapperRef}
Expand Down
8 changes: 4 additions & 4 deletions apps/nextjs/src/hooks/useSuggestedQuestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ const useSuggestedQuestions = ({
state,
dispatch,
}: UseSuggestedQuestionsProps) => {
const [potentialNewQuestions, setPotentialNewQuestion] =
const [potentialNewQuestions, setPotentialNewQuestions] =
useState<PotentialQuestionsType>([]);

useEffect(() => {
if (
state.status === QuizAppStatus.EditingSubjectAndKS ||
state.status === QuizAppStatus.Initial
) {
setPotentialNewQuestion([]);
setPotentialNewQuestions([]);
}
}, [state]);

Expand All @@ -60,7 +60,7 @@ const useSuggestedQuestions = ({
});
},
onSuccess: ({ data }) => {
setPotentialNewQuestion(data.response);
setPotentialNewQuestions(data.response);
},
},
);
Expand Down Expand Up @@ -107,7 +107,7 @@ const useSuggestedQuestions = ({
hasError,
potentialNewQuestions,
medianTimeTakenForPrompt,
setPotentialNewQuestion,
setPotentialNewQuestions,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const useTemporaryLessonPlanWithStreamingEdits = ({
// );

return useMemo(() => {
if (!throttledAssistantMessages || !throttledAssistantMessages.length) {
if (!throttledAssistantMessages?.length) {
return {
tempLessonPlan: tempLessonPlanRef.current,
partialPatches: [],
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/lib/hooks/use-copy-to-clipboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import * as React from "react";

interface useCopyToClipboardProps {
interface UseCopyToClipboardProps {
timeout?: number;
}

export function useCopyToClipboard({
timeout = 2000,
}: useCopyToClipboardProps) {
}: UseCopyToClipboardProps) {
const [isCopied, setIsCopied] = React.useState<boolean>(false);

const copyToClipboard = (value: string) => {
Expand All @@ -20,7 +20,7 @@ export function useCopyToClipboard({
return;
}

navigator.clipboard.writeText(value).then(() => {
void navigator.clipboard.writeText(value).then(() => {
setIsCopied(true);

setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/tests-e2e/tests/aila-chat/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function getSectionsComplete(page: Page): Promise<number> {
const progressText = await page.getByTestId("chat-progress").textContent();
const match = (progressText ?? "").match(/(\d+) of 10 sections complete/);

if (match && match[1]) {
if (match?.[1]) {
return parseInt(match[1], 10);
} else {
return 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/router/testSupport/prepareUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const deleteOldTestUser = async () => {
return;
}

const users = testUsers.sort(
const users = testUsers.toSorted(
(a, b) =>
new Date(a.lastActiveAt ?? a.createdAt).getTime() -
new Date(b.lastActiveAt ?? b.createdAt).getTime(),
Expand All @@ -143,7 +143,7 @@ const deleteOldTestUser = async () => {
log.info(
`${userToDelete.primaryEmailAddress?.emailAddress} already deleted, retrying`,
);
deleteOldTestUser();
await deleteOldTestUser();
} else {
throw e;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/models/lessonPlans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ export class LessonPlans {
lessonPlanJsonSchema: JSON.stringify(LessonPlanJsonSchema),
llmResponseJsonSchema: JSON.stringify(LLMResponseJsonSchema),
isUsingStructuredOutput:
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true"
? true
: false,
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true",
});

const systemPrompt = compiledTemplate;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/models/lessons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class Lessons {
lessonId,
quizQuestionId,
}: {
question: { answer?: string | string[] | null | undefined };
question: { answer?: string | string[] | null };
answer: string;
lessonId: string;
quizQuestionId: string;
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/prompts/lesson-assistant/variants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod";

import type { TemplateProps} from ".";
import type { TemplateProps } from ".";
import { getPromptParts } from ".";
import type { OakPromptDefinition, OakPromptVariant } from "../types";

Expand Down Expand Up @@ -59,9 +59,7 @@ export const generateVariants = (): OakPromptVariant[] => {
llmResponseJsonSchema: "<llmResponseJsonSchema>",
lessonPlan: {},
isUsingStructuredOutput:
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true"
? true
: false,
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true",
},
slug,
);
Expand Down
3 changes: 3 additions & 0 deletions packages/ingest/src/embedding/handleEmbeddingBatchSuccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export async function handleEmbeddingBatchSuccess({
continue;
}

if (errors.length > 0) {
log.info(`Errors: ${errors.length}`);
}
lessonIdsCompleted.add(lessonId);
}

Expand Down
Loading