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

Update @typescript-eslint/* to v2.1.0 #2878

Merged
merged 3 commits into from
Sep 7, 2019
Merged
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
23 changes: 19 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
"project": "./tsconfig.json",
"createDefaultProgram": true
},
"plugins": ["@typescript-eslint"],
"extends": [
Expand All @@ -11,14 +12,28 @@
"prettier/@typescript-eslint"
],
"rules": {
"@typescript-eslint/array-type": ["error", "array-simple"],
"@typescript-eslint/array-type": [
"error",
{ "default": "array-simple" }
],
"@typescript-eslint/explicit-member-accessibility": ["off"],
"@typescript-eslint/no-non-null-assertion": ["off"],
"@typescript-eslint/no-use-before-define": ["off"],
"@typescript-eslint/no-parameter-properties": ["off"],
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
]
}
],
"@typescript-eslint/ban-ts-ignore": ["off"],
"@typescript-eslint/no-empty-function": ["off"],
"@typescript-eslint/explicit-function-return-type": ["off"]
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-function-return-type": ["error"]
}
}
]
}
1 change: 1 addition & 0 deletions core/libdeno/libdeno_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// A simple runtime that doesn't involve typescript or protobufs to test
// libdeno. Invoked by libdeno_test.cc

// eslint-disable-next-line @typescript-eslint/no-this-alias
const global = this;

function assert(cond) {
Expand Down
12 changes: 6 additions & 6 deletions core/shared_queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SharedQueue Binary Layout
}

function init() {
let shared = Deno.core.shared;
const shared = Deno.core.shared;
assert(shared.byteLength > 0);
assert(sharedBytes == null);
assert(shared32 == null);
Expand Down Expand Up @@ -113,9 +113,9 @@ SharedQueue Binary Layout
}

function push(opId, buf) {
let off = head();
let end = off + buf.byteLength;
let index = numRecords();
const off = head();
const end = off + buf.byteLength;
const index = numRecords();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice - I guess this wasn't being checked before?

if (end > shared32.byteLength || index >= MAX_RECORDS) {
// console.log("shared_queue.js push fail");
return false;
Expand All @@ -130,7 +130,7 @@ SharedQueue Binary Layout

/// Returns null if empty.
function shift() {
let i = shared32[INDEX_NUM_SHIFTED_OFF];
const i = shared32[INDEX_NUM_SHIFTED_OFF];
if (size() == 0) {
assert(i == 0);
return null;
Expand Down Expand Up @@ -164,7 +164,7 @@ SharedQueue Binary Layout
asyncHandler(opId, buf);
} else {
while (true) {
let opIdBuf = shift();
const opIdBuf = shift();
if (opIdBuf == null) {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions core/shared_queue_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ function fullRecords(q) {
function main() {
const q = Deno.core.sharedQueue;

let h = q.head();
const h = q.head();
assert(h > 0);

let r = new Uint8Array([1, 2, 3, 4, 5]);
let len = r.byteLength + h;
const len = r.byteLength + h;
assert(q.push(99, r));
assert(q.head() == len);

Expand Down
49 changes: 25 additions & 24 deletions js/base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -16,27 +16,27 @@ 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");
}

// 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;
}

Expand All @@ -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) |
Expand Down Expand Up @@ -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) +
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions js/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion js/blob_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
12 changes: 6 additions & 6 deletions js/buffer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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, "");

Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion js/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Code {
regexp: RegExp;
}

let enabled = !noColor;
const enabled = !noColor;

function code(open: number, close: number): Code {
return {
Expand Down
4 changes: 2 additions & 2 deletions js/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions js/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ const isConsoleInstance = Symbol("isConsoleInstance");

export class Console {
indentLevel: number;
[isConsoleInstance]: boolean = false;
[isConsoleInstance] = false;

/** @internal */
constructor(private printFunc: PrintFunc) {
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion js/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion js/dom_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion js/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion js/files_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
2 changes: 1 addition & 1 deletion js/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion js/permissions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading