Perfect the codebase for wamr-ide (#1817)

Fix errors and warnings reported by eslint
Add CONTRIBUTING document for vscode-extension
This commit is contained in:
Wang Ning
2022-12-27 15:04:36 +08:00
committed by GitHub
parent 676c3c7b04
commit 679a8ab3cb
14 changed files with 316 additions and 299 deletions

View File

@ -31,7 +31,7 @@ export function createDirectory(
return false;
}
let parent = path.dirname(dest);
const parent = path.dirname(dest);
if (!createDirectory(parent, mode)) {
return false;
}
@ -44,6 +44,7 @@ export function createDirectory(
}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function copyFiles(src: string, dest: string, flags?: number): boolean {
try {
fileSystem.copyFileSync(src, dest);
@ -64,7 +65,7 @@ export function writeIntoFile(path: string, data: string): void {
export function readFromFile(path: string): string {
try {
let data = fileSystem.readFileSync(path, { encoding: 'utf-8' });
const data = fileSystem.readFileSync(path, { encoding: 'utf-8' });
return data as string;
} catch (err) {
vscode.window.showErrorMessage(err as string);
@ -114,9 +115,9 @@ export function checkIfFileExists(path: string): boolean {
return false;
}
export function checkFolderName(folderName: string) {
export function checkFolderName(folderName: string): boolean {
let invalidCharacterArr: string[] = [];
var valid = true;
let valid = true;
if (folderName.length > 255) {
valid = false;
@ -143,6 +144,7 @@ export function downloadFile(
): Promise<void> {
return new Promise((resolve, reject) => {
const file = fileSystem.createWriteStream(destinationPath);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const stream = request(url, undefined, (error, response, body) => {
if (response.statusCode !== 200) {
reject(

View File

@ -9,6 +9,6 @@ export function getUri(
webview: Webview,
extensionUri: Uri,
pathList: string[]
) {
): Uri {
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
}

View File

@ -37,6 +37,7 @@ function getLLDBUnzipFilePath(destinationFolder: string, filename: string) {
export function getWAMRExtensionVersion(
context: vscode.ExtensionContext
): string {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return require(path.join(context.extensionPath, 'package.json')).version;
}
@ -64,7 +65,9 @@ export function isLLDBInstalled(context: vscode.ExtensionContext): boolean {
return checkIfFileExists(lldbBinaryPath);
}
export async function promptInstallLLDB(context: vscode.ExtensionContext) {
export async function promptInstallLLDB(
context: vscode.ExtensionContext
): Promise<void> {
const extensionPath = context.extensionPath;
const setupPrompt = 'setup';
const skipPrompt = 'skip';
@ -111,5 +114,7 @@ export async function promptInstallLLDB(context: vscode.ExtensionContext) {
);
// Remove the bundle.zip
fs.unlink(lldbZipPath, () => {});
fs.unlink(lldbZipPath, () => {
return;
});
}