Skip to content

Commit

Permalink
fixed eslint issues in files
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejt10c committed Oct 9, 2023
1 parent e4e4a7b commit 8980d19
Show file tree
Hide file tree
Showing 28 changed files with 361 additions and 127 deletions.
9 changes: 6 additions & 3 deletions src/tasks/logs/mutators/mutateAppendSectionToLog.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { LogContext } from '../LogContext';
import { mutateAppendToLogNoNewline } from './mutateAppendToLogNoNewline';

export function mutateAppendSectionToLog(task: LogContext, section: string): void {
export function mutateAppendSectionToLog(
task: LogContext,
section: string,
): void {
mutateAppendToLogNoNewline(
task,
[
`${[
`////////////////////////////////////////////////////////////////////////////////`,
`// ${section}`,
`////////////////////////////////////////////////////////////////////////////////`,
].join('\n') + '\n\n',
].join('\n')}\n\n`,
);
}
2 changes: 1 addition & 1 deletion src/tasks/logs/mutators/mutateAppendToLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { TaskContext } from '../../TaskContext';
import { mutateAppendToLogNoNewline } from './mutateAppendToLogNoNewline';

export function mutateAppendToLog(task: TaskContext, content: string): void {
mutateAppendToLogNoNewline(task, content + '\n');
mutateAppendToLogNoNewline(task, `${content}\n`);
}
6 changes: 4 additions & 2 deletions src/tasks/logs/mutators/mutateAppendToLogNoNewline.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { getLogProvider } from '../../../managers/LogProvider';
import { TaskContext } from '../../TaskContext';
import { LogContext } from '../LogContext';

export function mutateAppendToLogNoNewline(task: LogContext, content: string): void {
export function mutateAppendToLogNoNewline(
task: LogContext,
content: string,
): void {
task.logContent += content;

getLogProvider().reportChangeInTask(task.id);
Expand Down
5 changes: 4 additions & 1 deletion src/tasks/mutators/mutateGenerateShortName.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { z } from 'zod';

import { gptExecute } from '../../gpt/gptExecute';
import { GPTMode } from '../../gpt/types';
import { TaskContext } from '../TaskContext';
Expand All @@ -10,7 +11,9 @@ export interface ShortNameContext {
selectedText: string;
}

export async function mutateGenerateShortName(task: TaskContext & ShortNameContext) {
export async function mutateGenerateShortName(
task: TaskContext & ShortNameContext,
) {
task.shortName = '...';
task.onChange(true);

Expand Down
5 changes: 4 additions & 1 deletion src/tasks/mutators/mutateReportSmallProgress.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { TaskContext } from '../TaskContext';

export function mutateReportSmallProgress(task: TaskContext, fractionOfBigTask = 0.005) {
export function mutateReportSmallProgress(
task: TaskContext,
fractionOfBigTask = 0.005,
) {
const totalPending = task.stageTargetProgress - task.progress;
const increment = totalPending * fractionOfBigTask;
task.progress = task.progress + increment;
Expand Down
12 changes: 6 additions & 6 deletions src/tasks/mutators/mutateRunTaskStages.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { mutateAppendToLog } from '../logs/mutators/mutateAppendToLog';
import { getEditorManager } from '../../managers/EditorManager';
import { WorkspaceFilesKnowledge } from '../../minionTasks/generateDescriptionForWorkspaceFiles';
import { calculateAndFormatExecutionTime } from '../../utils/calculateAndFormatExecutionTime';
import { mutateAppendToLog } from '../logs/mutators/mutateAppendToLog';
import { TaskContext } from '../TaskContext';
import { TaskCanceled } from '../utils/TaskCanceled';
import { mutateStopExecution } from './mutateStopExecution';
import { WorkspaceFilesKnowledge } from '../../minionTasks/generateDescriptionForWorkspaceFiles';

export function mutateRunTaskStages<TC extends TaskContext>(
task: TC,
Expand All @@ -16,7 +16,7 @@ export function mutateRunTaskStages<TC extends TaskContext>(
getExternalData?: () => Promise<WorkspaceFilesKnowledge[]>,
test?: boolean,
) {
return new Promise<void>(async (resolve, reject) => {
return new Promise<void>((resolve, reject) => {
if (task.stopped) {
return;
}
Expand All @@ -26,15 +26,15 @@ export function mutateRunTaskStages<TC extends TaskContext>(

try {
task.progress = 0;
await execute(task, getExternalData, test);
await mutateStopExecution(task);
execute(task, getExternalData, test);
mutateStopExecution(task);
} catch (error) {
if (!(error instanceof TaskCanceled)) {
getEditorManager().showErrorMessage(`Error in execution: ${error}`);
console.error('Error in execution', error);
}

await mutateStopExecution(
mutateStopExecution(
task,
error instanceof Error ? `Error: ${error.message}` : String(error),
);
Expand Down
10 changes: 7 additions & 3 deletions src/tasks/mutators/mutateStageFinishing.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { getEditorManager } from '../../managers/EditorManager';
import { playNotificationSound } from '../../utils/playSound';
import { TaskContext } from '../TaskContext';
import { mutateAppendSectionToLog } from '../logs/mutators/mutateAppendSectionToLog';
import { TaskContext } from '../TaskContext';
import { ShortNameContext } from './mutateGenerateShortName';

export async function mutateStageFinishing<TC extends TaskContext & ShortNameContext>(task: TC) {
getEditorManager().showInformationMessage(`${task.shortName} is ready to be applied!`);
export async function mutateStageFinishing<
TC extends TaskContext & ShortNameContext,
>(task: TC) {
getEditorManager().showInformationMessage(
`${task.shortName} is ready to be applied!`,
);

mutateAppendSectionToLog(task, task.executionStage);

Expand Down
5 changes: 4 additions & 1 deletion src/tasks/mutators/mutateStartStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export function mutateStartStage({
progressIncrement?: number;
progress?: number;
}) {
task.stageTargetProgress = Math.min(1.0, progress !== undefined ? progress : task.progress + progressIncrement);
task.stageTargetProgress = Math.min(
1.0,
progress !== undefined ? progress : task.progress + progressIncrement,
);
task.executionStage = name;
}
2 changes: 1 addition & 1 deletion src/tasks/mutators/mutateStopExecution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TaskContext } from '../TaskContext';
import { FINISHED_STAGE_NAME } from '../stageNames';
import { TaskContext } from '../TaskContext';

export async function mutateStopExecution(
task: TaskContext,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/MultiSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class MultiSet {
// eslint-disable-next-line eqeqeq
if (v != null && v > 0) {
return v;
} else {
return 0;
}

return 0;
}
}
11 changes: 9 additions & 2 deletions src/utils/calculateAndFormatExecutionTime.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
// Function to calculate and format the execution time in HH:mm:SS format
export function calculateAndFormatExecutionTime(executionDuration: number): string {
export function calculateAndFormatExecutionTime(
executionDuration: number,
): string {
// Function to format the time parts in HH:mm:SS format
function formatExecutionTime(hours: number, minutes: number, seconds: number): string {
function formatExecutionTime(
hours: number,
minutes: number,
seconds: number,
): string {
const paddedHours = hours.toString().padStart(2, '0');
const paddedMinutes = minutes.toString().padStart(2, '0');
const paddedSeconds = seconds.toFixed(0).padStart(2, '0');

return `${paddedHours}:${paddedMinutes}:${paddedSeconds}`;
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/code/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ export function getCommentForLanguage(language: string, content: string) {
export function canAddComment(language: string): boolean {
// Add new language cases here if necessary
const unsupportedLanguages = ['json'];

return !unsupportedLanguages.includes(language);
}
Loading

0 comments on commit 8980d19

Please sign in to comment.