Skip to content

Commit

Permalink
Run ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdprng committed Sep 10, 2024
1 parent a796474 commit a52401a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 29 deletions.
40 changes: 20 additions & 20 deletions src/codeMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class WARoot {
* @returns A list of `uri`s to decorate and the relevant username. TODO
*/
toggleAudited(uri: vscode.Uri, relativePath: string): [vscode.Uri[], string] {
let relevantUsername: string = "";
let relevantUsername = "";

let urisToDecorate: vscode.Uri[] = [];

Expand Down Expand Up @@ -536,7 +536,7 @@ class WARoot {
* @param uri The uri of the file that was audit-toggle
*/
checkIfAllSiblingFilesAreAudited(uri: vscode.Uri) {
let urisToDecorate: vscode.Uri[] = [];
const urisToDecorate: vscode.Uri[] = [];
// iterate over all the files in the same folder as the file that was audited
const folder = path.dirname(uri.fsPath);
const files = fs.readdirSync(folder);
Expand Down Expand Up @@ -964,8 +964,8 @@ class MultiRootManager {
* @returns An array of current the current WARoot instances.
*/
private setupRoots(): WARoot[] {
let roots: WARoot[] = [];
if (vscode.workspace.workspaceFolders == undefined) {
const roots: WARoot[] = [];
if (vscode.workspace.workspaceFolders === undefined) {
return roots;
}
for (const folder of vscode.workspace.workspaceFolders) {
Expand Down Expand Up @@ -1173,15 +1173,15 @@ class MultiRootManager {
* The paths are all extended to full.
*/
getMarkedFilesDayLog(): Map<string, FullPath[]> {
let mergedMarkedFilesDayLog: Map<string, FullPath[]> = new Map<string, FullPath[]>();
const mergedMarkedFilesDayLog: Map<string, FullPath[]> = new Map<string, FullPath[]>();
for (const root of this.roots) {
root.markedFilesDayLog.forEach((value, key) => {
const current_value = mergedMarkedFilesDayLog.get(key);
const update_value = value.map((path) => ({ rootPath: root.rootPath, path: path }) as FullPath);
if (current_value === undefined) {
mergedMarkedFilesDayLog.set(key, update_value);
const currentValue = mergedMarkedFilesDayLog.get(key);
const updateValue = value.map((path) => ({ rootPath: root.rootPath, path: path }) as FullPath);
if (currentValue === undefined) {
mergedMarkedFilesDayLog.set(key, updateValue);
} else {
mergedMarkedFilesDayLog.set(key, current_value.concat(update_value));
mergedMarkedFilesDayLog.set(key, currentValue.concat(updateValue));
}
});
}
Expand Down Expand Up @@ -1476,15 +1476,15 @@ export class CodeMarker implements vscode.TreeDataProvider<TreeEntry> {
// First check that all locations are inside one of the workspace roots:
for (const result of results) {
for (const loc of result.locations) {
const [wsRoot, relativePath] = this.workspaces.getCorrespondingRootAndPath(loc.path);
const [wsRoot, _relativePath] = this.workspaces.getCorrespondingRootAndPath(loc.path);
if (wsRoot === undefined) {
vscode.window.showErrorMessage(`Failed to load external findings. The file ${loc.path} is not in any workspace root.`);
return;
}
}
}

let fullResults = results.map(
const fullResults = results.map(
(entry) =>
({
label: entry.label,
Expand Down Expand Up @@ -1639,19 +1639,19 @@ export class CodeMarker implements vscode.TreeDataProvider<TreeEntry> {
/**
* Transforms a relative or absolute path in a normalized path relative to the path of a workspace root.
* @param _path the path to transform
* @param _root_path the root path to be used to relativize the target path
* @param _rootPath the root path to be used to relativize the target path
* @returns the normalized path relative to the path of a workspace root
* @throws an error if the path is not in the workspace
*/
private relativizePath(_path: string, _root_path: string): string {
private relativizePath(_path: string, _rootPath: string): string {
_path = path.normalize(_path);

if (path.isAbsolute(_path)) {
_path = path.relative(_root_path, _path);
_path = path.relative(_rootPath, _path);
}

if (_path.startsWith("..")) {
throw new Error(`The file ${_path} is not in the workspace (${_root_path}).`);
throw new Error(`The file ${_path} is not in the workspace (${_rootPath}).`);
}

return _path;
Expand Down Expand Up @@ -2686,7 +2686,7 @@ export class CodeMarker implements vscode.TreeDataProvider<TreeEntry> {
}

// For backwards compatibility, we need to add the rootpath to the locations here
let rootPath = wsRoot.rootPath;
const rootPath = wsRoot.rootPath;
const fullParsedEntries = {
clientRemote: parsedEntries.clientRemote,
gitRemote: parsedEntries.gitRemote,
Expand Down Expand Up @@ -2755,7 +2755,7 @@ export class CodeMarker implements vscode.TreeDataProvider<TreeEntry> {
);
}

let newTreeEntries = fullParsedEntries.treeEntries;
const newTreeEntries = fullParsedEntries.treeEntries;

this.treeEntries = this.treeEntries.concat(newTreeEntries);
wsRoot.concatAudited(fullParsedEntries.auditedFiles);
Expand Down Expand Up @@ -3262,8 +3262,8 @@ export class CodeMarker implements vscode.TreeDataProvider<TreeEntry> {
}
}

refreshAndDecorateFromPath(path_: string, root_path: string): void {
const uri = vscode.Uri.file(path.join(root_path, path_));
refreshAndDecorateFromPath(path_: string, rootPath: string): void {
const uri = vscode.Uri.file(path.join(rootPath, path_));
this.decorateWithUri(uri);
this.refresh(uri);
}
Expand Down
4 changes: 2 additions & 2 deletions src/multiConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class MultipleSavedFindingsTree implements vscode.TreeDataProvider<Config
this.activeConfigs = [];
this.findAndLoadConfigurationFiles();

const listener = (event: vscode.WorkspaceFoldersChangeEvent) => {
const listener = (_event: vscode.WorkspaceFoldersChangeEvent) => {
this.rootPaths = [];
this.getWorkspaceRootPaths();
this.configurationEntries = [];
Expand Down Expand Up @@ -137,7 +137,7 @@ export class MultipleSavedFindingsTree implements vscode.TreeDataProvider<Config

getWorkspaceRootPaths() {
this.rootPaths = [];
if (vscode.workspace.workspaceFolders == undefined) {
if (vscode.workspace.workspaceFolders === undefined) {
return;
}
for (const folder of vscode.workspace.workspaceFolders) {
Expand Down
7 changes: 2 additions & 5 deletions src/panels/gitConfigPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getUri } from "../utilities/getUri";
import { WebviewMessage, UpdateRepositoryMessage, SetWorkspaceRootsMessage } from "../webview/webviewMessageTypes";

export function activateGitConfigWebview(context: vscode.ExtensionContext) {
const provider = new GitConfigProvider(context.extensionUri, context);
const provider = new GitConfigProvider(context.extensionUri);

context.subscriptions.push(vscode.window.registerWebviewViewProvider(GitConfigProvider.viewType, provider));
}
Expand All @@ -19,10 +19,7 @@ class GitConfigProvider implements vscode.WebviewViewProvider {

private _view?: vscode.WebviewView;

constructor(
private readonly _extensionUri: vscode.Uri,
context: vscode.ExtensionContext,
) {
constructor(private readonly _extensionUri: vscode.Uri) {
this.currentRootPath = "";
this.dirToPathMap = new Map<string, string>();

Expand Down
2 changes: 1 addition & 1 deletion src/resolvedFindings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vscode from "vscode";
import * as path from "path";

import { Entry, FullEntry, EntryType } from "./types";
import { FullEntry, EntryType } from "./types";

export class ResolvedEntriesTree implements vscode.TreeDataProvider<FullEntry> {
private resolvedEntries: FullEntry[];
Expand Down
3 changes: 2 additions & 1 deletion src/webview/gitConfigMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function main() {
// handle the message inside the webview
window.addEventListener("message", (event) => {
const message = event.data;
let rootList;

switch (message.command) {
case "update-repository-config":
Expand All @@ -40,7 +41,7 @@ function main() {
break;

case "set-workspace-roots":
const rootList = document.getElementById("workspace-root-list-dropdown");
rootList = document.getElementById("workspace-root-list-dropdown");
if (rootList === null) {
break;
}
Expand Down

0 comments on commit a52401a

Please sign in to comment.