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 remaining ESLint errors (manually) #105

Merged
merged 3 commits into from
Dec 26, 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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@
"MANIM",
"manimgl",
"Millis",
"prerun",
"Sanderson",
"Sanderson's",
"venv",
"virtualenvs",
"youtube"
]
}
44 changes: 22 additions & 22 deletions src/export.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as vscode from "vscode";
import { QuickPickItem, window } from "vscode";
import { window, TextDocument, CancellationToken, CodeLens } from "vscode";
import {
MultiStepInput, toQuickPickItem, toQuickPickItems,
shouldResumeNoOp,
MultiStepInput, toQuickPickItems, shouldResumeNoOp,
} from "./utils/multiStepQuickPickUtil";
import { findClassLines, findManimSceneName } from "./pythonParsing";
import { Logger, Window } from "./logger";
Expand All @@ -14,11 +13,12 @@ class VideoQuality {
static readonly HIGH = new VideoQuality("High Quality (1080p)", "--hd");
static readonly VERY_HIGH = new VideoQuality("Very High Quality (4K)", "--uhd");

// eslint-disable-next-line no-unused-vars
private constructor(public readonly name: string, public readonly cliFlag: string) { }

/**
* Returns the names of all VideoQuality objects.
*/
* Returns the names of all VideoQuality objects.
*/
static names(): string[] {
return Object.values(VideoQuality).map(quality => quality.name);
}
Expand Down Expand Up @@ -69,8 +69,8 @@ export async function exportScene(sceneName?: string) {
const QUICK_PICK_TITLE = "Export scene as video";

/**
* Lets the user pick the quality of the video to export.
*/
* Lets the user pick the quality of the video to export.
*/
async function pickQuality(input: MultiStepInput, state: Partial<VideoSettings>) {
const qualityPick = await input.showQuickPick({
title: QUICK_PICK_TITLE,
Expand All @@ -86,8 +86,8 @@ export async function exportScene(sceneName?: string) {
}

/**
* Lets the user pick the frames per second (fps) of the video to export.
*/
* Lets the user pick the frames per second (fps) of the video to export.
*/
async function pickFps(input: MultiStepInput, state: Partial<VideoSettings>) {
const fps = await input.showInputBox({
title: QUICK_PICK_TITLE,
Expand All @@ -114,12 +114,12 @@ export async function exportScene(sceneName?: string) {
}

/**
* Lets the user pick the filename of the video to export. The default value
* is the name of the scene followed by ".mp4".
*
* It is ok to not append `.mp4` here as Manim will also do it if it is not
* present in the filename.
*/
* Lets the user pick the filename of the video to export. The default value
* is the name of the scene followed by ".mp4".
*
* It is ok to not append `.mp4` here as Manim will also do it if it is not
* present in the filename.
*/
async function pickFileName(input: MultiStepInput, state: Partial<VideoSettings>) {
const fileName = await input.showInputBox({
title: QUICK_PICK_TITLE,
Expand Down Expand Up @@ -152,8 +152,8 @@ export async function exportScene(sceneName?: string) {
}

/**
* Lets the user pick the folder location where the video should be saved.
*/
* Lets the user pick the folder location where the video should be saved.
*/
async function pickFileLocation(input: MultiStepInput, state: Partial<VideoSettings>) {
const folderUri = await window.showOpenDialog({
canSelectFiles: false,
Expand All @@ -168,9 +168,9 @@ export async function exportScene(sceneName?: string) {
}

/**
* Initiates the multi-step wizard and returns the collected inputs
* from the user.
*/
* Initiates the multi-step wizard and returns the collected inputs
* from the user.
*/
async function collectInputs(): Promise<VideoSettings> {
const state = {} as Partial<VideoSettings>;
state.sceneName = sceneName;
Expand Down Expand Up @@ -225,7 +225,7 @@ function toManimExportCommand(settings: VideoSettings, editor: vscode.TextEditor
* class definition line in the active document.
*/
export class ExportSceneCodeLens implements vscode.CodeLensProvider {
public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.CodeLens[] {
public provideCodeLenses(document: TextDocument, _token: CancellationToken): CodeLens[] {
const codeLenses: vscode.CodeLens[] = [];

for (const classLine of findClassLines(document)) {
Expand All @@ -242,7 +242,7 @@ export class ExportSceneCodeLens implements vscode.CodeLensProvider {
return codeLenses;
}

public resolveCodeLens(codeLens: vscode.CodeLens, token: vscode.CancellationToken): vscode.CodeLens {
public resolveCodeLens(codeLens: CodeLens, _token: CancellationToken): CodeLens {
return codeLens;
}
}
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { window } from "vscode";
import { ManimShell, NoActiveShellError } from "./manimShell";
import { ManimCell } from "./manimCell";
import { previewManimCell, reloadAndPreviewManimCell, previewCode } from "./previewCode";
import { ManimCellRanges } from "./pythonParsing";
import { startScene, exitScene } from "./startStopScene";
import { exportScene } from "./export";
import { Logger, Window, LogRecorder } from "./logger";
Expand Down Expand Up @@ -114,6 +113,7 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
previewManimCellCommand,
previewSelectionCommand,
reloadAndPreviewManimCellCommand,
startSceneCommand,
exitSceneCommand,
clearSceneCommand,
Expand All @@ -134,7 +134,7 @@ export function deactivate() {
/**
* Previews the selected code.
*
* - both ends of the selection automatically extend to the start and end of lines
* - both ends of the selection automatically extend to the start & end of lines
* (for convenience)
* - if Multi-Cursor selection:
* only the first selection is considered
Expand Down
102 changes: 52 additions & 50 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export class Logger {
}

/**
* Clears the output panel and the log file. This is necessary since clearing
* is not performed automatically on MacOS. See issue #58.
*
* @param logFilePath The URI of the log file.
*/
* Clears the output panel and the log file. This is necessary since clearing
* is not performed automatically on MacOS. See issue #58.
*
* @param logFilePath The URI of the log file.
*/
public static async clear(logFilePath: vscode.Uri) {
// This logging statement here is important to ensure that something
// is written to the log file, such that the file is created on disk.
Expand All @@ -82,31 +82,32 @@ export class Logger {
}

/**
* Returns formatted caller information in the form of
* "[filename] [methodname]".
*
* It works by creating a stack trace and extracting the file name from the
* third line of the stack trace, e.g.
*
* Error:
* at Logger.getCurrentFileName (manim-notebook/out/logger.js:32:19)
* at Logger.info (manim-notebook/out/logger.js:46:39)
* at activate (manim-notebook/out/extension.js:37:21)
* ...
*
* where "extension.js:37:21" is the file that called the logger method
* and "activate" is the respective method.
*
* Another example where the Logger is called in a Promise might be:
*
* Error:
* at Function.getFormattedCallerInformation (manim-notebook/src/logger.ts:46:23)
* at Function.info (manim-notebook/src/logger.ts:18:31)
* at manim-notebook/src/extension.ts:199:12
*
* where "extension.ts:199:12" is the file that called the logger method
* and the method is unknown.
*/
* Returns formatted caller information in the form of
* "[filename] [methodname]".
*
* It works by creating a stack trace and extracting the file name from the
* third line of the stack trace, e.g.
*
* Error:
* at Logger.getCurrentFileName (manim-notebook/out/logger.js:32:19)
* at Logger.info (manim-notebook/out/logger.js:46:39)
* at activate (manim-notebook/out/extension.js:37:21)
* ...
*
* where "extension.js:37:21" is the file that called the logger method
* and "activate" is the respective method.
*
* Another example where the Logger is called in a Promise might be:
*
* Error:
* at Function.getFormattedCallerInformation
* (manim-notebook/src/logger.ts:46:23)
* at Function.info (manim-notebook/src/logger.ts:18:31)
* at manim-notebook/src/extension.ts:199:12
*
* where "extension.ts:199:12" is the file that called the logger method
* and the method is unknown.
*/
private static getFormattedCallerInformation(): string {
const error = new Error();
const stack = error.stack;
Expand Down Expand Up @@ -173,11 +174,11 @@ export class LogRecorder {
private static recorderStatusBar: vscode.StatusBarItem;

/**
* Starts recording a log file. Initializes a new status bar item that
* allows the user to stop the recording.
*
* @param context The extension context.
*/
* Starts recording a log file. Initializes a new status bar item that
* allows the user to stop the recording.
*
* @param context The extension context.
*/
public static async recordLogFile(context: vscode.ExtensionContext) {
if (Logger.isRecording) {
window.showInformationMessage("A log file is already being recorded.");
Expand All @@ -191,7 +192,7 @@ export class LogRecorder {
location: vscode.ProgressLocation.Notification,
title: "Setting up Manim Notebook Log recording...",
cancellable: false,
}, async (progressIndicator, token) => {
}, async (_progressIndicator, _token) => {
try {
await Logger.clear(this.getLogFilePath(context));
isClearSuccessful = true;
Expand Down Expand Up @@ -225,11 +226,11 @@ export class LogRecorder {
}

/**
* Finishes the active recording of a log file. Called when the user
* clicks on the status bar item initialized in `recordLogFile()`.
*
* @param context The extension context.
*/
* Finishes the active recording of a log file. Called when the user
* clicks on the status bar item initialized in `recordLogFile()`.
*
* @param context The extension context.
*/
public static async finishRecordingLogFile(context: vscode.ExtensionContext) {
Logger.isRecording = false;
this.recorderStatusBar.dispose();
Expand All @@ -238,25 +239,26 @@ export class LogRecorder {
}

/**
* Returns the URI of the log file that VSCode initializes for us.
*
* @param context The extension context.
*/
* Returns the URI of the log file that VSCode initializes for us.
*
* @param context The extension context.
*/
private static getLogFilePath(context: vscode.ExtensionContext): vscode.Uri {
return vscode.Uri.joinPath(context.logUri, `${LOGGER_NAME}.log`);
}

/**
* Tries to open the log file in an editor and reveal it in the OS file explorer.
*
* @param logFilePath The URI of the log file.
*/
* Tries to open the log file in an editor and reveal it in the
* OS file explorer.
*
* @param logFilePath The URI of the log file.
*/
private static async openLogFile(logFilePath: vscode.Uri) {
await window.withProgress({
location: vscode.ProgressLocation.Notification,
title: "Opening Manim Notebook log file...",
cancellable: false,
}, async (progressIndicator, token) => {
}, async (_progressIndicator, _token) => {
await new Promise<void>(async (resolve) => {
try {
const doc = await vscode.workspace.openTextDocument(logFilePath);
Expand Down
10 changes: 7 additions & 3 deletions src/manimCell.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from "vscode";
import { window } from "vscode";
import { window, TextDocument, CancellationToken,
CodeLens, FoldingContext, FoldingRange } from "vscode";
import { ManimCellRanges } from "./pythonParsing";

export class ManimCell implements vscode.CodeLensProvider, vscode.FoldingRangeProvider {
Expand Down Expand Up @@ -34,7 +35,7 @@ export class ManimCell implements vscode.CodeLensProvider, vscode.FoldingRangePr
});
}

public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.CodeLens[] {
public provideCodeLenses(document: TextDocument, _token: CancellationToken): CodeLens[] {
if (!window.activeTextEditor) {
return [];
}
Expand Down Expand Up @@ -71,7 +72,10 @@ export class ManimCell implements vscode.CodeLensProvider, vscode.FoldingRangePr
return codeLenses;
}

public provideFoldingRanges(document: vscode.TextDocument, context: vscode.FoldingContext, token: vscode.CancellationToken): vscode.FoldingRange[] {
public provideFoldingRanges(
document: TextDocument,
_context: FoldingContext,
_token: CancellationToken): FoldingRange[] {
const ranges = ManimCellRanges.calculateRanges(document);
return ranges.map(range => new vscode.FoldingRange(range.start.line, range.end.line));
}
Expand Down
Loading
Loading