Skip to content

Commit

Permalink
Fix VSCode reported lint issues (ethers-io#4153, ethers-io#4156, ethe…
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo authored and Woodpile37 committed Jan 14, 2024
1 parent 9d948cf commit 3b46bd4
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src.ts/_admin/test-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const TestData = (function() {
return [ String(data.length), zlib.deflateRawSync(data).toString("base64") ].join(",");
}

let data = [ ];
let data: Array<string> = [ ];
data.push(`import { ethers } from "/index.js";`);
data.push(`import { inflate } from "/static/tiny-inflate.js";`);
data.push(`const fs = new Map();`);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/_tests/test-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe("Test Typed Contract Interaction", function() {
}
];

const abi = [ ];
const abi: Array<string> = [ ];
for (let i = 1; i <= 32; i++) {
abi.push(`function testTyped(uint${ i * 8 }) public pure returns (string memory)`);
abi.push(`function testTyped(int${ i * 8 }) public pure returns (string memory)`);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/_tests/test-wallet-mnemonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function fromHex(hex: string): string {
}

function repeat(text: string, length: number): Array<string> {
const result = [ ];
const result: Array<string> = [ ];
while (result.length < length) { result.push(text); }
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src.ts/abi/coders/abstract-coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class Result extends Array<any> {
}
if (end > this.length) { end = this.length; }

const result = [ ], names = [ ];
const result: Array<any> = [ ], names: Array<null | string> = [ ];
for (let i = start; i < end; i++) {
result.push(this[i]);
names.push(this.#names[i]);
Expand All @@ -195,7 +195,7 @@ export class Result extends Array<any> {
* @_ignore
*/
filter(callback: (el: any, index: number, array: Result) => boolean, thisArg?: any): Result {
const result = [ ], names = [ ];
const result: Array<any> = [ ], names: Array<null | string> = [ ];
for (let i = 0; i < this.length; i++) {
const item = this[i];
if (item instanceof Error) {
Expand Down
4 changes: 2 additions & 2 deletions src.ts/abi/coders/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class ArrayCoder extends Coder {

assertArgumentCount(value.length, count, "coder array" + (this.localName? (" "+ this.localName): ""));

let coders = [];
let coders: Array<Coder> = [ ];
for (let i = 0; i < value.length; i++) { coders.push(this.coder); }

return pack(writer, coders, value);
Expand All @@ -190,7 +190,7 @@ export class ArrayCoder extends Coder {
assert(count * WordSize <= reader.dataLength, "insufficient data length",
"BUFFER_OVERRUN", { buffer: reader.bytes, offset: count * WordSize, length: reader.dataLength });
}
let coders = [];
let coders: Array<Coder> = [];
for (let i = 0; i < count; i++) { coders.push(new AnonymousCoder(this.coder)); }

return unpack(reader, coders);
Expand Down
8 changes: 4 additions & 4 deletions src.ts/abi/fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ export class ParamType {
comps = null;
}

let indexed = null;
let indexed: null | boolean = null;
const keywords = consumeKeywords(obj, KwModifiers);
if (keywords.has("indexed")) {
if (!allowIndexed) { throw new Error(""); }
Expand Down Expand Up @@ -1079,7 +1079,7 @@ export class ErrorFragment extends NamedFragment {
});
}

const result = [ ];
const result: Array<string> = [ ];
if (format !== "sighash") { result.push("error"); }
result.push(this.name + joinParams(format, this.inputs));
return result.join(" ");
Expand Down Expand Up @@ -1154,7 +1154,7 @@ export class EventFragment extends NamedFragment {
});
}

const result = [ ];
const result: Array<string> = [ ];
if (format !== "sighash") { result.push("event"); }
result.push(this.name + joinParams(format, this.inputs));
if (format !== "sighash" && this.anonymous) { result.push("anonymous"); }
Expand Down Expand Up @@ -1465,7 +1465,7 @@ export class FunctionFragment extends NamedFragment {
});
}

const result = [];
const result: Array<string> = [];

if (format !== "sighash") { result.push("function"); }

Expand Down
6 changes: 3 additions & 3 deletions src.ts/abi/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ export class Interface {

// It is a bare name, look up the function (will return null if ambiguous)
if (key.indexOf("(") === -1) {
const matching = [ ];
const matching: Array<EventFragment> = [ ];
for (const [ name, fragment ] of this.#events) {
if (name.split("("/* fix:) */)[0] === key) { matching.push(fragment); }
}
Expand Down Expand Up @@ -716,7 +716,7 @@ export class Interface {

// It is a bare name, look up the function (will return null if ambiguous)
if (key.indexOf("(") === -1) {
const matching = [ ];
const matching: Array<ErrorFragment> = [ ];
for (const [ name, fragment ] of this.#errors) {
if (name.split("("/* fix:) */)[0] === key) { matching.push(fragment); }
}
Expand Down Expand Up @@ -1154,7 +1154,7 @@ export class Interface {
const keys: Array<null | string> = [ ];
let nonIndexedIndex = 0, indexedIndex = 0;
fragment.inputs.forEach((param, index) => {
let value = null;
let value: null | Indexed = null;
if (param.indexed) {
if (resultIndexed == null) {
value = new Indexed(null);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/contract/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ export class BaseContract implements Addressable, EventEmitterable<ContractEvent
Object.defineProperty(this, internal, { value: { } });

let addrPromise;
let addr = null;
let addr: null | string = null;

let deployTx: null | ContractTransactionResponse = null;
if (_deployTx) {
Expand Down
3 changes: 2 additions & 1 deletion src.ts/providers/abstract-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@ export class AbstractProvider implements Provider {
})())
});

let maxFeePerGas = null, maxPriorityFeePerGas = null;
let maxFeePerGas: null | bigint = null;
let maxPriorityFeePerGas: null | bigint = null;

// These are the recommended EIP-1559 heuristics for fee data
const block = this._wrapBlock(_block, network);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/providers/provider-fallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function getFuzzyMode(quorum: number, results: Array<TallyResult>): undefined |
}

let bestWeight = 0;
let bestResult = undefined;
let bestResult: undefined | number = undefined;

for (const { weight, result } of tally.values()) {
// Use this result, if this result meets quorum and has either:
Expand Down
2 changes: 1 addition & 1 deletion src.ts/utils/rlp-decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Decoded = {
};

function _decodeChildren(data: Uint8Array, offset: number, childOffset: number, length: number): Decoded {
const result = [];
const result: Array<any> = [];

while (childOffset < offset + 1 + length) {
const decoded = _decode(data, childOffset);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/utils/rlp-encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { RlpStructuredData } from "./rlp.js";


function arrayifyInteger(value: number): Array<number> {
const result = [];
const result: Array<number> = [];
while (value) {
result.unshift(value & 0xff);
value >>= 8;
Expand Down
6 changes: 3 additions & 3 deletions src.ts/utils/utf8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ function getUtf8CodePoints(_bytes: BytesLike, onError?: Utf8ErrorFunc): Array<nu
}

// Multibyte; how many bytes left for this character?
let extraLength = null;
let overlongMask = null;
let extraLength: null | number = null;
let overlongMask: null | number = null;

// 110x xxxx 10xx xxxx
if ((c & 0xe0) === 0xc0) {
Expand Down Expand Up @@ -253,7 +253,7 @@ export function toUtf8Bytes(str: string, form?: UnicodeNormalizationForm): Uint8
str = str.normalize(form);
}

let result = [];
let result: Array<number> = [];
for (let i = 0; i < str.length; i++) {
const c = str.charCodeAt(i);

Expand Down
4 changes: 2 additions & 2 deletions src.ts/wordlists/lang-ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function toString(data: Array<number>): string {
function loadWords(): Array<string> {
if (_wordlist !== null) { return _wordlist; }

const wordlist = [];
const wordlist: Array<string> = [];

// Transforms for normalizing (sort is a not quite UTF-8)
const transform: { [key: string]: string | boolean } = {};
Expand Down Expand Up @@ -91,7 +91,7 @@ function loadWords(): Array<string> {
for (let length = 3; length <= 9; length++) {
const d = data[length - 3];
for (let offset = 0; offset < d.length; offset += length) {
const word = [];
const word: Array<number> = [];
for (let i = 0; i < length; i++) {
const k = mapping.indexOf(d[offset + i]);
word.push(227);
Expand Down
2 changes: 1 addition & 1 deletion src.ts/wordlists/lang-zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const style = "~!@#$%^&*_-=[]{}|;:,.()<>?"
function loadWords(locale: string): Array<string> {
if (_wordlist[locale] != null) { return _wordlist[locale] as Array<string>; }

const wordlist = [];
const wordlist: Array<string> = [];

let deltaOffset = 0;
for (let i = 0; i < 2048; i++) {
Expand Down

0 comments on commit 3b46bd4

Please sign in to comment.