Fix lints and errors in fidl format code.
Change-Id: I21df9115e4aca73044422e2cca3543b89f071359
diff --git a/vscode-language-fidl/src/tool_finder.ts b/vscode-language-fidl/src/tool_finder.ts
index ef1cb49..bb1ec03 100644
--- a/vscode-language-fidl/src/tool_finder.ts
+++ b/vscode-language-fidl/src/tool_finder.ts
@@ -30,14 +30,13 @@
*/
function deriveZirconOutPath(fuchsiaRoot: string): string | null {
const buildOutputPointer = path.join(fuchsiaRoot, '.fx-build-dir');
- let outputRoot
try {
- outputRoot = fs.readFileSync(buildOutputPointer, { encoding: 'utf8' }).trim();
+ const outputRoot = fs.readFileSync(buildOutputPointer, { encoding: 'utf8' }).trim();
+ return path.join(fuchsiaRoot, outputRoot + '.zircon');
} catch (err) {
// TODO: proper error handling
return null;
}
- return path.join(fuchsiaRoot, outputRoot + '.zircon');
}
/**
@@ -103,7 +102,7 @@
const basePath = path.dirname(uri.fsPath);
const toolPath = findFidlFormatInFolder(basePath);
- if (toolPath == null) {
+ if (toolPath === null) {
continue;
}
@@ -137,7 +136,7 @@
// Traverse through parent repositories until the direct child of the
// root directory.
for (folderPath = folder.uri.fsPath;
- path.dirname(folderPath) != folderPath;
+ path.dirname(folderPath) !== folderPath;
folderPath = path.dirname(folderPath)) {
const toolPath = findFidlFormatInFolder(folderPath);
@@ -166,13 +165,12 @@
let formatTool: string | undefined | null
= vscode.workspace.getConfiguration('fidl').get('formatTool');
- try {
- fs.accessSync(toolPath, fs.constants.X_OK);
- } catch (err) {
- throw new FormatToolError(FormatToolErrorCause.ToolNotExecutable);
- }
-
if (formatTool) {
+ try {
+ fs.accessSync(formatTool, fs.constants.X_OK);
+ } catch (err) {
+ throw new FormatToolError(FormatToolErrorCause.ToolNotExecutable);
+ }
return formatTool;
} else {
return null;