From d2d5b6ac8e25bc2046b1960b9a1d22e219299cb9 Mon Sep 17 00:00:00 2001 From: Vincent LE GOFF Date: Sun, 14 Apr 2019 16:53:19 +0200 Subject: [PATCH] Fix eslint warnings and small clean ups (denoland/deno_std#339) Original: https://github.com/denoland/deno_std/commit/95ab4e2a3c8ac5fd7a1175567848ba7c2161b9e3 --- fs/README.md | 2 +- prettier/main_test.ts | 3 ++- testing/main.ts | 2 +- toml/parser.ts | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/README.md b/fs/README.md index ad02199ccb14e3..b80cef7b84a742 100644 --- a/fs/README.md +++ b/fs/README.md @@ -31,7 +31,7 @@ ensureDir("./bar"); // returns a promise ensureDirSync("./ensureDirSync"); // void ``` -### ensure_file +### ensureFile Ensures that the file exists. If the file that is requested to be created is in directories diff --git a/prettier/main_test.ts b/prettier/main_test.ts index 10ad79e36b57bf..3d5d54d6626000 100644 --- a/prettier/main_test.ts +++ b/prettier/main_test.ts @@ -107,7 +107,8 @@ test(async function testPrettierOptions() { const file2 = join(testdata, "opts", "2.ts"); const file3 = join(testdata, "opts", "3.md"); - const getSourceCode = async f => decoder.decode(await Deno.readFile(f)); + const getSourceCode = async (f: string): Promise => + decoder.decode(await Deno.readFile(f)); await run([...cmd, "--no-semi", file0]); assertEquals( diff --git a/testing/main.ts b/testing/main.ts index 64d7e597e674ad..838266f4bb6474 100644 --- a/testing/main.ts +++ b/testing/main.ts @@ -1,7 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { runTests } from "./mod.ts"; -async function main() { +async function main(): Promise { // Testing entire test suite serially await runTests(); } diff --git a/toml/parser.ts b/toml/parser.ts index a7dd977509b8ce..c29f5a761c139a 100644 --- a/toml/parser.ts +++ b/toml/parser.ts @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { existsSync } from "../fs/exists.ts"; +import { readFileStrSync } from "../fs/read_file_str.ts"; import { deepAssign } from "../util/deep_assign.ts"; import { pad } from "../strings/pad.ts"; @@ -542,7 +543,6 @@ export function parseFile(filePath: string): object { if (!existsSync(filePath)) { throw new Error("File not found"); } - const decoder = new TextDecoder(); - const strFile = decoder.decode(Deno.readFileSync(filePath)); + const strFile = readFileStrSync(filePath); return parse(strFile); }