summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2019-09-08 01:27:18 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-09-07 12:27:18 -0400
commitf12acdb50bd6afae21d8d033548c012d23ec2791 (patch)
treee61071f25a9dfe3ea853bcaea0ece7307a02bc73 /js
parenta205e8a3c2bf5ba72fe18bd7f224303338956c62 (diff)
Update @typescript-eslint/* to v2.1.0 (#2878)
Diffstat (limited to 'js')
-rw-r--r--js/base64.ts49
-rw-r--r--js/blob.ts4
-rw-r--r--js/blob_test.ts2
-rw-r--r--js/buffer_test.ts12
-rw-r--r--js/colors.ts2
-rw-r--r--js/compiler.ts4
-rw-r--r--js/console.ts4
-rw-r--r--js/diagnostics.ts2
-rw-r--r--js/dom_util.ts2
-rw-r--r--js/files.ts2
-rw-r--r--js/files_test.ts2
-rw-r--r--js/io.ts2
-rw-r--r--js/main.ts2
-rw-r--r--js/permissions_test.ts2
-rw-r--r--js/process_test.ts10
-rw-r--r--js/request.ts2
-rw-r--r--js/text_encoding.ts2
-rw-r--r--js/text_encoding_test.ts4
-rw-r--r--js/timers.ts10
-rw-r--r--js/workers.ts4
-rw-r--r--js/xeval.ts4
21 files changed, 64 insertions, 63 deletions
diff --git a/js/base64.ts b/js/base64.ts
index 38fd9824d..4d30e00f1 100644
--- a/js/base64.ts
+++ b/js/base64.ts
@@ -5,7 +5,7 @@ const lookup: string[] = [];
const revLookup: number[] = [];
const code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-for (var i = 0, len = code.length; i < len; ++i) {
+for (let i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i];
revLookup[code.charCodeAt(i)] = i;
}
@@ -16,7 +16,7 @@ revLookup["-".charCodeAt(0)] = 62;
revLookup["_".charCodeAt(0)] = 63;
function getLens(b64: string): [number, number] {
- var len = b64.length;
+ const len = b64.length;
if (len % 4 > 0) {
throw new Error("Invalid string. Length must be a multiple of 4");
@@ -24,19 +24,19 @@ function getLens(b64: string): [number, number] {
// Trim off extra bytes after placeholder bytes are found
// See: https://github.com/beatgammit/base64-js/issues/42
- var validLen = b64.indexOf("=");
+ let validLen = b64.indexOf("=");
if (validLen === -1) validLen = len;
- var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4);
+ const placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4);
return [validLen, placeHoldersLen];
}
// base64 is 4/3 + up to two characters of the original data
export function byteLength(b64: string): number {
- var lens = getLens(b64);
- var validLen = lens[0];
- var placeHoldersLen = lens[1];
+ const lens = getLens(b64);
+ const validLen = lens[0];
+ const placeHoldersLen = lens[1];
return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen;
}
@@ -49,19 +49,20 @@ function _byteLength(
}
export function toByteArray(b64: string): Uint8Array {
- var tmp;
- var lens = getLens(b64);
- var validLen = lens[0];
- var placeHoldersLen = lens[1];
+ let tmp;
+ const lens = getLens(b64);
+ const validLen = lens[0];
+ const placeHoldersLen = lens[1];
- var arr = new Uint8Array(_byteLength(b64, validLen, placeHoldersLen));
+ const arr = new Uint8Array(_byteLength(b64, validLen, placeHoldersLen));
- var curByte = 0;
+ let curByte = 0;
// if there are placeholders, only get up to the last complete 4 chars
- var len = placeHoldersLen > 0 ? validLen - 4 : validLen;
+ const len = placeHoldersLen > 0 ? validLen - 4 : validLen;
- for (var i = 0; i < len; i += 4) {
+ let i;
+ for (i = 0; i < len; i += 4) {
tmp =
(revLookup[b64.charCodeAt(i)] << 18) |
(revLookup[b64.charCodeAt(i + 1)] << 12) |
@@ -101,9 +102,9 @@ function tripletToBase64(num: number): string {
}
function encodeChunk(uint8: Uint8Array, start: number, end: number): string {
- var tmp;
- var output = [];
- for (var i = start; i < end; i += 3) {
+ let tmp;
+ const output = [];
+ for (let i = start; i < end; i += 3) {
tmp =
((uint8[i] << 16) & 0xff0000) +
((uint8[i + 1] << 8) & 0xff00) +
@@ -114,14 +115,14 @@ function encodeChunk(uint8: Uint8Array, start: number, end: number): string {
}
export function fromByteArray(uint8: Uint8Array): string {
- var tmp;
- var len = uint8.length;
- var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
- var parts = [];
- var maxChunkLength = 16383; // must be multiple of 3
+ let tmp;
+ const len = uint8.length;
+ const extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes
+ const parts = [];
+ const maxChunkLength = 16383; // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
+ for (let i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
parts.push(
encodeChunk(
uint8,
diff --git a/js/blob.ts b/js/blob.ts
index 4c86f1f24..50ab7f374 100644
--- a/js/blob.ts
+++ b/js/blob.ts
@@ -7,7 +7,7 @@ import { build } from "./build.ts";
export const bytesSymbol = Symbol("bytes");
function convertLineEndingsToNative(s: string): string {
- let nativeLineEnd = build.os == "win" ? "\r\n" : "\n";
+ const nativeLineEnd = build.os == "win" ? "\r\n" : "\n";
let position = 0;
@@ -19,7 +19,7 @@ function convertLineEndingsToNative(s: string): string {
let result = token;
while (position < s.length) {
- let c = s.charAt(position);
+ const c = s.charAt(position);
if (c == "\r") {
result += nativeLineEnd;
position++;
diff --git a/js/blob_test.ts b/js/blob_test.ts
index 7fc7db1e2..afa1182a9 100644
--- a/js/blob_test.ts
+++ b/js/blob_test.ts
@@ -54,7 +54,7 @@ test(function nativeEndLine(): void {
const options: object = {
ending: "native"
};
- let blob = new Blob(["Hello\nWorld"], options);
+ const blob = new Blob(["Hello\nWorld"], options);
assertEquals(blob.size, Deno.build.os === "win" ? 12 : 11);
});
diff --git a/js/buffer_test.ts b/js/buffer_test.ts
index 911750bb1..a157b927e 100644
--- a/js/buffer_test.ts
+++ b/js/buffer_test.ts
@@ -45,7 +45,7 @@ async function fillBytes(
): Promise<string> {
check(buf, s);
for (; n > 0; n--) {
- let m = await buf.write(fub);
+ const m = await buf.write(fub);
assertEquals(m, fub.byteLength);
const decoder = new TextDecoder();
s += decoder.decode(fub);
@@ -84,7 +84,7 @@ test(function bufferNewBuffer(): void {
test(async function bufferBasicOperations(): Promise<void> {
init();
- let buf = new Buffer();
+ const buf = new Buffer();
for (let i = 0; i < 5; i++) {
check(buf, "");
@@ -123,9 +123,9 @@ test(async function bufferBasicOperations(): Promise<void> {
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();
+ const buf = new Buffer();
const zeroLengthTmp = new Uint8Array(0);
- let result = await buf.read(zeroLengthTmp);
+ const result = await buf.read(zeroLengthTmp);
assertEquals(result, 0);
});
@@ -211,9 +211,9 @@ test(async function bufferReadFromSync(): Promise<void> {
test(async function bufferTestGrow(): Promise<void> {
const tmp = new Uint8Array(72);
- for (let startLen of [0, 100, 1000, 10000, 100000]) {
+ for (const startLen of [0, 100, 1000, 10000, 100000]) {
const xBytes = repeat("x", startLen);
- for (let growLen of [0, 100, 1000, 10000, 100000]) {
+ for (const growLen of [0, 100, 1000, 10000, 100000]) {
const buf = new Buffer(xBytes.buffer as ArrayBuffer);
// If we read, this affects buf.off, which is good to test.
const result = await buf.read(tmp);
diff --git a/js/colors.ts b/js/colors.ts
index 47a893036..9937bdb57 100644
--- a/js/colors.ts
+++ b/js/colors.ts
@@ -11,7 +11,7 @@ interface Code {
regexp: RegExp;
}
-let enabled = !noColor;
+const enabled = !noColor;
function code(open: number, close: number): Code {
return {
diff --git a/js/compiler.ts b/js/compiler.ts
index 255ac9774..12062e63f 100644
--- a/js/compiler.ts
+++ b/js/compiler.ts
@@ -61,7 +61,7 @@ interface ConfigureResponse {
/** Options that either do nothing in Deno, or would cause undesired behavior
* if modified. */
-const ignoredCompilerOptions: ReadonlyArray<string> = [
+const ignoredCompilerOptions: readonly string[] = [
"allowSyntheticDefaultImports",
"baseUrl",
"build",
@@ -415,7 +415,7 @@ class Host implements ts.CompilerHost {
data: string,
writeByteOrderMark: boolean,
onError?: (message: string) => void,
- sourceFiles?: ReadonlyArray<ts.SourceFile>
+ sourceFiles?: readonly ts.SourceFile[]
): void {
util.log("writeFile", fileName);
try {
diff --git a/js/console.ts b/js/console.ts
index c778ee928..9f0ce4bd6 100644
--- a/js/console.ts
+++ b/js/console.ts
@@ -490,7 +490,7 @@ const isConsoleInstance = Symbol("isConsoleInstance");
export class Console {
indentLevel: number;
- [isConsoleInstance]: boolean = false;
+ [isConsoleInstance] = false;
/** @internal */
constructor(private printFunc: PrintFunc) {
@@ -501,7 +501,7 @@ export class Console {
// For historical web-compatibility reasons, the namespace object for
// console must have as its [[Prototype]] an empty object, created as if
// by ObjectCreate(%ObjectPrototype%), instead of %ObjectPrototype%.
- let console = Object.create({}) as Console;
+ const console = Object.create({}) as Console;
Object.assign(console, this);
return console;
}
diff --git a/js/diagnostics.ts b/js/diagnostics.ts
index 4085d31fe..5da91483c 100644
--- a/js/diagnostics.ts
+++ b/js/diagnostics.ts
@@ -204,7 +204,7 @@ function parseRelatedInformation(
export function fromTypeScriptDiagnostic(
diagnostics: readonly ts.Diagnostic[]
): Diagnostic {
- let items: DiagnosticItem[] = [];
+ const items: DiagnosticItem[] = [];
for (const sourceDiagnostic of diagnostics) {
const item: DiagnosticItem = parseDiagnostic(sourceDiagnostic);
if (sourceDiagnostic.relatedInformation) {
diff --git a/js/dom_util.ts b/js/dom_util.ts
index 85a33fad1..725a35aaf 100644
--- a/js/dom_util.ts
+++ b/js/dom_util.ts
@@ -50,7 +50,7 @@ export function isShadowInclusiveAncestor(
export function getRoot(
node: domTypes.EventTarget | null
): domTypes.EventTarget | null {
- let root = node;
+ const root = node;
// for (const ancestor of domSymbolTree.ancestorsIterator(node)) {
// root = ancestor;
diff --git a/js/files.ts b/js/files.ts
index 98d18f0cf..b83a147e1 100644
--- a/js/files.ts
+++ b/js/files.ts
@@ -115,7 +115,7 @@ export function writeSync(rid: number, p: Uint8Array): number {
*
*/
export async function write(rid: number, p: Uint8Array): Promise<number> {
- let result = await sendAsyncMinimal(dispatch.OP_WRITE, rid, p);
+ const result = await sendAsyncMinimal(dispatch.OP_WRITE, rid, p);
if (result < 0) {
throw new Error("write error");
} else {
diff --git a/js/files_test.ts b/js/files_test.ts
index babec1fc2..004cb662b 100644
--- a/js/files_test.ts
+++ b/js/files_test.ts
@@ -323,7 +323,7 @@ testPerm({ read: true }, async function seekMode(): Promise<void> {
// We should still be able to read the file
// since it is still open.
- let buf = new Uint8Array(1);
+ const buf = new Uint8Array(1);
await file.read(buf); // "H"
assertEquals(new TextDecoder().decode(buf), "H");
});
diff --git a/js/io.ts b/js/io.ts
index aa1f08f36..1a7bf8c4c 100644
--- a/js/io.ts
+++ b/js/io.ts
@@ -6,7 +6,7 @@
// TODO(kt3k): EOF should be `unique symbol` type.
// That might require some changes of ts_library_builder.
// See #2591 for more details.
-export const EOF: null = null;
+export const EOF = null;
export type EOF = null;
// Seek whence values.
diff --git a/js/main.ts b/js/main.ts
index 474fc74a4..6a75f55e0 100644
--- a/js/main.ts
+++ b/js/main.ts
@@ -13,7 +13,7 @@ import { setLocation } from "./location.ts";
import { setBuildInfo } from "./build.ts";
import { setSignals } from "./process.ts";
-function denoMain(preserveDenoNamespace: boolean = true, name?: string): void {
+function denoMain(preserveDenoNamespace = true, name?: string): void {
const s = os.start(preserveDenoNamespace, name);
setBuildInfo(s.os, s.arch);
diff --git a/js/permissions_test.ts b/js/permissions_test.ts
index 932ec2480..6511c2dcb 100644
--- a/js/permissions_test.ts
+++ b/js/permissions_test.ts
@@ -10,7 +10,7 @@ const knownPermissions: Deno.Permission[] = [
"hrtime"
];
-for (let grant of knownPermissions) {
+for (const grant of knownPermissions) {
testPerm({ [grant]: true }, function envGranted(): void {
const perms = Deno.permissions();
assert(perms !== null);
diff --git a/js/process_test.ts b/js/process_test.ts
index 69b904b73..0f9f608e8 100644
--- a/js/process_test.ts
+++ b/js/process_test.ts
@@ -44,10 +44,10 @@ testPerm({ run: true }, async function runSuccess(): Promise<void> {
testPerm({ run: true }, async function runCommandFailedWithCode(): Promise<
void
> {
- let p = run({
+ const p = run({
args: ["python", "-c", "import sys;sys.exit(41 + 1)"]
});
- let status = await p.status();
+ const status = await p.status();
assertEquals(status.success, false);
assertEquals(status.code, 42);
assertEquals(status.signal, undefined);
@@ -133,8 +133,8 @@ testPerm({ run: true }, async function runStdinPiped(): Promise<void> {
assert(!p.stdout);
assert(!p.stderr);
- let msg = new TextEncoder().encode("hello");
- let n = await p.stdin.write(msg);
+ const msg = new TextEncoder().encode("hello");
+ const n = await p.stdin.write(msg);
assertEquals(n, msg.byteLength);
p.stdin.close();
@@ -307,7 +307,7 @@ testPerm({ run: true }, async function runClose(): Promise<void> {
p.close();
const data = new Uint8Array(10);
- let r = await p.stderr.read(data);
+ const r = await p.stderr.read(data);
assertEquals(r, Deno.EOF);
});
diff --git a/js/request.ts b/js/request.ts
index f7a3cdfc1..0c77b8854 100644
--- a/js/request.ts
+++ b/js/request.ts
@@ -138,7 +138,7 @@ export class Request extends body.Body implements domTypes.Request {
headersList.push(header);
}
- let body2 = this._bodySource;
+ const body2 = this._bodySource;
const cloned = new Request(this.url, {
body: body2,
diff --git a/js/text_encoding.ts b/js/text_encoding.ts
index 5aed7ac07..a956cd52c 100644
--- a/js/text_encoding.ts
+++ b/js/text_encoding.ts
@@ -481,7 +481,7 @@ export class TextEncoder {
break;
}
if (Array.isArray(result)) {
- output.push.apply(output, result);
+ output.push(...result);
} else {
output.push(result);
}
diff --git a/js/text_encoding_test.ts b/js/text_encoding_test.ts
index 7633e105a..727424749 100644
--- a/js/text_encoding_test.ts
+++ b/js/text_encoding_test.ts
@@ -24,8 +24,8 @@ test(function atobWithAsciiWhitespace(): void {
d29ybGQ=`
];
- for (let encoded of encodedList) {
- let decoded = atob(encoded);
+ for (const encoded of encodedList) {
+ const decoded = atob(encoded);
assertEquals(decoded, "hello world");
}
});
diff --git a/js/timers.ts b/js/timers.ts
index 8aec33d92..ff8df9a6b 100644
--- a/js/timers.ts
+++ b/js/timers.ts
@@ -48,7 +48,7 @@ async function setGlobalTimeout(due: number, now: number): Promise<void> {
// Since JS and Rust don't use the same clock, pass the time to rust as a
// relative time value. On the Rust side we'll turn that into an absolute
// value again.
- let timeout = due - now;
+ const timeout = due - now;
assert(timeout >= 0);
// Send message to the backend.
@@ -229,7 +229,7 @@ function setTimer(
/** Sets a timer which executes a function once after the timer expires. */
export function setTimeout(
cb: (...args: Args) => void,
- delay: number = 0,
+ delay = 0,
...args: Args
): number {
checkBigInt(delay);
@@ -241,7 +241,7 @@ export function setTimeout(
/** Repeatedly calls a function , with a fixed time delay between each call. */
export function setInterval(
cb: (...args: Args) => void,
- delay: number = 0,
+ delay = 0,
...args: Args
): number {
checkBigInt(delay);
@@ -263,7 +263,7 @@ function clearTimer(id: number): void {
idMap.delete(timer.id);
}
-export function clearTimeout(id: number = 0): void {
+export function clearTimeout(id = 0): void {
checkBigInt(id);
if (id === 0) {
return;
@@ -271,7 +271,7 @@ export function clearTimeout(id: number = 0): void {
clearTimer(id);
}
-export function clearInterval(id: number = 0): void {
+export function clearInterval(id = 0): void {
checkBigInt(id);
if (id === 0) {
return;
diff --git a/js/workers.ts b/js/workers.ts
index 36c2aa50b..8d42f3585 100644
--- a/js/workers.ts
+++ b/js/workers.ts
@@ -55,7 +55,7 @@ async function hostGetMessage(rid: number): Promise<any> {
}
// Stuff for workers
-export let onmessage: (e: { data: any }) => void = (): void => {};
+export const onmessage: (e: { data: any }) => void = (): void => {};
export function postMessage(data: any): void {
const dataIntArray = encodeMessage(data);
@@ -122,7 +122,7 @@ export interface DenoWorkerOptions extends WorkerOptions {
export class WorkerImpl implements Worker {
private readonly rid: number;
- private isClosing: boolean = false;
+ private isClosing = false;
private readonly isClosedPromise: Promise<void>;
public onerror?: () => void;
public onmessage?: (data: any) => void;
diff --git a/js/xeval.ts b/js/xeval.ts
index cf5a33727..29adcbcaf 100644
--- a/js/xeval.ts
+++ b/js/xeval.ts
@@ -48,7 +48,7 @@ async function* chunks(
let inspectIndex = 0;
let matchIndex = 0;
while (true) {
- let result = await reader.read(inspectArr);
+ const result = await reader.read(inspectArr);
if (result === EOF) {
// Yield last chunk.
const lastChunk = inputBuffer.toString();
@@ -59,7 +59,7 @@ async function* chunks(
// Discard all remaining and silently fail.
return;
}
- let sliceRead = inspectArr.subarray(0, result as number);
+ const sliceRead = inspectArr.subarray(0, result as number);
await writeAll(inputBuffer, sliceRead);
let sliceToProcess = inputBuffer.bytes();