Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix eslint warning #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix eslint warning
  • Loading branch information
zekth committed Apr 19, 2019
commit 026750a2853f0d91b2c0f6cc07d4e24f44b8ec1c
4 changes: 2 additions & 2 deletions js/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function processBlobParts(
// instead of dynamic allocation.
const uint8Arrays = toUint8Arrays(blobParts, normalizeLineEndingsToNative);
const byteLength = uint8Arrays
.map(u8 => u8.byteLength)
.reduce((a, b) => a + b, 0);
.map((u8): number => u8.byteLength)
.reduce((a, b): number => a + b, 0);
const ab = new ArrayBuffer(byteLength);
const bytes = new Uint8Array(ab);

Expand Down
8 changes: 4 additions & 4 deletions js/blob_test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert, assertEquals } from "./test_util.ts";

test(function blobString() {
test(function blobString():void {
const b1 = new Blob(["Hello World"]);
const str = "Test";
const b2 = new Blob([b1, str]);
assertEquals(b2.size, b1.size + str.length);
});

test(function blobBuffer() {
test(function blobBuffer():void {
const buffer = new ArrayBuffer(12);
const u8 = new Uint8Array(buffer);
const f1 = new Float32Array(buffer);
Expand All @@ -18,7 +18,7 @@ test(function blobBuffer() {
assertEquals(b2.size, 3 * u8.length);
});

test(function blobSlice() {
test(function blobSlice():void {
const blob = new Blob(["Deno", "Foo"]);
const b1 = blob.slice(0, 3, "Text/HTML");
assert(b1 instanceof Blob);
Expand All @@ -32,7 +32,7 @@ test(function blobSlice() {
assertEquals(b4.size, blob.size);
});

test(function blobShouldNotThrowError() {
test(function blobShouldNotThrowError():void {
let hasThrown = false;

try {
Expand Down
24 changes: 12 additions & 12 deletions js/buffer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ function repeat(c: string, bytes: number): Uint8Array {
return ui8;
}

test(function bufferNewBuffer() {
test(function bufferNewBuffer(): void {
init();
const buf = new Buffer(testBytes.buffer as ArrayBuffer);
check(buf, testString);
});

test(async function bufferBasicOperations() {
test(async function bufferBasicOperations(): Promise<void> {
init();
let buf = new Buffer();
for (let i = 0; i < 5; i++) {
Expand Down Expand Up @@ -120,7 +120,7 @@ test(async function bufferBasicOperations() {
}
});

test(async function bufferReadEmptyAtEOF() {
test(async function bufferReadEmptyAtEOF(): Promise<void> {
// check that EOF of 'buf' is not reached (even though it's empty) if
// results are written to buffer that has 0 length (ie. it can't store any data)
let buf = new Buffer();
Expand All @@ -130,7 +130,7 @@ test(async function bufferReadEmptyAtEOF() {
assertEquals(result.eof, false);
});

test(async function bufferLargeByteWrites() {
test(async function bufferLargeByteWrites(): Promise<void> {
init();
const buf = new Buffer();
const limit = 9;
Expand All @@ -141,7 +141,7 @@ test(async function bufferLargeByteWrites() {
check(buf, "");
});

test(async function bufferTooLargeByteWrites() {
test(async function bufferTooLargeByteWrites(): Promise<void> {
init();
const tmp = new Uint8Array(72);
const growLen = Number.MAX_VALUE;
Expand All @@ -160,7 +160,7 @@ test(async function bufferTooLargeByteWrites() {
assertEquals(err.name, "TooLarge");
});

test(async function bufferLargeByteReads() {
test(async function bufferLargeByteReads(): Promise<void> {
init();
const buf = new Buffer();
for (let i = 3; i < 30; i += 3) {
Expand All @@ -171,12 +171,12 @@ test(async function bufferLargeByteReads() {
check(buf, "");
});

test(function bufferCapWithPreallocatedSlice() {
test(function bufferCapWithPreallocatedSlice(): void {
const buf = new Buffer(new ArrayBuffer(10));
assertEquals(buf.capacity, 10);
});

test(async function bufferReadFrom() {
test(async function bufferReadFrom():Promise<void> {
init();
const buf = new Buffer();
for (let i = 3; i < 30; i += 3) {
Expand All @@ -193,7 +193,7 @@ test(async function bufferReadFrom() {
}
});

test(async function bufferReadFromSync() {
test(async function bufferReadFromSync(): Promise<void> {
init();
const buf = new Buffer();
for (let i = 3; i < 30; i += 3) {
Expand All @@ -210,7 +210,7 @@ test(async function bufferReadFromSync() {
}
});

test(async function bufferTestGrow() {
test(async function bufferTestGrow(): Promise<void> {
const tmp = new Uint8Array(72);
for (let startLen of [0, 100, 1000, 10000, 100000]) {
const xBytes = repeat("x", startLen);
Expand All @@ -234,7 +234,7 @@ test(async function bufferTestGrow() {
}
});

test(async function testReadAll() {
test(async function testReadAll(): Promise<void> {
init();
const reader = new Buffer(testBytes.buffer as ArrayBuffer);
const actualBytes = await readAll(reader);
Expand All @@ -244,7 +244,7 @@ test(async function testReadAll() {
}
});

test(function testReadAllSync() {
test(function testReadAllSync(): void {
init();
const reader = new Buffer(testBytes.buffer as ArrayBuffer);
const actualBytes = readAllSync(reader);
Expand Down
4 changes: 2 additions & 2 deletions js/build_test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { test, assert } from "./test_util.ts";

test(function buildInfo() {
test(function buildInfo():void {
// Deno.build is injected by rollup at compile time. Here
// we check it has been properly transformed.
const { arch, os } = Deno.build;
assert(arch === "x64");
assert(os === "mac" || os === "win" || os === "linux");
});

test(function buildGnArgs() {
test(function buildGnArgs():void {
assert(Deno.build.args.length > 100);
});
16 changes: 8 additions & 8 deletions js/chmod_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { testPerm, assertEquals } from "./test_util.ts";

const isNotWindows = Deno.build.os !== "win";

testPerm({ read: true, write: true }, function chmodSyncSuccess() {
testPerm({ read: true, write: true }, function chmodSyncSuccess():void {
const enc = new TextEncoder();
const data = enc.encode("Hello");
const tempDir = Deno.makeTempDirSync();
Expand All @@ -22,7 +22,7 @@ testPerm({ read: true, write: true }, function chmodSyncSuccess() {

// Check symlink when not on windows
if (isNotWindows) {
testPerm({ read: true, write: true }, function chmodSyncSymlinkSuccess() {
testPerm({ read: true, write: true }, function chmodSyncSymlinkSuccess():void {
const enc = new TextEncoder();
const data = enc.encode("Hello");
const tempDir = Deno.makeTempDirSync();
Expand All @@ -45,7 +45,7 @@ if (isNotWindows) {
});
}

testPerm({ write: true }, function chmodSyncFailure() {
testPerm({ write: true }, function chmodSyncFailure():void {
let err;
try {
const filename = "/badfile.txt";
Expand All @@ -57,7 +57,7 @@ testPerm({ write: true }, function chmodSyncFailure() {
assertEquals(err.name, "NotFound");
});

testPerm({ write: false }, function chmodSyncPerm() {
testPerm({ write: false }, function chmodSyncPerm():void {
let err;
try {
Deno.chmodSync("/somefile.txt", 0o777);
Expand All @@ -68,7 +68,7 @@ testPerm({ write: false }, function chmodSyncPerm() {
assertEquals(err.name, "PermissionDenied");
});

testPerm({ read: true, write: true }, async function chmodSuccess() {
testPerm({ read: true, write: true }, async function chmodSuccess():Promise<void> {
const enc = new TextEncoder();
const data = enc.encode("Hello");
const tempDir = Deno.makeTempDirSync();
Expand All @@ -87,7 +87,7 @@ testPerm({ read: true, write: true }, async function chmodSuccess() {

// Check symlink when not on windows
if (isNotWindows) {
testPerm({ read: true, write: true }, async function chmodSymlinkSuccess() {
testPerm({ read: true, write: true }, async function chmodSymlinkSuccess():Promise<void> {
const enc = new TextEncoder();
const data = enc.encode("Hello");
const tempDir = Deno.makeTempDirSync();
Expand All @@ -110,7 +110,7 @@ if (isNotWindows) {
});
}

testPerm({ write: true }, async function chmodFailure() {
testPerm({ write: true }, async function chmodFailure():Promise<void> {
let err;
try {
const filename = "/badfile.txt";
Expand All @@ -122,7 +122,7 @@ testPerm({ write: true }, async function chmodFailure() {
assertEquals(err.name, "NotFound");
});

testPerm({ write: false }, async function chmodPerm() {
testPerm({ write: false }, async function chmodPerm():Promise<void> {
let err;
try {
await Deno.chmod("/somefile.txt", 0o777);
Expand Down
6 changes: 3 additions & 3 deletions js/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class Compiler implements ts.LanguageServiceHost, ts.FormatDiagnosticsHost {
// so we will ignore complaints about this compiler setting.
...service
.getCompilerOptionsDiagnostics()
.filter(diagnostic => diagnostic.code !== 5070),
.filter((diagnostic): boolean => diagnostic.code !== 5070),
...service.getSyntacticDiagnostics(fileName),
...service.getSemanticDiagnostics(fileName)
];
Expand Down Expand Up @@ -519,9 +519,9 @@ window.TextEncoder = TextEncoder;

// provide the "main" function that will be called by the privileged side when
// lazy instantiating the compiler web worker
window.compilerMain = function compilerMain() {
window.compilerMain = function compilerMain(): void {
// workerMain should have already been called since a compiler is a worker.
window.onmessage = ({ data }: { data: CompilerLookup }) => {
window.onmessage = ({ data }: { data: CompilerLookup }): void => {
const { specifier, referrer, cmdId } = data;

try {
Expand Down
Loading