Skip to content

Commit

Permalink
fix tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
testforstephen committed Nov 28, 2023
1 parent 28d6f90 commit b296389
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
53 changes: 27 additions & 26 deletions src/explorerCommands/new.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import * as stringInterpolate from "fmtr";

Check failure on line 4 in src/explorerCommands/new.ts

View workflow job for this annotation

GitHub Actions / Windows

Could not find a declaration file for module 'fmtr'. 'D:/a/vscode-java-dependency/vscode-java-dependency/node_modules/fmtr/index.js' implicitly has an 'any' type.

Check failure on line 4 in src/explorerCommands/new.ts

View workflow job for this annotation

GitHub Actions / macOS

Could not find a declaration file for module 'fmtr'. '/Users/runner/work/vscode-java-dependency/vscode-java-dependency/node_modules/fmtr/index.js' implicitly has an 'any' type.

Check failure on line 4 in src/explorerCommands/new.ts

View workflow job for this annotation

GitHub Actions / Windows-UI

Could not find a declaration file for module 'fmtr'. 'D:/a/vscode-java-dependency/vscode-java-dependency/node_modules/fmtr/index.js' implicitly has an 'any' type.

Check failure on line 4 in src/explorerCommands/new.ts

View workflow job for this annotation

GitHub Actions / Linux

Could not find a declaration file for module 'fmtr'. '/home/runner/work/vscode-java-dependency/vscode-java-dependency/node_modules/fmtr/index.js' implicitly has an 'any' type.

Check failure on line 4 in src/explorerCommands/new.ts

View workflow job for this annotation

GitHub Actions / Linux-UI

Could not find a declaration file for module 'fmtr'. '/home/runner/work/vscode-java-dependency/vscode-java-dependency/node_modules/fmtr/index.js' implicitly has an 'any' type.
import * as fse from "fs-extra";
import { userInfo } from "os";
import * as path from "path";
Expand All @@ -13,36 +14,35 @@ import { DataNode } from "../views/dataNode";
import { resourceRoots } from "../views/packageRootNode";
import { checkJavaQualifiedName } from "./utility";
import { sendError, setUserError } from "vscode-extension-telemetry-wrapper";
const stringInterpolate = require("fmtr");

export class JavaType {
public static readonly Class: JavaType = new JavaType("Class", "class", "$(symbol-class)");
public static readonly Interface: JavaType = new JavaType("Interface", "interface", "$(symbol-interface)");
public static readonly Enum: JavaType = new JavaType("Enum", "enum", "$(symbol-enum)");
public static readonly Record: JavaType = new JavaType("Record", "record", "$(symbol-class)");
public static readonly Annotation: JavaType = new JavaType("Annotation", "@interface", "$(symbol-interface)");
public static readonly AbstractClass: JavaType = new JavaType("Abstract Class", "abstract class", "$(symbol-class)");

public static readonly All: JavaType[] = [
JavaType.Class,
JavaType.Interface,
JavaType.Enum,
JavaType.Record,
JavaType.Annotation,
JavaType.AbstractClass,
public static readonly CLASS: JavaType = new JavaType("Class", "class", "$(symbol-class)");
public static readonly INTERFACE: JavaType = new JavaType("Interface", "interface", "$(symbol-interface)");
public static readonly ENUM: JavaType = new JavaType("Enum", "enum", "$(symbol-enum)");
public static readonly RECORD: JavaType = new JavaType("Record", "record", "$(symbol-class)");
public static readonly ANNOTATION: JavaType = new JavaType("Annotation", "@interface", "$(symbol-interface)");
public static readonly ABSTRACT_CLASS: JavaType = new JavaType("Abstract Class", "abstract class", "$(symbol-class)");

public static readonly ALL: JavaType[] = [
JavaType.CLASS,
JavaType.INTERFACE,
JavaType.ENUM,
JavaType.RECORD,
JavaType.ANNOTATION,
JavaType.ABSTRACT_CLASS,
];

public static fromDisplayName(label: string): JavaType | undefined {
if (label?.startsWith("$")) {
return JavaType.All.find((javaType) => `${javaType.icon} ${javaType.label}` === label);
return JavaType.ALL.find((javaType) => `${javaType.icon} ${javaType.label}` === label);
}

return JavaType.All.find((javaType) => javaType.label === label);
return JavaType.ALL.find((javaType) => javaType.label === label);
}

public static getDisplayNames(includeIcon: boolean, includeRecord?: boolean): string[] {
return JavaType.All
.filter((javaType) => includeRecord || javaType !== JavaType.Record)
return JavaType.ALL
.filter((javaType) => includeRecord || javaType !== JavaType.RECORD)
.map((javaType) => {
if (includeIcon) {
return `${javaType.icon} ${javaType.label}`;
Expand All @@ -53,7 +53,7 @@ export class JavaType {
}

private constructor(public readonly label: string, public readonly keyword: string,
public readonly icon: string) {
public readonly icon: string) {
}
}

Expand Down Expand Up @@ -110,7 +110,7 @@ export async function newResource(node: DataNode): Promise<void> {

// Create a new Java file from the menu bar.
export async function newJavaFile(): Promise<void> {
let packageFsPath: string | undefined = await inferPackageFsPath();
const packageFsPath: string | undefined = await inferPackageFsPath();
if (packageFsPath === undefined) {
// User canceled
return;
Expand Down Expand Up @@ -196,7 +196,7 @@ async function newJavaFileWithContents(fsPath: string, javaType: JavaType, packa
const context: any = {
fileName: path.basename(fsPath),
packageName: "",
typeName: typeName,
typeName,
user: userInfo().username,
date: date.toLocaleDateString(undefined, {month: "short", day: "2-digit", year: "numeric"}),
time: date.toLocaleTimeString(),
Expand Down Expand Up @@ -237,7 +237,7 @@ async function newJavaFileWithContents(fsPath: string, javaType: JavaType, packa
if (isModuleInfo) {
snippets.push(`module {`);
} else {
snippets.push(`public ${javaType.keyword} ${typeName}${javaType === JavaType.Record ? "()" : ""} {`);
snippets.push(`public ${javaType.keyword} ${typeName}${javaType === JavaType.RECORD ? "()" : ""} {`);
}
snippets.push("");
snippets.push("}");
Expand Down Expand Up @@ -341,7 +341,7 @@ const COMPLIANCE = "org.eclipse.jdt.core.compiler.compliance";
async function isVersionLessThan(fileUri: string, targetVersion: number): Promise<boolean> {
let projectSettings: any = {};
try {
projectSettings = await commands.executeCommand<Object>(
projectSettings = await commands.executeCommand<any>(
Commands.EXECUTE_WORKSPACE_COMMAND, Commands.GET_PROJECT_SETTINGS, fileUri, [ COMPLIANCE ]);
} catch (err) {
// do nothing.
Expand All @@ -359,7 +359,7 @@ async function isVersionLessThan(fileUri: string, targetVersion: number): Promis
const regexp = /\d+/g;
const match = regexp.exec(complianceVersion);
if (match) {
javaVersion = parseInt(match[0]);
javaVersion = parseInt(match[0], 10);
}
}

Expand All @@ -368,7 +368,8 @@ async function isVersionLessThan(fileUri: string, targetVersion: number): Promis

async function resolvePackageName(filePath: string): Promise<string> {
let sourcePaths: string[] = [];
const result: IListCommandResult = await commands.executeCommand<IListCommandResult>(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.LIST_SOURCEPATHS);
const result: IListCommandResult =
await commands.executeCommand<IListCommandResult>(Commands.EXECUTE_WORKSPACE_COMMAND, Commands.LIST_SOURCEPATHS);
if (result && result.data && result.data.length) {
sourcePaths = result.data.map((sourcePath) => sourcePath.path).sort((a, b) => b.length - a.length);
}
Expand Down
12 changes: 6 additions & 6 deletions src/views/dependencyExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ export class DependencyExplorer implements Disposable {
newResource(node);
}),
instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_NEW_JAVA_CLASS, async (node?: DataNode) => {
newJavaFileWithSpecificType(JavaType.Class, node);
newJavaFileWithSpecificType(JavaType.CLASS, node);
}),
instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_NEW_JAVA_INTERFACE, async (node?: DataNode) => {
newJavaFileWithSpecificType(JavaType.Interface, node);
newJavaFileWithSpecificType(JavaType.INTERFACE, node);
}),
instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_NEW_JAVA_ENUM, async (node?: DataNode) => {
newJavaFileWithSpecificType(JavaType.Enum, node);
newJavaFileWithSpecificType(JavaType.ENUM, node);
}),
instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_NEW_JAVA_RECORD, async (node?: DataNode) => {
newJavaFileWithSpecificType(JavaType.Record, node);
newJavaFileWithSpecificType(JavaType.RECORD, node);
}),
instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_NEW_JAVA_ANNOTATION, async (node?: DataNode) => {
newJavaFileWithSpecificType(JavaType.Annotation, node);
newJavaFileWithSpecificType(JavaType.ANNOTATION, node);
}),
instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_NEW_JAVA_ABSTRACT_CLASS, async (node?: DataNode) => {
newJavaFileWithSpecificType(JavaType.AbstractClass, node);
newJavaFileWithSpecificType(JavaType.ABSTRACT_CLASS, node);
}),
instrumentOperationAsVsCodeCommand(Commands.VIEW_PACKAGE_NEW_FILE, async (node: DataNode) => {
newFile(node);
Expand Down

0 comments on commit b296389

Please sign in to comment.