diff --git a/archive/tar.ts b/archive/tar.ts index 2680bcff25f2..cafef8723a4c 100644 --- a/archive/tar.ts +++ b/archive/tar.ts @@ -104,68 +104,68 @@ struct posix_header { // byte offset const ustarStructure: Array<{ field: string; length: number }> = [ { field: "fileName", - length: 100 + length: 100, }, { field: "fileMode", - length: 8 + length: 8, }, { field: "uid", - length: 8 + length: 8, }, { field: "gid", - length: 8 + length: 8, }, { field: "fileSize", - length: 12 + length: 12, }, { field: "mtime", - length: 12 + length: 12, }, { field: "checksum", - length: 8 + length: 8, }, { field: "type", - length: 1 + length: 1, }, { field: "linkName", - length: 100 + length: 100, }, { field: "ustar", - length: 8 + length: 8, }, { field: "owner", - length: 32 + length: 32, }, { field: "group", - length: 32 + length: 32, }, { field: "majorNumber", - length: 8 + length: 8, }, { field: "minorNumber", - length: 8 + length: 8, }, { field: "fileNamePrefix", - length: 155 + length: 155, }, { field: "padding", - length: 12 - } + length: 12, + }, ]; /** @@ -175,7 +175,7 @@ function formatHeader(data: TarData): Uint8Array { const encoder = new TextEncoder(), buffer = clean(512); let offset = 0; - ustarStructure.forEach(function(value): void { + ustarStructure.forEach(function (value): void { const entry = encoder.encode(data[value.field as keyof TarData] || ""); buffer.set(entry, offset); offset += value.length; // space it out with nulls @@ -190,7 +190,7 @@ function formatHeader(data: TarData): Uint8Array { function parseHeader(buffer: Uint8Array): { [key: string]: Uint8Array } { const data: { [key: string]: Uint8Array } = {}; let offset = 0; - ustarStructure.forEach(function(value): void { + ustarStructure.forEach(function (value): void { const arr = buffer.subarray(offset, offset + value.length); data[value.field] = arr; offset += value.length; @@ -350,7 +350,7 @@ export class Tar { owner: opts.owner || "", group: opts.group || "", filePath: opts.filePath, - reader: opts.reader + reader: opts.reader, }; // calculate the checksum @@ -358,7 +358,7 @@ export class Tar { const encoder = new TextEncoder(); Object.keys(tarData) .filter((key): boolean => ["filePath", "reader"].indexOf(key) < 0) - .forEach(function(key): void { + .forEach(function (key): void { checksum += encoder .encode(tarData[key as keyof TarData]) .reduce((p, c): number => p + c, 0); @@ -424,7 +424,7 @@ export class Untar { decoder = new TextDecoder("ascii"); Object.keys(header) .filter((key): boolean => key !== "checksum") - .forEach(function(key): void { + .forEach(function (key): void { checksum += header[key].reduce((p, c): number => p + c, 0); }); checksum += encoder.encode(" ").reduce((p, c): number => p + c, 0); @@ -440,7 +440,7 @@ export class Untar { // get meta data const meta: UntarOptions = { - fileName: decoder.decode(trim(header.fileName)) + fileName: decoder.decode(trim(header.fileName)), }; const fileNamePrefix = trim(header.fileNamePrefix); if (fileNamePrefix.byteLength > 0) { diff --git a/archive/tar_test.ts b/archive/tar_test.ts index 1bac623b0978..ae3ee8138c0b 100644 --- a/archive/tar_test.ts +++ b/archive/tar_test.ts @@ -23,7 +23,7 @@ Deno.test(async function createTarArchive(): Promise { const content = new TextEncoder().encode("hello tar world!"); await tar.append("output.txt", { reader: new Deno.Buffer(content), - contentSize: content.byteLength + contentSize: content.byteLength, }); // put a file @@ -49,7 +49,7 @@ Deno.test(async function deflateTarArchive(): Promise { const content = new TextEncoder().encode(text); await tar.append(fileName, { reader: new Deno.Buffer(content), - contentSize: content.byteLength + contentSize: content.byteLength, }); // read data from a tar archive @@ -73,7 +73,7 @@ Deno.test(async function appendFileWithLongNameToTarArchive(): Promise { const content = new TextEncoder().encode(text); await tar.append(fileName, { reader: new Deno.Buffer(content), - contentSize: content.byteLength + contentSize: content.byteLength, }); // read data from a tar archive diff --git a/bytes/test.ts b/bytes/test.ts index 3ded0cd85e4e..5efddf77f966 100644 --- a/bytes/test.ts +++ b/bytes/test.ts @@ -6,7 +6,7 @@ import { equal, hasPrefix, repeat, - concat + concat, } from "./mod.ts"; import { assertEquals, assertThrows, assert } from "../testing/asserts.ts"; import { encode, decode } from "../strings/mod.ts"; @@ -58,7 +58,7 @@ Deno.test("[bytes] repeat", () => { ["-", "", 0], ["-", "-", -1, "bytes: negative repeat count"], ["-", "----------", 10], - ["abc ", "abc abc abc ", 3] + ["abc ", "abc abc abc ", 3], ]; for (const [input, output, count, errMsg] of repeatTestCase) { if (errMsg) { diff --git a/datetime/README.md b/datetime/README.md index e3d935bc0d35..6c29f65e49ac 100644 --- a/datetime/README.md +++ b/datetime/README.md @@ -31,7 +31,7 @@ parseDateTime("16:34 01-20-2019", "hh:mm mm-dd-yyyy") // output : new Date(2019, ```ts import { dayOfYear, - currentDayOfYear + currentDayOfYear, } from "https://deno.land/std/datetime/mod.ts"; dayOfYear(new Date("2019-03-11T03:24:00")); // output: 70 diff --git a/datetime/mod.ts b/datetime/mod.ts index 124f7391169d..036cd2cc5524 100644 --- a/datetime/mod.ts +++ b/datetime/mod.ts @@ -145,7 +145,7 @@ export function toIMF(date: Date): string { "Sep", "Oct", "Nov", - "Dec" + "Dec", ]; return `${days[date.getUTCDay()]}, ${d} ${ months[date.getUTCMonth()] diff --git a/datetime/test.ts b/datetime/test.ts index 979fd34bec01..dc93095f41b7 100644 --- a/datetime/test.ts +++ b/datetime/test.ts @@ -82,7 +82,7 @@ Deno.test({ const actual = datetime.toIMF(new Date(Date.UTC(1994, 3, 5, 15, 32))); const expected = "Tue, 05 Apr 1994 15:32:00 GMT"; assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -91,5 +91,5 @@ Deno.test({ const actual = datetime.toIMF(new Date(0)); const expected = "Thu, 01 Jan 1970 00:00:00 GMT"; assertEquals(actual, expected); - } + }, }); diff --git a/encoding/README.md b/encoding/README.md index 2b2d416b19e5..e6604c605035 100644 --- a/encoding/README.md +++ b/encoding/README.md @@ -39,7 +39,7 @@ const string = "a,b,c\nd,e,f"; console.log( await parseCsv(string, { - header: false + header: false, }) ); // output: @@ -161,9 +161,9 @@ import { stringify } from "./parser.ts"; const obj = { bin: [ { name: "deno", path: "cli/main.rs" }, - { name: "deno_core", path: "src/foo.rs" } + { name: "deno_core", path: "src/foo.rs" }, ], - nib: [{ name: "node", path: "not_found" }] + nib: [{ name: "node", path: "not_found" }], }; const tomlString = stringify(obj); ``` diff --git a/encoding/base32_test.ts b/encoding/base32_test.ts index 28550d57a523..2bd7acea1fb6 100644 --- a/encoding/base32_test.ts +++ b/encoding/base32_test.ts @@ -6,7 +6,7 @@ import { encode, decode } from "./base32.ts"; // Lifted from https://stackoverflow.com/questions/38987784 const fromHexString = (hexString: string): Uint8Array => - new Uint8Array(hexString.match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))); + new Uint8Array(hexString.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16))); const toHexString = (bytes: Uint8Array): string => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), ""); @@ -34,56 +34,56 @@ const testCases = [ ["ddf80ebe21bf1b1e12a64c5cc6a74b5d92dd", "3X4A5PRBX4NR4EVGJROMNJ2LLWJN2==="], [ "c0cae52c6f641ce04a7ee5b9a8fa8ded121bca", - "YDFOKLDPMQOOAST64W42R6UN5UJBXSQ=" + "YDFOKLDPMQOOAST64W42R6UN5UJBXSQ=", ], [ "872840a355c8c70586f462c9e669ee760cb3537e", - "Q4UEBI2VZDDQLBXUMLE6M2POOYGLGU36" + "Q4UEBI2VZDDQLBXUMLE6M2POOYGLGU36", ], [ "5773fe22662818a120c5688824c935fe018208a496", - "K5Z74ITGFAMKCIGFNCECJSJV7YAYECFESY======" + "K5Z74ITGFAMKCIGFNCECJSJV7YAYECFESY======", ], [ "416e23abc524d1b85736e2bea6cfecd5192789034a28", - "IFXCHK6FETI3QVZW4K7KNT7M2UMSPCIDJIUA====" + "IFXCHK6FETI3QVZW4K7KNT7M2UMSPCIDJIUA====", ], [ "83d2386ebdd7e8e818ec00e3ccd882aa933b905b7e2e44", - "QPJDQ3V527UOQGHMADR4ZWECVKJTXEC3PYXEI===" + "QPJDQ3V527UOQGHMADR4ZWECVKJTXEC3PYXEI===", ], [ "a2fa8b881f3b8024f52745763c4ae08ea12bdf8bef1a72f8", - "UL5IXCA7HOACJ5JHIV3DYSXAR2QSXX4L54NHF6A=" + "UL5IXCA7HOACJ5JHIV3DYSXAR2QSXX4L54NHF6A=", ], [ "b074ae8b9efde0f17f37bccadde006d039997b59c8efb05add", - "WB2K5C467XQPC7ZXXTFN3YAG2A4ZS62ZZDX3AWW5" + "WB2K5C467XQPC7ZXXTFN3YAG2A4ZS62ZZDX3AWW5", ], [ "764fef941aee7e416dc204ae5ab9c5b9ce644567798e6849aea9", - "OZH67FA25Z7EC3OCASXFVOOFXHHGIRLHPGHGQSNOVE======" + "OZH67FA25Z7EC3OCASXFVOOFXHHGIRLHPGHGQSNOVE======", ], [ "4995d9811f37f59797d7c3b9b9e5325aa78277415f70f4accf588c", - "JGK5TAI7G72ZPF6XYO43TZJSLKTYE52BL5YPJLGPLCGA====" + "JGK5TAI7G72ZPF6XYO43TZJSLKTYE52BL5YPJLGPLCGA====", ], [ "24f0812ca8eed58374c11a7008f0b262698b72fd2792709208eaacb2", - "ETYICLFI53KYG5GBDJYAR4FSMJUYW4X5E6JHBEQI5KWLE===" + "ETYICLFI53KYG5GBDJYAR4FSMJUYW4X5E6JHBEQI5KWLE===", ], [ "d70692543810d4bf50d81cf44a55801a557a388a341367c7ea077ca306", - "24DJEVBYCDKL6UGYDT2EUVMADJKXUOEKGQJWPR7KA56KGBQ=" + "24DJEVBYCDKL6UGYDT2EUVMADJKXUOEKGQJWPR7KA56KGBQ=", ], [ "6e08a89ca36b677ff8fe99e68a1241c8d8cef2570a5f60b6417d2538b30c", - "NYEKRHFDNNTX76H6THTIUESBZDMM54SXBJPWBNSBPUSTRMYM" + "NYEKRHFDNNTX76H6THTIUESBZDMM54SXBJPWBNSBPUSTRMYM", ], [ "f2fc2319bd29457ccd01e8e194ee9bd7e97298b6610df4ab0f3d5baa0b2d7ccf69829edb74edef", - "6L6CGGN5FFCXZTIB5DQZJ3U327UXFGFWMEG7JKYPHVN2UCZNPTHWTAU63N2O33Y=" - ] + "6L6CGGN5FFCXZTIB5DQZJ3U327UXFGFWMEG7JKYPHVN2UCZNPTHWTAU63N2O33Y=", + ], ]; Deno.test({ @@ -92,7 +92,7 @@ Deno.test({ for (const [bin, b32] of testCases) { assertEquals(encode(fromHexString(bin)), b32); } - } + }, }); Deno.test({ @@ -101,7 +101,7 @@ Deno.test({ for (const [bin, b32] of testCases) { assertEquals(toHexString(decode(b32)), bin); } - } + }, }); Deno.test({ @@ -117,7 +117,7 @@ Deno.test({ errorCaught = true; } assert(errorCaught); - } + }, }); Deno.test({ @@ -131,5 +131,5 @@ Deno.test({ errorCaught = true; } assert(errorCaught); - } + }, }); diff --git a/encoding/binary.ts b/encoding/binary.ts index 2eec9b4ab467..cd338703b109 100644 --- a/encoding/binary.ts +++ b/encoding/binary.ts @@ -34,7 +34,7 @@ const rawTypeSizes = { int64: 8, uint64: 8, float32: 4, - float64: 8 + float64: 8, }; /** Returns the number of bytes required to store the given data-type. */ diff --git a/encoding/binary_test.ts b/encoding/binary_test.ts index 54f8cbded5f3..084ca2fa49b9 100644 --- a/encoding/binary_test.ts +++ b/encoding/binary_test.ts @@ -11,7 +11,7 @@ import { varbig, varnum, writeVarbig, - writeVarnum + writeVarnum, } from "./binary.ts"; Deno.test(async function testGetNBytes(): Promise { diff --git a/encoding/csv.ts b/encoding/csv.ts index 12336b10ddcc..c8c7719cab56 100644 --- a/encoding/csv.ts +++ b/encoding/csv.ts @@ -118,7 +118,7 @@ export async function readMatrix( opt: ReadOptions = { comma: ",", trimLeadingSpace: false, - lazyQuotes: false + lazyQuotes: false, } ): Promise { const result: string[][] = []; @@ -195,7 +195,7 @@ export interface ParseOptions extends ReadOptions { export async function parse( input: string | BufReader, opt: ParseOptions = { - header: false + header: false, } ): Promise { let r: string[][]; @@ -215,7 +215,7 @@ export async function parse( headers = h.map( (e): HeaderOptions => { return { - name: e + name: e, }; } ); @@ -226,7 +226,7 @@ export async function parse( headers = head.map( (e): HeaderOptions => { return { - name: e + name: e, }; } ); diff --git a/encoding/csv_test.ts b/encoding/csv_test.ts index 74ad00c72ce7..cb61de433940 100644 --- a/encoding/csv_test.ts +++ b/encoding/csv_test.ts @@ -14,20 +14,20 @@ const testCases = [ { Name: "Simple", Input: "a,b,c\n", - Output: [["a", "b", "c"]] + Output: [["a", "b", "c"]], }, { Name: "CRLF", Input: "a,b\r\nc,d\r\n", Output: [ ["a", "b"], - ["c", "d"] - ] + ["c", "d"], + ], }, { Name: "BareCR", Input: "a,b\rc,d\r\n", - Output: [["a", "b\rc", "d"]] + Output: [["a", "b\rc", "d"]], }, { Name: "RFC4180test", @@ -41,20 +41,20 @@ zzz,yyy,xxx`, ["#field1", "field2", "field3"], ["aaa", "bbb", "ccc"], ["a,a", `bbb`, "ccc"], - ["zzz", "yyy", "xxx"] + ["zzz", "yyy", "xxx"], ], - ignore: true + ignore: true, }, { Name: "NoEOLTest", Input: "a,b,c", - Output: [["a", "b", "c"]] + Output: [["a", "b", "c"]], }, { Name: "Semicolon", Input: "a;b;c\n", Output: [["a", "b", "c"]], - Comma: ";" + Comma: ";", }, { Name: "MultiLine", @@ -63,103 +63,103 @@ line","one line","three line field"`, Output: [["two\nline"], ["one line"], ["three\nline\nfield"]], - ignore: true + ignore: true, }, { Name: "BlankLine", Input: "a,b,c\n\nd,e,f\n\n", Output: [ ["a", "b", "c"], - ["d", "e", "f"] - ] + ["d", "e", "f"], + ], }, { Name: "BlankLineFieldCount", Input: "a,b,c\n\nd,e,f\n\n", Output: [ ["a", "b", "c"], - ["d", "e", "f"] + ["d", "e", "f"], ], UseFieldsPerRecord: true, - FieldsPerRecord: 0 + FieldsPerRecord: 0, }, { Name: "TrimSpace", Input: " a, b, c\n", Output: [["a", "b", "c"]], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "LeadingSpace", Input: " a, b, c\n", - Output: [[" a", " b", " c"]] + Output: [[" a", " b", " c"]], }, { Name: "Comment", Input: "#1,2,3\na,b,c\n#comment", Output: [["a", "b", "c"]], - Comment: "#" + Comment: "#", }, { Name: "NoComment", Input: "#1,2,3\na,b,c", Output: [ ["#1", "2", "3"], - ["a", "b", "c"] - ] + ["a", "b", "c"], + ], }, { Name: "LazyQuotes", Input: `a "word","1"2",a","b`, Output: [[`a "word"`, `1"2`, `a"`, `b`]], - LazyQuotes: true + LazyQuotes: true, }, { Name: "BareQuotes", Input: `a "word","1"2",a"`, Output: [[`a "word"`, `1"2`, `a"`]], - LazyQuotes: true + LazyQuotes: true, }, { Name: "BareDoubleQuotes", Input: `a""b,c`, Output: [[`a""b`, `c`]], - LazyQuotes: true + LazyQuotes: true, }, { Name: "BadDoubleQuotes", Input: `a""b,c`, - Error: ErrBareQuote + Error: ErrBareQuote, // Error: &ParseError{StartLine: 1, Line: 1, Column: 1, Err: ErrBareQuote}, }, { Name: "TrimQuote", Input: ` "a"," b",c`, Output: [["a", " b", "c"]], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "BadBareQuote", Input: `a "word","b"`, - Error: ErrBareQuote + Error: ErrBareQuote, // &ParseError{StartLine: 1, Line: 1, Column: 2, Err: ErrBareQuote} }, { Name: "BadTrailingQuote", Input: `"a word",b"`, - Error: ErrBareQuote + Error: ErrBareQuote, }, { Name: "ExtraneousQuote", Input: `"a "word","b"`, - Error: ErrBareQuote + Error: ErrBareQuote, }, { Name: "BadFieldCount", Input: "a,b,c\nd,e", Error: ErrFieldCount, UseFieldsPerRecord: true, - FieldsPerRecord: 0 + FieldsPerRecord: 0, }, { Name: "BadFieldCount1", @@ -167,37 +167,37 @@ field"`, // Error: &ParseError{StartLine: 1, Line: 1, Err: ErrFieldCount}, UseFieldsPerRecord: true, FieldsPerRecord: 2, - Error: ErrFieldCount + Error: ErrFieldCount, }, { Name: "FieldCount", Input: "a,b,c\nd,e", Output: [ ["a", "b", "c"], - ["d", "e"] - ] + ["d", "e"], + ], }, { Name: "TrailingCommaEOF", Input: "a,b,c,", - Output: [["a", "b", "c", ""]] + Output: [["a", "b", "c", ""]], }, { Name: "TrailingCommaEOL", Input: "a,b,c,\n", - Output: [["a", "b", "c", ""]] + Output: [["a", "b", "c", ""]], }, { Name: "TrailingCommaSpaceEOF", Input: "a,b,c, ", Output: [["a", "b", "c", ""]], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "TrailingCommaSpaceEOL", Input: "a,b,c, \n", Output: [["a", "b", "c", ""]], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "TrailingCommaLine3", @@ -205,14 +205,14 @@ field"`, Output: [ ["a", "b", "c"], ["d", "e", "f"], - ["g", "hi", ""] + ["g", "hi", ""], ], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "NotTrailingComma3", Input: "a,b,c, \n", - Output: [["a", "b", "c", " "]] + Output: [["a", "b", "c", " "]], }, { Name: "CommaFieldTest", @@ -237,98 +237,98 @@ x,,, ["x", "y", "z", ""], ["x", "y", "", ""], ["x", "", "", ""], - ["", "", "", ""] - ] + ["", "", "", ""], + ], }, { Name: "TrailingCommaIneffective1", Input: "a,b,\nc,d,e", Output: [ ["a", "b", ""], - ["c", "d", "e"] + ["c", "d", "e"], ], - TrimLeadingSpace: true + TrimLeadingSpace: true, }, { Name: "ReadAllReuseRecord", Input: "a,b\nc,d", Output: [ ["a", "b"], - ["c", "d"] + ["c", "d"], ], - ReuseRecord: true + ReuseRecord: true, }, { Name: "StartLine1", // Issue 19019 Input: 'a,"b\nc"d,e', Error: true, // Error: &ParseError{StartLine: 1, Line: 2, Column: 1, Err: ErrQuote}, - ignore: true + ignore: true, }, { Name: "StartLine2", Input: 'a,b\n"d\n\n,e', Error: true, // Error: &ParseError{StartLine: 2, Line: 5, Column: 0, Err: ErrQuote}, - ignore: true + ignore: true, }, { Name: "CRLFInQuotedField", // Issue 21201 Input: 'A,"Hello\r\nHi",B\r\n', Output: [["A", "Hello\nHi", "B"]], - ignore: true + ignore: true, }, { Name: "BinaryBlobField", // Issue 19410 Input: "x09\x41\xb4\x1c,aktau", - Output: [["x09A\xb4\x1c", "aktau"]] + Output: [["x09A\xb4\x1c", "aktau"]], }, { Name: "TrailingCR", Input: "field1,field2\r", Output: [["field1", "field2"]], - ignore: true + ignore: true, }, { Name: "QuotedTrailingCR", Input: '"field"\r', Output: [['"field"']], - ignore: true + ignore: true, }, { Name: "QuotedTrailingCRCR", Input: '"field"\r\r', Error: true, // Error: &ParseError{StartLine: 1, Line: 1, Column: 6, Err: ErrQuote}, - ignore: true + ignore: true, }, { Name: "FieldCR", Input: "field\rfield\r", Output: [["field\rfield"]], - ignore: true + ignore: true, }, { Name: "FieldCRCR", Input: "field\r\rfield\r\r", Output: [["field\r\rfield\r"]], - ignore: true + ignore: true, }, { Name: "FieldCRCRLF", Input: "field\r\r\nfield\r\r\n", - Output: [["field\r"], ["field\r"]] + Output: [["field\r"], ["field\r"]], }, { Name: "FieldCRCRLFCR", Input: "field\r\r\n\rfield\r\r\n\r", - Output: [["field\r"], ["\rfield\r"]] + Output: [["field\r"], ["\rfield\r"]], }, { Name: "FieldCRCRLFCRCR", Input: "field\r\r\n\r\rfield\r\r\n\r\r", Output: [["field\r"], ["\r\rfield\r"], ["\r"]], - ignore: true + ignore: true, }, { Name: "MultiFieldCRCRLFCRCR", @@ -336,9 +336,9 @@ x,,, Output: [ ["field1", "field2\r"], ["\r\rfield1", "field2\r"], - ["\r\r", ""] + ["\r\r", ""], ], - ignore: true + ignore: true, }, { Name: "NonASCIICommaAndComment", @@ -346,14 +346,14 @@ x,,, Output: [["a", "b,c", "d,e"]], TrimLeadingSpace: true, Comma: "£", - Comment: "€" + Comment: "€", }, { Name: "NonASCIICommaAndCommentWithQuotes", Input: 'a€" b,"€ c\nλ comment\n', Output: [["a", " b,", " c"]], Comma: "€", - Comment: "λ" + Comment: "λ", }, { // λ and θ start with the same byte. @@ -362,24 +362,24 @@ x,,, Input: '"abθcd"λefθgh', Output: [["abθcd", "efθgh"]], Comma: "λ", - Comment: "€" + Comment: "€", }, { Name: "NonASCIICommentConfusion", Input: "λ\nλ\nθ\nλ\n", Output: [["λ"], ["λ"], ["λ"]], - Comment: "θ" + Comment: "θ", }, { Name: "QuotedFieldMultipleLF", Input: '"\n\n\n\n"', Output: [["\n\n\n\n"]], - ignore: true + ignore: true, }, { Name: "MultipleCRLF", Input: "\r\n\r\n\r\n\r\n", - ignore: true + ignore: true, }, /** * The implementation may read each line in several chunks if @@ -392,77 +392,77 @@ x,,, "#ignore\n".repeat(10000) + "@".repeat(5000) + "," + "*".repeat(5000), Output: [["@".repeat(5000), "*".repeat(5000)]], Comment: "#", - ignore: true + ignore: true, }, { Name: "QuoteWithTrailingCRLF", Input: '"foo"bar"\r\n', - Error: ErrBareQuote + Error: ErrBareQuote, // Error: &ParseError{StartLine: 1, Line: 1, Column: 4, Err: ErrQuote}, }, { Name: "LazyQuoteWithTrailingCRLF", Input: '"foo"bar"\r\n', Output: [[`foo"bar`]], - LazyQuotes: true + LazyQuotes: true, }, { Name: "DoubleQuoteWithTrailingCRLF", Input: '"foo""bar"\r\n', Output: [[`foo"bar`]], - ignore: true + ignore: true, }, { Name: "EvenQuotes", Input: `""""""""`, Output: [[`"""`]], - ignore: true + ignore: true, }, { Name: "OddQuotes", Input: `"""""""`, Error: true, // Error:" &ParseError{StartLine: 1, Line: 1, Column: 7, Err: ErrQuote}", - ignore: true + ignore: true, }, { Name: "LazyOddQuotes", Input: `"""""""`, Output: [[`"""`]], LazyQuotes: true, - ignore: true + ignore: true, }, { Name: "BadComma1", Comma: "\n", - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadComma2", Comma: "\r", - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadComma3", Comma: '"', - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadComment1", Comment: "\n", - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadComment2", Comment: "\r", - Error: ErrInvalidDelim + Error: ErrInvalidDelim, }, { Name: "BadCommaComment", Comma: "X", Comment: "X", - Error: ErrInvalidDelim - } + Error: ErrInvalidDelim, + }, ]; for (const t of testCases) { Deno.test({ @@ -500,7 +500,7 @@ for (const t of testCases) { comment: comment, trimLeadingSpace: trim, fieldsPerRecord: fieldsPerRec, - lazyQuotes: lazyquote + lazyQuotes: lazyquote, } ); } catch (e) { @@ -516,13 +516,13 @@ for (const t of testCases) { comment: comment, trimLeadingSpace: trim, fieldsPerRecord: fieldsPerRec, - lazyQuotes: lazyquote + lazyQuotes: lazyquote, } ); const expected = t.Output; assertEquals(actual, expected); } - } + }, }); } @@ -531,13 +531,13 @@ const parseTestCases = [ name: "simple", in: "a,b,c", header: false, - result: [["a", "b", "c"]] + result: [["a", "b", "c"]], }, { name: "simple Bufreader", in: new BufReader(new StringReader("a,b,c")), header: false, - result: [["a", "b", "c"]] + result: [["a", "b", "c"]], }, { name: "multiline", @@ -545,14 +545,14 @@ const parseTestCases = [ header: false, result: [ ["a", "b", "c"], - ["e", "f", "g"] - ] + ["e", "f", "g"], + ], }, { name: "header mapping boolean", in: "a,b,c\ne,f,g\n", header: true, - result: [{ a: "e", b: "f", c: "g" }] + result: [{ a: "e", b: "f", c: "g" }], }, { name: "header mapping array", @@ -560,8 +560,8 @@ const parseTestCases = [ header: ["this", "is", "sparta"], result: [ { this: "a", is: "b", sparta: "c" }, - { this: "e", is: "f", sparta: "g" } - ] + { this: "e", is: "f", sparta: "g" }, + ], }, { name: "header mapping object", @@ -569,8 +569,8 @@ const parseTestCases = [ header: [{ name: "this" }, { name: "is" }, { name: "sparta" }], result: [ { this: "a", is: "b", sparta: "c" }, - { this: "e", is: "f", sparta: "g" } - ] + { this: "e", is: "f", sparta: "g" }, + ], }, { name: "header mapping parse entry", @@ -580,25 +580,25 @@ const parseTestCases = [ name: "this", parse: (e: string): string => { return `b${e}$$`; - } + }, }, { name: "is", parse: (e: string): number => { return e.length; - } + }, }, { name: "sparta", parse: (e: string): unknown => { return { bim: `boom-${e}` }; - } - } + }, + }, ], result: [ { this: "ba$$", is: 1, sparta: { bim: `boom-c` } }, - { this: "be$$", is: 1, sparta: { bim: `boom-g` } } - ] + { this: "be$$", is: 1, sparta: { bim: `boom-g` } }, + ], }, { name: "multiline parse", @@ -609,8 +609,8 @@ const parseTestCases = [ header: false, result: [ { super: "a", street: "b", fighter: "c" }, - { super: "e", street: "f", fighter: "g" } - ] + { super: "e", street: "f", fighter: "g" }, + ], }, { name: "header mapping object parseline", @@ -621,9 +621,9 @@ const parseTestCases = [ }, result: [ { super: "a", street: "b", fighter: "c" }, - { super: "e", street: "f", fighter: "g" } - ] - } + { super: "e", street: "f", fighter: "g" }, + ], + }, ]; for (const testCase of parseTestCases) { @@ -632,9 +632,9 @@ for (const testCase of parseTestCases) { async fn(): Promise { const r = await parse(testCase.in, { header: testCase.header, - parse: testCase.parse as (input: unknown) => unknown + parse: testCase.parse as (input: unknown) => unknown, }); assertEquals(r, testCase.result); - } + }, }); } diff --git a/encoding/hex_test.ts b/encoding/hex_test.ts index f98fe5422d48..56bdbf4f0bcb 100644 --- a/encoding/hex_test.ts +++ b/encoding/hex_test.ts @@ -14,7 +14,7 @@ import { decode, decodeString, errLength, - errInvalidByte + errInvalidByte, } from "./hex.ts"; function toByte(s: string): number { @@ -29,7 +29,7 @@ const testCases = [ ["f0f1f2f3f4f5f6f7", [0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7]], ["f8f9fafbfcfdfeff", [0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff]], ["67", Array.from(new TextEncoder().encode("g"))], - ["e3a1", [0xe3, 0xa1]] + ["e3a1", [0xe3, 0xa1]], ]; const errCases = [ @@ -42,7 +42,7 @@ const errCases = [ ["0g", "", errInvalidByte(new TextEncoder().encode("g")[0])], ["00gg", "\x00", errInvalidByte(new TextEncoder().encode("g")[0])], ["0\x01", "", errInvalidByte(new TextEncoder().encode("\x01")[0])], - ["ffeed", "\xff\xee", errLength()] + ["ffeed", "\xff\xee", errLength()], ]; Deno.test({ @@ -53,7 +53,7 @@ Deno.test({ assertEquals(encodedLen(2), 4); assertEquals(encodedLen(3), 6); assertEquals(encodedLen(4), 8); - } + }, }); Deno.test({ @@ -88,7 +88,7 @@ Deno.test({ assertEquals(dest.length, n); assertEquals(new TextDecoder().decode(dest), enc); } - } + }, }); Deno.test({ @@ -97,7 +97,7 @@ Deno.test({ for (const [enc, dec] of testCases) { assertEquals(encodeToString(new Uint8Array(dec as number[])), enc); } - } + }, }); Deno.test({ @@ -108,7 +108,7 @@ Deno.test({ assertEquals(decodedLen(4), 2); assertEquals(decodedLen(6), 3); assertEquals(decodedLen(8), 4); - } + }, }); Deno.test({ @@ -117,7 +117,7 @@ Deno.test({ // Case for decoding uppercase hex characters, since // Encode always uses lowercase. const extraTestcase = [ - ["F8F9FAFBFCFDFEFF", [0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff]] + ["F8F9FAFBFCFDFEFF", [0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff]], ]; const cases = testCases.concat(extraTestcase); @@ -129,7 +129,7 @@ Deno.test({ assertEquals(err, undefined); assertEquals(Array.from(dest), Array.from(dec as number[])); } - } + }, }); Deno.test({ @@ -140,7 +140,7 @@ Deno.test({ assertEquals(dec, Array.from(dst)); } - } + }, }); Deno.test({ @@ -155,7 +155,7 @@ Deno.test({ ); assertEquals(err, expectedErr); } - } + }, }); Deno.test({ @@ -175,5 +175,5 @@ Deno.test({ assertEquals(new TextDecoder("ascii").decode(out), output as string); } } - } + }, }); diff --git a/encoding/mod.ts b/encoding/mod.ts index d63cf47f328a..eaa28ae278e6 100644 --- a/encoding/mod.ts +++ b/encoding/mod.ts @@ -2,13 +2,13 @@ export { HeaderOptions as CsvHeaderOptions, ParseError as CsvParseError, ParseOptions as ParseCsvOptions, - parse as parseCsv + parse as parseCsv, } from "./csv.ts"; export { decode as decodeHex, decodeString as decodeHexString, encode as encodeToHex, - encodeToString as encodeToHexString + encodeToString as encodeToHexString, } from "./hex.ts"; export { parse as parseToml, stringify as tomlStringify } from "./toml.ts"; export { parse as parseYaml, stringify as yamlStringify } from "./yaml.ts"; diff --git a/encoding/toml_test.ts b/encoding/toml_test.ts index 425b8a22c668..d272a29ffe52 100644 --- a/encoding/toml_test.ts +++ b/encoding/toml_test.ts @@ -29,12 +29,12 @@ Deno.test({ str6: "The quick brown\nfox jumps over\nthe lazy dog.", lines: "The first newline is\ntrimmed in raw strings.\n All other " + - "whitespace\n is preserved." - } + "whitespace\n is preserved.", + }, }; const actual = parseFile(path.join(testFilesDir, "string.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -43,7 +43,7 @@ Deno.test({ const expected = { boolean: { bool1: true, bool2: false } }; const actual = parseFile(path.join(testFilesDir, "CRLF.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -52,7 +52,7 @@ Deno.test({ const expected = { boolean: { bool1: true, bool2: false } }; const actual = parseFile(path.join(testFilesDir, "boolean.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -72,12 +72,12 @@ Deno.test({ hex3: "0xdead_beef", oct1: "0o01234567", oct2: "0o755", - bin1: "0b11010110" - } + bin1: "0b11010110", + }, }; const actual = parseFile(path.join(testFilesDir, "integer.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -98,12 +98,12 @@ Deno.test({ sf3: -Infinity, sf4: NaN, sf5: NaN, - sf6: NaN - } + sf6: NaN, + }, }; const actual = parseFile(path.join(testFilesDir, "float.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -113,14 +113,14 @@ Deno.test({ arrays: { data: [ ["gamma", "delta"], - [1, 2] + [1, 2], ], - hosts: ["alpha", "omega"] - } + hosts: ["alpha", "omega"], + }, }; const actual = parseFile(path.join(testFilesDir, "arrays.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -133,27 +133,27 @@ Deno.test({ in: { the: { toml: { - name: "Tom Preston-Werner" - } - } - } - } - } + name: "Tom Preston-Werner", + }, + }, + }, + }, + }, }, servers: { alpha: { ip: "10.0.0.1", - dc: "eqdc10" + dc: "eqdc10", }, beta: { ip: "10.0.0.2", - dc: "eqdc20" - } - } + dc: "eqdc20", + }, + }, }; const actual = parseFile(path.join(testFilesDir, "table.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -164,11 +164,11 @@ Deno.test({ not: "[node]", regex: "", NANI: "何?!", - comment: "Comment inside # the comment" + comment: "Comment inside # the comment", }; const actual = parseFile(path.join(testFilesDir, "simple.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -182,12 +182,12 @@ Deno.test({ odt4: new Date("1979-05-27 07:32:00Z"), ld1: new Date("1979-05-27"), lt1: "07:32:00", - lt2: "00:32:00.999999" - } + lt2: "00:32:00.999999", + }, }; const actual = parseFile(path.join(testFilesDir, "datetime.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -200,39 +200,39 @@ Deno.test({ malevolant: { creation: { drum: { - kit: "Tama" - } - } - } + kit: "Tama", + }, + }, + }, }, derek: { - roddy: "drummer" - } + roddy: "drummer", + }, }, name: { first: "Tom", - last: "Preston-Werner" + last: "Preston-Werner", }, point: { x: 1, - y: 2 + y: 2, }, dog: { type: { - name: "pug" - } + name: "pug", + }, }, "tosin.abasi": "guitarist", animal: { as: { - leaders: "tosin" - } - } - } + leaders: "tosin", + }, + }, + }, }; const actual = parseFile(path.join(testFilesDir, "inlineTable.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -241,13 +241,13 @@ Deno.test({ const expected = { bin: [ { name: "deno", path: "cli/main.rs" }, - { name: "deno_core", path: "src/foo.rs" } + { name: "deno_core", path: "src/foo.rs" }, ], - nib: [{ name: "node", path: "not_found" }] + nib: [{ name: "node", path: "not_found" }], }; const actual = parseFile(path.join(testFilesDir, "arrayTable.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -286,14 +286,14 @@ Deno.test({ "tokio-io": "0.1.11", "tokio-process": "0.2.3", "tokio-threadpool": "0.1.11", - url: "1.7.2" + url: "1.7.2", }, - target: { "cfg(windows)": { dependencies: { winapi: "0.3.6" } } } + target: { "cfg(windows)": { dependencies: { winapi: "0.3.6" } } }, }; /* eslint-enable @typescript-eslint/camelcase */ const actual = parseFile(path.join(testFilesDir, "cargo.toml")); assertEquals(actual, expected); - } + }, }); Deno.test({ @@ -303,15 +303,15 @@ Deno.test({ foo: { bar: "deno" }, this: { is: { nested: "denonono" } }, "https://deno.land/std": { - $: "doller" + $: "doller", }, "##": { deno: { "https://deno.land": { proto: "https", - ":80": "port" - } - } + ":80": "port", + }, + }, }, arrayObjects: [{ stuff: "in" }, {}, { the: "array" }], deno: "is", @@ -347,9 +347,9 @@ Deno.test({ sf6: NaN, data: [ ["gamma", "delta"], - [1, 2] + [1, 2], ], - hosts: ["alpha", "omega"] + hosts: ["alpha", "omega"], }; const expected = `deno = "is" not = "[node]" @@ -408,5 +408,5 @@ the = "array" `; const actual = stringify(src); assertEquals(actual, expected); - } + }, }); diff --git a/encoding/yaml.ts b/encoding/yaml.ts index a8784319b350..76b1b8379c18 100644 --- a/encoding/yaml.ts +++ b/encoding/yaml.ts @@ -6,6 +6,6 @@ export { ParseOptions, parse, parseAll } from "./yaml/parse.ts"; export { DumpOptions as StringifyOptions, - stringify + stringify, } from "./yaml/stringify.ts"; export * from "./yaml/schema/mod.ts"; diff --git a/encoding/yaml/dumper/dumper.ts b/encoding/yaml/dumper/dumper.ts index 3a34e14cc7d1..1280ee757293 100644 --- a/encoding/yaml/dumper/dumper.ts +++ b/encoding/yaml/dumper/dumper.ts @@ -73,7 +73,7 @@ const DEPRECATED_BOOLEANS_SYNTAX = [ "NO", "off", "Off", - "OFF" + "OFF", ]; function encodeHex(character: number): string { diff --git a/encoding/yaml/dumper/dumper_state.ts b/encoding/yaml/dumper/dumper_state.ts index 88164a0d235d..94cd84878fbd 100644 --- a/encoding/yaml/dumper/dumper_state.ts +++ b/encoding/yaml/dumper/dumper_state.ts @@ -121,7 +121,7 @@ export class DumperState extends State { lineWidth = 80, noRefs = false, noCompatMode = false, - condenseFlow = false + condenseFlow = false, }: DumperStateOptions) { super(schema); this.indent = Math.max(1, indent); diff --git a/encoding/yaml/example/dump.ts b/encoding/yaml/example/dump.ts index 746c3be01bf5..db3647274ce1 100644 --- a/encoding/yaml/example/dump.ts +++ b/encoding/yaml/example/dump.ts @@ -10,13 +10,13 @@ console.log( "a", "b", { - a: false + a: false, }, { - a: false - } - ] + a: false, + }, + ], }, - test: "foobar" + test: "foobar", }) ); diff --git a/encoding/yaml/example/inout.ts b/encoding/yaml/example/inout.ts index 80cad8258715..b0b47e3fe825 100644 --- a/encoding/yaml/example/inout.ts +++ b/encoding/yaml/example/inout.ts @@ -9,14 +9,14 @@ const test = { "a", "b", { - a: false + a: false, }, { - a: false - } - ] + a: false, + }, + ], }, - test: "foobar" + test: "foobar", }; const string = stringify(test); diff --git a/encoding/yaml/loader/loader.ts b/encoding/yaml/loader/loader.ts index 1ab4fc7f5b5e..f0d535624698 100644 --- a/encoding/yaml/loader/loader.ts +++ b/encoding/yaml/loader/loader.ts @@ -37,11 +37,11 @@ function _class(obj: unknown): string { } function isEOL(c: number): boolean { - return c === 0x0a /* LF */ || c === 0x0d /* CR */; + return c === 0x0a || /* LF */ c === 0x0d /* CR */; } function isWhiteSpace(c: number): boolean { - return c === 0x09 /* Tab */ || c === 0x20 /* Space */; + return c === 0x09 || /* Tab */ c === 0x20 /* Space */; } function isWsOrEol(c: number): boolean { @@ -64,13 +64,13 @@ function isFlowIndicator(c: number): boolean { } function fromHexCode(c: number): number { - if (0x30 /* 0 */ <= c && c <= 0x39 /* 9 */) { + if (0x30 <= /* 0 */ c && c <= 0x39 /* 9 */) { return c - 0x30; } const lc = c | 0x20; - if (0x61 /* a */ <= lc && lc <= 0x66 /* f */) { + if (0x61 <= /* a */ lc && lc <= 0x66 /* f */) { return lc - 0x61 + 10; } @@ -91,7 +91,7 @@ function escapedHexLen(c: number): number { } function fromDecimalCode(c: number): number { - if (0x30 /* 0 */ <= c && c <= 0x39 /* 9 */) { + if (0x30 <= /* 0 */ c && c <= 0x39 /* 9 */) { return c - 0x30; } @@ -251,7 +251,7 @@ const directiveHandlers: DirectiveHandlers = { state.tagMap = {}; } state.tagMap[handle] = prefix; - } + }, }; function captureSegment( @@ -414,7 +414,7 @@ function skipSeparationSpace( if (allowComments && ch === 0x23 /* # */) { do { ch = state.input.charCodeAt(++state.position); - } while (ch !== 0x0a /* LF */ && ch !== 0x0d /* CR */ && ch !== 0); + } while (ch !== 0x0a && /* LF */ ch !== 0x0d && /* CR */ ch !== 0); } if (isEOL(ch)) { @@ -451,7 +451,7 @@ function testDocumentSeparator(state: LoaderState): boolean { // Condition state.position === state.lineStart is tested // in parent on each call, for efficiency. No needs to test here again. if ( - (ch === 0x2d /* - */ || ch === 0x2e) /* . */ && + (ch === 0x2d || /* - */ ch === 0x2e) /* . */ && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2) ) { @@ -503,7 +503,7 @@ function readPlainScalar( } let following: number; - if (ch === 0x3f /* ? */ || ch === 0x2d /* - */) { + if (ch === 0x3f || /* ? */ ch === 0x2d /* - */) { following = state.input.charCodeAt(state.position + 1); if ( @@ -869,7 +869,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean { while (ch !== 0) { ch = state.input.charCodeAt(++state.position); - if (ch === 0x2b /* + */ || ch === 0x2d /* - */) { + if (ch === 0x2b || /* + */ ch === 0x2d /* - */) { if (CHOMPING_CLIP === chomping) { chomping = ch === 0x2b /* + */ ? CHOMPING_KEEP : CHOMPING_STRIP; } else { @@ -1103,7 +1103,7 @@ function readBlockMapping( // Explicit notation case. There are two separate blocks: // first for the key (denoted by "?") and second for the value (denoted by ":") // - if ((ch === 0x3f /* ? */ || ch === 0x3a) /* : */ && isWsOrEol(following)) { + if ((ch === 0x3f || /* ? */ ch === 0x3a) && /* : */ isWsOrEol(following)) { if (ch === 0x3f /* ? */) { if (atExplicitKey) { storeMappingPair( diff --git a/encoding/yaml/loader/loader_state.ts b/encoding/yaml/loader/loader_state.ts index 1e136025cf37..ca50fcaf1dbd 100644 --- a/encoding/yaml/loader/loader_state.ts +++ b/encoding/yaml/loader/loader_state.ts @@ -56,7 +56,7 @@ export class LoaderState extends State { onWarning, legacy = false, json = false, - listener = null + listener = null, }: LoaderStateOptions ) { super(schema); diff --git a/encoding/yaml/parse_test.ts b/encoding/yaml/parse_test.ts index bdcd8db62940..21f1b893bda3 100644 --- a/encoding/yaml/parse_test.ts +++ b/encoding/yaml/parse_test.ts @@ -20,7 +20,7 @@ Deno.test({ const expected = { test: "toto", foo: { bar: true, baz: 1, qux: null } }; assertEquals(parse(yaml), expected); - } + }, }); Deno.test({ @@ -40,17 +40,17 @@ name: Eve const expected = [ { id: 1, - name: "Alice" + name: "Alice", }, { id: 2, - name: "Bob" + name: "Bob", }, { id: 3, - name: "Eve" - } + name: "Eve", + }, ]; assertEquals(parseAll(yaml), expected); - } + }, }); diff --git a/encoding/yaml/schema.ts b/encoding/yaml/schema.ts index 1968e34c1e57..579644dbb7c7 100644 --- a/encoding/yaml/schema.ts +++ b/encoding/yaml/schema.ts @@ -45,7 +45,7 @@ function compileMap(...typesList: Type[][]): TypeMap { fallback: {}, mapping: {}, scalar: {}, - sequence: {} + sequence: {}, }; for (const types of typesList) { diff --git a/encoding/yaml/schema/core.ts b/encoding/yaml/schema/core.ts index 82a512a1e1fe..4fadc9bfee9e 100644 --- a/encoding/yaml/schema/core.ts +++ b/encoding/yaml/schema/core.ts @@ -9,5 +9,5 @@ import { json } from "./json.ts"; // Standard YAML's Core schema. // http://www.yaml.org/spec/1.2/spec.html#id2804923 export const core = new Schema({ - include: [json] + include: [json], }); diff --git a/encoding/yaml/schema/default.ts b/encoding/yaml/schema/default.ts index 0fe1dbf1290c..4c5ceeba7153 100644 --- a/encoding/yaml/schema/default.ts +++ b/encoding/yaml/schema/default.ts @@ -12,5 +12,5 @@ import { core } from "./core.ts"; export const def = new Schema({ explicit: [binary, omap, pairs, set], implicit: [timestamp, merge], - include: [core] + include: [core], }); diff --git a/encoding/yaml/schema/failsafe.ts b/encoding/yaml/schema/failsafe.ts index 0fbb74ca9dc1..74e1897be1e1 100644 --- a/encoding/yaml/schema/failsafe.ts +++ b/encoding/yaml/schema/failsafe.ts @@ -9,5 +9,5 @@ import { map, seq, str } from "../type/mod.ts"; // Standard YAML's Failsafe schema. // http://www.yaml.org/spec/1.2/spec.html#id2802346 export const failsafe = new Schema({ - explicit: [str, seq, map] + explicit: [str, seq, map], }); diff --git a/encoding/yaml/schema/json.ts b/encoding/yaml/schema/json.ts index dae469f350c7..c30166fdf9c4 100644 --- a/encoding/yaml/schema/json.ts +++ b/encoding/yaml/schema/json.ts @@ -11,5 +11,5 @@ import { failsafe } from "./failsafe.ts"; // http://www.yaml.org/spec/1.2/spec.html#id2803231 export const json = new Schema({ implicit: [nil, bool, int, float], - include: [failsafe] + include: [failsafe], }); diff --git a/encoding/yaml/stringify_test.ts b/encoding/yaml/stringify_test.ts index 941beb789f3b..03a3090d96f4 100644 --- a/encoding/yaml/stringify_test.ts +++ b/encoding/yaml/stringify_test.ts @@ -16,14 +16,14 @@ Deno.test({ "a", "b", { - a: false + a: false, }, { - a: false - } - ] + a: false, + }, + ], }, - test: "foobar" + test: "foobar", }; const ASSERTS = `foo: @@ -37,5 +37,5 @@ test: foobar `; assertEquals(stringify(FIXTURE), ASSERTS); - } + }, }); diff --git a/encoding/yaml/type/binary.ts b/encoding/yaml/type/binary.ts index 8cfe54f7965f..f4823b3f74e5 100644 --- a/encoding/yaml/type/binary.ts +++ b/encoding/yaml/type/binary.ts @@ -135,5 +135,5 @@ export const binary = new Type("tag:yaml.org,2002:binary", { kind: "scalar", predicate: isBinary, represent: representYamlBinary, - resolve: resolveYamlBinary + resolve: resolveYamlBinary, }); diff --git a/encoding/yaml/type/bool.ts b/encoding/yaml/type/bool.ts index e39823872fab..a5a85cf9e108 100644 --- a/encoding/yaml/type/bool.ts +++ b/encoding/yaml/type/bool.ts @@ -33,7 +33,7 @@ export const bool = new Type("tag:yaml.org,2002:bool", { }, camelcase(object: boolean): string { return object ? "True" : "False"; - } + }, }, - resolve: resolveYamlBoolean + resolve: resolveYamlBoolean, }); diff --git a/encoding/yaml/type/float.ts b/encoding/yaml/type/float.ts index acb12f5b0088..5ae0689b20a5 100644 --- a/encoding/yaml/type/float.ts +++ b/encoding/yaml/type/float.ts @@ -121,5 +121,5 @@ export const float = new Type("tag:yaml.org,2002:float", { kind: "scalar", predicate: isFloat, represent: representYamlFloat, - resolve: resolveYamlFloat + resolve: resolveYamlFloat, }); diff --git a/encoding/yaml/type/int.ts b/encoding/yaml/type/int.ts index 93ec8260e58b..6a86aafe9df6 100644 --- a/encoding/yaml/type/int.ts +++ b/encoding/yaml/type/int.ts @@ -8,18 +8,18 @@ import { isNegativeZero, Any } from "../utils.ts"; function isHexCode(c: number): boolean { return ( - (0x30 /* 0 */ <= c && c <= 0x39) /* 9 */ || - (0x41 /* A */ <= c && c <= 0x46) /* F */ || - (0x61 /* a */ <= c && c <= 0x66) /* f */ + (0x30 <= /* 0 */ c && c <= 0x39) /* 9 */ || + (0x41 <= /* A */ c && c <= 0x46) /* F */ || + (0x61 <= /* a */ c && c <= 0x66) /* f */ ); } function isOctCode(c: number): boolean { - return 0x30 /* 0 */ <= c && c <= 0x37 /* 7 */; + return 0x30 <= /* 0 */ c && c <= 0x37 /* 7 */; } function isDecCode(c: number): boolean { - return 0x30 /* 0 */ <= c && c <= 0x39 /* 9 */; + return 0x30 <= /* 0 */ c && c <= 0x39 /* 9 */; } function resolveYamlInteger(data: string): boolean { @@ -175,17 +175,14 @@ export const int = new Type("tag:yaml.org,2002:int", { hexadecimal(obj: number): string { return obj >= 0 ? `0x${obj.toString(16).toUpperCase()}` - : `-0x${obj - .toString(16) - .toUpperCase() - .slice(1)}`; - } + : `-0x${obj.toString(16).toUpperCase().slice(1)}`; + }, }, resolve: resolveYamlInteger, styleAliases: { binary: [2, "bin"], decimal: [10, "dec"], hexadecimal: [16, "hex"], - octal: [8, "oct"] - } + octal: [8, "oct"], + }, }); diff --git a/encoding/yaml/type/map.ts b/encoding/yaml/type/map.ts index 60e6786572e2..dcd99abcac97 100644 --- a/encoding/yaml/type/map.ts +++ b/encoding/yaml/type/map.ts @@ -10,5 +10,5 @@ export const map = new Type("tag:yaml.org,2002:map", { construct(data): Any { return data !== null ? data : {}; }, - kind: "mapping" + kind: "mapping", }); diff --git a/encoding/yaml/type/merge.ts b/encoding/yaml/type/merge.ts index 77b34025b592..68314bf2e452 100644 --- a/encoding/yaml/type/merge.ts +++ b/encoding/yaml/type/merge.ts @@ -11,5 +11,5 @@ function resolveYamlMerge(data: string): boolean { export const merge = new Type("tag:yaml.org,2002:merge", { kind: "scalar", - resolve: resolveYamlMerge + resolve: resolveYamlMerge, }); diff --git a/encoding/yaml/type/nil.ts b/encoding/yaml/type/nil.ts index 00627514ccc9..8a48d02fb637 100644 --- a/encoding/yaml/type/nil.ts +++ b/encoding/yaml/type/nil.ts @@ -39,7 +39,7 @@ export const nil = new Type("tag:yaml.org,2002:null", { }, camelcase(): string { return "Null"; - } + }, }, - resolve: resolveYamlNull + resolve: resolveYamlNull, }); diff --git a/encoding/yaml/type/omap.ts b/encoding/yaml/type/omap.ts index 541e31df6249..d6d751505819 100644 --- a/encoding/yaml/type/omap.ts +++ b/encoding/yaml/type/omap.ts @@ -42,5 +42,5 @@ function constructYamlOmap(data: Any): Any { export const omap = new Type("tag:yaml.org,2002:omap", { construct: constructYamlOmap, kind: "sequence", - resolve: resolveYamlOmap + resolve: resolveYamlOmap, }); diff --git a/encoding/yaml/type/pairs.ts b/encoding/yaml/type/pairs.ts index c964524b562a..e999748ae735 100644 --- a/encoding/yaml/type/pairs.ts +++ b/encoding/yaml/type/pairs.ts @@ -45,5 +45,5 @@ function constructYamlPairs(data: string): Any[] { export const pairs = new Type("tag:yaml.org,2002:pairs", { construct: constructYamlPairs, kind: "sequence", - resolve: resolveYamlPairs + resolve: resolveYamlPairs, }); diff --git a/encoding/yaml/type/seq.ts b/encoding/yaml/type/seq.ts index bd7ceb945388..b19565dbca8d 100644 --- a/encoding/yaml/type/seq.ts +++ b/encoding/yaml/type/seq.ts @@ -10,5 +10,5 @@ export const seq = new Type("tag:yaml.org,2002:seq", { construct(data): Any { return data !== null ? data : []; }, - kind: "sequence" + kind: "sequence", }); diff --git a/encoding/yaml/type/set.ts b/encoding/yaml/type/set.ts index 3b7fca0e9695..0bfe1c8db4e4 100644 --- a/encoding/yaml/type/set.ts +++ b/encoding/yaml/type/set.ts @@ -27,5 +27,5 @@ function constructYamlSet(data: string): Any { export const set = new Type("tag:yaml.org,2002:set", { construct: constructYamlSet, kind: "mapping", - resolve: resolveYamlSet + resolve: resolveYamlSet, }); diff --git a/encoding/yaml/type/str.ts b/encoding/yaml/type/str.ts index c7227743e3fe..cd6e9430fc14 100644 --- a/encoding/yaml/type/str.ts +++ b/encoding/yaml/type/str.ts @@ -8,5 +8,5 @@ export const str = new Type("tag:yaml.org,2002:str", { construct(data): string { return data !== null ? data : ""; }, - kind: "scalar" + kind: "scalar", }); diff --git a/encoding/yaml/type/timestamp.ts b/encoding/yaml/type/timestamp.ts index 14d24077a887..eb03b382501b 100644 --- a/encoding/yaml/type/timestamp.ts +++ b/encoding/yaml/type/timestamp.ts @@ -92,5 +92,5 @@ export const timestamp = new Type("tag:yaml.org,2002:timestamp", { instanceOf: Date, kind: "scalar", represent: representYamlTimestamp, - resolve: resolveYamlTimestamp + resolve: resolveYamlTimestamp, }); diff --git a/examples/chat/server.ts b/examples/chat/server.ts index 08aede05bbc6..eb5b2f7d4823 100644 --- a/examples/chat/server.ts +++ b/examples/chat/server.ts @@ -3,7 +3,7 @@ import { acceptWebSocket, acceptable, WebSocket, - isWebSocketCloseEvent + isWebSocketCloseEvent, } from "../../ws/mod.ts"; const clients = new Map(); @@ -29,19 +29,19 @@ async function wsHandler(ws: WebSocket): Promise { } } -listenAndServe({ port: 8080 }, async req => { +listenAndServe({ port: 8080 }, async (req) => { if (req.method === "GET" && req.url === "/") { //Serve with hack const u = new URL("./index.html", import.meta.url); if (u.protocol.startsWith("http")) { // server launched by deno run http(s)://.../server.ts, - fetch(u.href).then(resp => { + fetch(u.href).then((resp) => { return req.respond({ status: resp.status, headers: new Headers({ - "content-type": "text/html" + "content-type": "text/html", }), - body: resp.body + body: resp.body, }); }); } else { @@ -50,9 +50,9 @@ listenAndServe({ port: 8080 }, async req => { req.respond({ status: 200, headers: new Headers({ - "content-type": "text/html" + "content-type": "text/html", }), - body: file + body: file, }); } } @@ -60,8 +60,8 @@ listenAndServe({ port: 8080 }, async req => { req.respond({ status: 302, headers: new Headers({ - location: "https://deno.land/favicon.ico" - }) + location: "https://deno.land/favicon.ico", + }), }); } if (req.method === "GET" && req.url === "/ws") { @@ -70,7 +70,7 @@ listenAndServe({ port: 8080 }, async req => { conn: req.conn, bufReader: req.r, bufWriter: req.w, - headers: req.headers + headers: req.headers, }).then(wsHandler); } } diff --git a/examples/chat/server_test.ts b/examples/chat/server_test.ts index 13a5c337c18e..673b61174190 100644 --- a/examples/chat/server_test.ts +++ b/examples/chat/server_test.ts @@ -11,7 +11,7 @@ async function startServer(): Promise { const server = Deno.run({ cmd: [Deno.execPath(), "--allow-net", "--allow-read", "server.ts"], cwd: "examples/chat", - stdout: "piped" + stdout: "piped", }); try { assert(server.stdout != null); @@ -45,7 +45,7 @@ test({ server.stdout!.close(); } await delay(10); - } + }, }); test({ @@ -65,5 +65,5 @@ test({ server.stdout!.close(); ws!.conn.close(); } - } + }, }); diff --git a/examples/gist.ts b/examples/gist.ts index 15f00ff5d04d..a11a92383598 100755 --- a/examples/gist.ts +++ b/examples/gist.ts @@ -35,7 +35,7 @@ for (const filename of parsedArgs._) { const content = { description: parsedArgs.title || parsedArgs.t || "Example", public: false, - files: files + files: files, }; const body = JSON.stringify(content); @@ -44,9 +44,9 @@ const res = await fetch("https://api.github.com/gists", { headers: [ ["Content-Type", "application/json"], ["User-Agent", "Deno-Gist"], - ["Authorization", `token ${token}`] + ["Authorization", `token ${token}`], ], - body + body, }); if (res.ok) { diff --git a/examples/test.ts b/examples/test.ts index d5dd8bedcf01..6e26407fb0bc 100644 --- a/examples/test.ts +++ b/examples/test.ts @@ -19,10 +19,10 @@ Deno.test(async function catSmoke(): Promise { "run", "--allow-read", "examples/cat.ts", - "README.md" + "README.md", ], stdout: "null", - stderr: "null" + stderr: "null", }); const s = await p.status(); assertEquals(s.code, 0); diff --git a/examples/tests/cat_test.ts b/examples/tests/cat_test.ts index 0f17b798d6fd..b12a6916f6b8 100644 --- a/examples/tests/cat_test.ts +++ b/examples/tests/cat_test.ts @@ -9,10 +9,10 @@ Deno.test("[examples/cat] print multiple files", async () => { "--allow-read", "cat.ts", "testdata/cat/hello.txt", - "testdata/cat/world.txt" + "testdata/cat/world.txt", ], cwd: "examples", - stdout: "piped" + stdout: "piped", }); try { diff --git a/examples/tests/catj_test.ts b/examples/tests/catj_test.ts index 3f246a65f017..53b36bef83b1 100644 --- a/examples/tests/catj_test.ts +++ b/examples/tests/catj_test.ts @@ -12,7 +12,7 @@ Deno.test("[examples/catj] print an array", async () => { ".[1] = 100", '.[2].key = "value"', '.[2].array[0] = "foo"', - '.[2].array[1] = "bar"' + '.[2].array[1] = "bar"', ].join("\n"); assertStrictEq(actual, expected); @@ -31,7 +31,7 @@ Deno.test("[examples/catj] print an object", async () => { const expected = [ '.string = "foobar"', ".number = 123", - '.array[0].message = "hello"' + '.array[0].message = "hello"', ].join("\n"); assertStrictEq(actual, expected); @@ -81,6 +81,6 @@ function catj(...files: string[]): Deno.Process { cwd: "examples", stdin: "piped", stdout: "piped", - env: { NO_COLOR: "true" } + env: { NO_COLOR: "true" }, }); } diff --git a/examples/tests/colors_test.ts b/examples/tests/colors_test.ts index 7c01cd8d650c..ac779adb8d3d 100644 --- a/examples/tests/colors_test.ts +++ b/examples/tests/colors_test.ts @@ -6,7 +6,7 @@ Deno.test("[examples/colors] print a colored text", async () => { const process = Deno.run({ cmd: [Deno.execPath(), "colors.ts"], cwd: "examples", - stdout: "piped" + stdout: "piped", }); try { const output = await process.output(); diff --git a/examples/tests/curl_test.ts b/examples/tests/curl_test.ts index 8d7634525363..9b2870216f51 100644 --- a/examples/tests/curl_test.ts +++ b/examples/tests/curl_test.ts @@ -16,7 +16,7 @@ Deno.test({ const process = Deno.run({ cmd: [Deno.execPath(), "--allow-net", "curl.ts", "http://localhost:8081"], cwd: "examples", - stdout: "piped" + stdout: "piped", }); try { @@ -30,5 +30,5 @@ Deno.test({ process.close(); await serverPromise; } - } + }, }); diff --git a/examples/tests/echo_server_test.ts b/examples/tests/echo_server_test.ts index dd73360232ce..fecc7d6a666c 100644 --- a/examples/tests/echo_server_test.ts +++ b/examples/tests/echo_server_test.ts @@ -8,7 +8,7 @@ Deno.test("[examples/echo_server]", async () => { const process = Deno.run({ cmd: [Deno.execPath(), "--allow-net", "echo_server.ts"], cwd: "examples", - stdout: "piped" + stdout: "piped", }); let conn: Deno.Conn | undefined; diff --git a/examples/tests/welcome_test.ts b/examples/tests/welcome_test.ts index 60c55dc0b001..cacb77ab9db4 100644 --- a/examples/tests/welcome_test.ts +++ b/examples/tests/welcome_test.ts @@ -6,7 +6,7 @@ Deno.test("[examples/welcome] print a welcome message", async () => { const process = Deno.run({ cmd: [Deno.execPath(), "welcome.ts"], cwd: "examples", - stdout: "piped" + stdout: "piped", }); try { const output = await process.output(); diff --git a/examples/tests/xeval_test.ts b/examples/tests/xeval_test.ts index 92e9e1bfef36..25f99c9f0bca 100644 --- a/examples/tests/xeval_test.ts +++ b/examples/tests/xeval_test.ts @@ -5,7 +5,7 @@ import { decode, encode } from "../../strings/mod.ts"; import { assertEquals, assertStrContains, - assert + assert, } from "../../testing/asserts.ts"; const { execPath, run } = Deno; @@ -18,7 +18,7 @@ Deno.test(async function xevalSuccess(): Promise { Deno.test(async function xevalDelimiter(): Promise { const chunks: string[] = []; await xeval(stringsReader("!MADMADAMADAM!"), ($): number => chunks.push($), { - delimiter: "MADAM" + delimiter: "MADAM", }); assertEquals(chunks, ["!MAD", "ADAM!"]); }); @@ -27,12 +27,12 @@ const xevalPath = "examples/xeval.ts"; Deno.test({ name: "xevalCliReplvar", - fn: async function(): Promise { + fn: async function (): Promise { const p = run({ cmd: [execPath(), xevalPath, "--replvar=abc", "console.log(abc)"], stdin: "piped", stdout: "piped", - stderr: "null" + stderr: "null", }); assert(p.stdin != null); await p.stdin.write(encode("hello")); @@ -40,7 +40,7 @@ Deno.test({ assertEquals(await p.status(), { code: 0, success: true }); assertEquals(decode(await p.output()).trimEnd(), "hello"); p.close(); - } + }, }); Deno.test(async function xevalCliSyntaxError(): Promise { @@ -48,7 +48,7 @@ Deno.test(async function xevalCliSyntaxError(): Promise { cmd: [execPath(), xevalPath, "("], stdin: "null", stdout: "piped", - stderr: "piped" + stderr: "piped", }); assertEquals(await p.status(), { code: 1, success: false }); assertEquals(decode(await p.output()), ""); diff --git a/examples/xeval.ts b/examples/xeval.ts index 16ce37fb4ff0..6589fec168a0 100644 --- a/examples/xeval.ts +++ b/examples/xeval.ts @@ -5,7 +5,7 @@ type Reader = Deno.Reader; /* eslint-disable-next-line max-len */ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction. -const AsyncFunction = Object.getPrototypeOf(async function(): Promise {}) +const AsyncFunction = Object.getPrototypeOf(async function (): Promise {}) .constructor; /* eslint-disable max-len */ @@ -59,12 +59,12 @@ async function main(): Promise { alias: { delim: ["d"], replvar: ["I"], - help: ["h"] + help: ["h"], }, default: { delim: DEFAULT_DELIMITER, - replvar: "$" - } + replvar: "$", + }, }); if (parsedArgs._.length != 1) { console.error(HELP_MSG); diff --git a/flags/all_bool_test.ts b/flags/all_bool_test.ts index 6516f48ed5a8..cb5a36710ee0 100755 --- a/flags/all_bool_test.ts +++ b/flags/all_bool_test.ts @@ -5,12 +5,12 @@ import { parse } from "./mod.ts"; // flag boolean true (default all --args to boolean) Deno.test(function flagBooleanTrue(): void { const argv = parse(["moo", "--honk", "cow"], { - boolean: true + boolean: true, }); assertEquals(argv, { honk: true, - _: ["moo", "cow"] + _: ["moo", "cow"], }); assertEquals(typeof argv.honk, "boolean"); @@ -19,14 +19,14 @@ Deno.test(function flagBooleanTrue(): void { // flag boolean true only affects double hyphen arguments without equals signs Deno.test(function flagBooleanTrueOnlyAffectsDoubleDash(): void { const argv = parse(["moo", "--honk", "cow", "-p", "55", "--tacos=good"], { - boolean: true + boolean: true, }); assertEquals(argv, { honk: true, tacos: "good", p: 55, - _: ["moo", "cow"] + _: ["moo", "cow"], }); assertEquals(typeof argv.honk, "boolean"); diff --git a/flags/bool_test.ts b/flags/bool_test.ts index 2d6a8b938000..f2d88e617a07 100755 --- a/flags/bool_test.ts +++ b/flags/bool_test.ts @@ -5,13 +5,13 @@ import { parse } from "./mod.ts"; Deno.test(function flagBooleanDefaultFalse(): void { const argv = parse(["moo"], { boolean: ["t", "verbose"], - default: { verbose: false, t: false } + default: { verbose: false, t: false }, }); assertEquals(argv, { verbose: false, t: false, - _: ["moo"] + _: ["moo"], }); assertEquals(typeof argv.verbose, "boolean"); @@ -20,14 +20,14 @@ Deno.test(function flagBooleanDefaultFalse(): void { Deno.test(function booleanGroups(): void { const argv = parse(["-x", "-z", "one", "two", "three"], { - boolean: ["x", "y", "z"] + boolean: ["x", "y", "z"], }); assertEquals(argv, { x: true, y: false, z: true, - _: ["one", "two", "three"] + _: ["one", "two", "three"], }); assertEquals(typeof argv.x, "boolean"); @@ -40,16 +40,16 @@ Deno.test(function booleanAndAliasWithChainableApi(): void { const regular = ["--herp", "derp"]; const aliasedArgv = parse(aliased, { boolean: "herp", - alias: { h: "herp" } + alias: { h: "herp" }, }); const propertyArgv = parse(regular, { boolean: "herp", - alias: { h: "herp" } + alias: { h: "herp" }, }); const expected = { herp: true, h: true, - _: ["derp"] + _: ["derp"], }; assertEquals(aliasedArgv, expected); @@ -61,14 +61,14 @@ Deno.test(function booleanAndAliasWithOptionsHash(): void { const regular = ["--herp", "derp"]; const opts = { alias: { h: "herp" }, - boolean: "herp" + boolean: "herp", }; const aliasedArgv = parse(aliased, opts); const propertyArgv = parse(regular, opts); const expected = { herp: true, h: true, - _: ["derp"] + _: ["derp"], }; assertEquals(aliasedArgv, expected); assertEquals(propertyArgv, expected); @@ -80,7 +80,7 @@ Deno.test(function booleanAndAliasArrayWithOptionsHash(): void { const alt = ["--harp", "derp"]; const opts = { alias: { h: ["herp", "harp"] }, - boolean: "h" + boolean: "h", }; const aliasedArgv = parse(aliased, opts); const propertyArgv = parse(regular, opts); @@ -89,7 +89,7 @@ Deno.test(function booleanAndAliasArrayWithOptionsHash(): void { harp: true, herp: true, h: true, - _: ["derp"] + _: ["derp"], }; assertEquals(aliasedArgv, expected); assertEquals(propertyArgv, expected); @@ -101,14 +101,14 @@ Deno.test(function booleanAndAliasUsingExplicitTrue(): void { const regular = ["--herp", "true"]; const opts = { alias: { h: "herp" }, - boolean: "h" + boolean: "h", }; const aliasedArgv = parse(aliased, opts); const propertyArgv = parse(regular, opts); const expected = { herp: true, h: true, - _: [] + _: [], }; assertEquals(aliasedArgv, expected); @@ -119,14 +119,14 @@ Deno.test(function booleanAndAliasUsingExplicitTrue(): void { // boolean and --x=true Deno.test(function booleanAndNonBoolean(): void { const parsed = parse(["--boool", "--other=true"], { - boolean: "boool" + boolean: "boool", }); assertEquals(parsed.boool, true); assertEquals(parsed.other, "true"); const parsed2 = parse(["--boool", "--other=false"], { - boolean: "boool" + boolean: "boool", }); assertEquals(parsed2.boool, true); @@ -136,9 +136,9 @@ Deno.test(function booleanAndNonBoolean(): void { Deno.test(function booleanParsingTrue(): void { const parsed = parse(["--boool=true"], { default: { - boool: false + boool: false, }, - boolean: ["boool"] + boolean: ["boool"], }); assertEquals(parsed.boool, true); @@ -147,9 +147,9 @@ Deno.test(function booleanParsingTrue(): void { Deno.test(function booleanParsingFalse(): void { const parsed = parse(["--boool=false"], { default: { - boool: true + boool: true, }, - boolean: ["boool"] + boolean: ["boool"], }); assertEquals(parsed.boool, false); @@ -187,7 +187,7 @@ Deno.test(function latestFlagIsBooleanNegation(): void { assertEquals(parsed.foo, false); const parsed2 = parse(["--no-foo", "--foo", "--no-foo", "123"], { - boolean: ["foo"] + boolean: ["foo"], }); assertEquals(parsed2.foo, false); }); @@ -197,7 +197,7 @@ Deno.test(function latestFlagIsBoolean(): void { assertEquals(parsed.foo, true); const parsed2 = parse(["--foo", "--no-foo", "--foo", "123"], { - boolean: ["foo"] + boolean: ["foo"], }); assertEquals(parsed2.foo, true); }); diff --git a/flags/dash_test.ts b/flags/dash_test.ts index bdf8f502df2a..3df169291a3f 100755 --- a/flags/dash_test.ts +++ b/flags/dash_test.ts @@ -22,7 +22,7 @@ Deno.test(function moveArgsAfterDoubleDashIntoOwnArray(): void { { name: "John", _: ["before"], - "--": ["after"] + "--": ["after"], } ); }); diff --git a/flags/default_bool_test.ts b/flags/default_bool_test.ts index 813b6870b931..4376038feca0 100755 --- a/flags/default_bool_test.ts +++ b/flags/default_bool_test.ts @@ -5,7 +5,7 @@ import { parse } from "./mod.ts"; Deno.test(function booleanDefaultTrue(): void { const argv = parse([], { boolean: "sometrue", - default: { sometrue: true } + default: { sometrue: true }, }); assertEquals(argv.sometrue, true); }); @@ -13,7 +13,7 @@ Deno.test(function booleanDefaultTrue(): void { Deno.test(function booleanDefaultFalse(): void { const argv = parse([], { boolean: "somefalse", - default: { somefalse: false } + default: { somefalse: false }, }); assertEquals(argv.somefalse, false); }); @@ -21,12 +21,12 @@ Deno.test(function booleanDefaultFalse(): void { Deno.test(function booleanDefaultNull(): void { const argv = parse([], { boolean: "maybe", - default: { maybe: null } + default: { maybe: null }, }); assertEquals(argv.maybe, null); const argv2 = parse(["--maybe"], { boolean: "maybe", - default: { maybe: null } + default: { maybe: null }, }); assertEquals(argv2.maybe, true); }); diff --git a/flags/dotted_test.ts b/flags/dotted_test.ts index 93dd3031f6e4..c86392f2aff8 100755 --- a/flags/dotted_test.ts +++ b/flags/dotted_test.ts @@ -5,7 +5,7 @@ import { parse } from "./mod.ts"; Deno.test(function dottedAlias(): void { const argv = parse(["--a.b", "22"], { default: { "a.b": 11 }, - alias: { "a.b": "aa.bb" } + alias: { "a.b": "aa.bb" }, }); assertEquals(argv.a.b, 22); assertEquals(argv.aa.bb, 22); diff --git a/flags/long_test.ts b/flags/long_test.ts index e5b68f8c00ee..f0f4d7545abe 100755 --- a/flags/long_test.ts +++ b/flags/long_test.ts @@ -9,11 +9,11 @@ Deno.test(function longOpts(): void { assertEquals(parse(["--host", "localhost", "--port", "555"]), { host: "localhost", port: 555, - _: [] + _: [], }); assertEquals(parse(["--host=localhost", "--port=555"]), { host: "localhost", port: 555, - _: [] + _: [], }); }); diff --git a/flags/mod.ts b/flags/mod.ts index 18727a66544b..b334cb5b8aaf 100644 --- a/flags/mod.ts +++ b/flags/mod.ts @@ -85,7 +85,7 @@ function isNumber(x: unknown): boolean { function hasKey(obj: NestedMapping, keys: string[]): boolean { let o = obj; - keys.slice(0, -1).forEach(key => { + keys.slice(0, -1).forEach((key) => { o = (get(o, key) ?? {}) as NestedMapping; }); @@ -107,14 +107,14 @@ export function parse( default: defaults = {}, stopEarly = false, string = [], - unknown = (i: unknown): unknown => i + unknown = (i: unknown): unknown => i, }: ArgParsingOptions = {} ): Args { const flags: Flags = { bools: {}, strings: {}, unknownFn: unknown, - allBools: false + allBools: false, }; if (boolean !== undefined) { @@ -139,7 +139,7 @@ export function parse( aliases[key] = val; } for (const alias of getForce(aliases, key)) { - aliases[alias] = [key].concat(aliases[key].filter(y => alias !== y)); + aliases[alias] = [key].concat(aliases[key].filter((y) => alias !== y)); } } } @@ -171,7 +171,7 @@ export function parse( function setKey(obj: NestedMapping, keys: string[], value: unknown): void { let o = obj; - keys.slice(0, -1).forEach(function(key): void { + keys.slice(0, -1).forEach(function (key): void { if (get(o, key) === undefined) { o[key] = {}; } @@ -214,7 +214,7 @@ export function parse( function aliasIsBoolean(key: string): boolean { return getForce(aliases, key).some( - x => typeof get(flags.bools, x) === "boolean" + (x) => typeof get(flags.bools, x) === "boolean" ); } diff --git a/flags/num_test.ts b/flags/num_test.ts index 0d6b634b9da5..f8a0d11ac5da 100755 --- a/flags/num_test.ts +++ b/flags/num_test.ts @@ -14,7 +14,7 @@ Deno.test(function nums(): void { "10f", "--hex", "0xdeadbeef", - "789" + "789", ]); assertEquals(argv, { x: 1234, @@ -22,7 +22,7 @@ Deno.test(function nums(): void { z: 1e7, w: "10f", hex: 0xdeadbeef, - _: [789] + _: [789], }); assertEquals(typeof argv.x, "number"); assertEquals(typeof argv.y, "number"); diff --git a/flags/parse_test.ts b/flags/parse_test.ts index cd93c1f810b1..abba42e16b8e 100755 --- a/flags/parse_test.ts +++ b/flags/parse_test.ts @@ -6,7 +6,7 @@ Deno.test(function parseArgs(): void { assertEquals(parse(["--no-moo"]), { moo: false, _: [] }); assertEquals(parse(["-v", "a", "-v", "b", "-v", "c"]), { v: ["a", "b", "c"], - _: [] + _: [], }); }); @@ -28,7 +28,7 @@ Deno.test(function comprehensive(): void { "--multi=baz", "--", "--not-a-flag", - "eek" + "eek", ]), { c: true, @@ -42,7 +42,7 @@ Deno.test(function comprehensive(): void { multi: ["quux", "baz"], meep: false, name: "meowmers", - _: ["bare", "--not-a-flag", "eek"] + _: ["bare", "--not-a-flag", "eek"], } ); }); @@ -56,13 +56,13 @@ Deno.test(function flagBoolean(): void { Deno.test(function flagBooleanValue(): void { const argv = parse(["--verbose", "false", "moo", "-t", "true"], { boolean: ["t", "verbose"], - default: { verbose: true } + default: { verbose: true }, }); assertEquals(argv, { verbose: false, t: true, - _: ["moo"] + _: ["moo"], }); assertEquals(typeof argv.verbose, "boolean"); @@ -110,7 +110,7 @@ Deno.test(function emptyStrings(): void { assertEquals(typeof str, "string"); const letters = parse(["-art"], { - string: ["a", "t"] + string: ["a", "t"], }); assertEquals(letters.a, ""); @@ -121,7 +121,7 @@ Deno.test(function emptyStrings(): void { Deno.test(function stringAndAlias(): void { const x = parse(["--str", "000123"], { string: "s", - alias: { s: "str" } + alias: { s: "str" }, }); assertEquals(x.str, "000123"); @@ -131,7 +131,7 @@ Deno.test(function stringAndAlias(): void { const y = parse(["-s", "000123"], { string: "str", - alias: { str: "s" } + alias: { str: "s" }, }); assertEquals(y.str, "000123"); @@ -146,13 +146,13 @@ Deno.test(function slashBreak(): void { x: true, y: true, z: "/foo/bar/baz", - _: [] + _: [], }); }); Deno.test(function alias(): void { const argv = parse(["-f", "11", "--zoom", "55"], { - alias: { z: "zoom" } + alias: { z: "zoom" }, }); assertEquals(argv.zoom, 55); assertEquals(argv.z, argv.zoom); @@ -161,7 +161,7 @@ Deno.test(function alias(): void { Deno.test(function multiAlias(): void { const argv = parse(["-f", "11", "--zoom", "55"], { - alias: { z: ["zm", "zoom"] } + alias: { z: ["zm", "zoom"] }, }); assertEquals(argv.zoom, 55); assertEquals(argv.z, argv.zoom); @@ -178,7 +178,7 @@ Deno.test(function nestedDottedObjects(): void { "--foo.quux.quibble", "5", "--foo.quux.oO", - "--beep.boop" + "--beep.boop", ]); assertEquals(argv.foo, { @@ -186,8 +186,8 @@ Deno.test(function nestedDottedObjects(): void { baz: 4, quux: { quibble: 5, - oO: true - } + oO: true, + }, }); assertEquals(argv.beep, { boop: true }); }); diff --git a/flags/short_test.ts b/flags/short_test.ts index d7171b920d99..6305bbb94423 100755 --- a/flags/short_test.ts +++ b/flags/short_test.ts @@ -16,13 +16,13 @@ Deno.test(function short(): void { a: true, t: true, s: "meow", - _: [] + _: [], }); assertEquals(parse(["-h", "localhost"]), { h: "localhost", _: [] }); assertEquals(parse(["-h", "localhost", "-p", "555"]), { h: "localhost", p: 555, - _: [] + _: [], }); }); @@ -31,7 +31,7 @@ Deno.test(function mixedShortBoolAndCapture(): void { f: true, p: 555, h: "localhost", - _: ["script.js"] + _: ["script.js"], }); }); @@ -40,6 +40,6 @@ Deno.test(function shortAndLong(): void { f: true, p: 555, h: "localhost", - _: ["script.js"] + _: ["script.js"], }); }); diff --git a/flags/stop_early_test.ts b/flags/stop_early_test.ts index d1996e7aa04a..4b7eac097f6b 100755 --- a/flags/stop_early_test.ts +++ b/flags/stop_early_test.ts @@ -5,11 +5,11 @@ import { parse } from "./mod.ts"; // stops parsing on the first non-option when stopEarly is set Deno.test(function stopParsing(): void { const argv = parse(["--aaa", "bbb", "ccc", "--ddd"], { - stopEarly: true + stopEarly: true, }); assertEquals(argv, { aaa: "bbb", - _: ["ccc", "--ddd"] + _: ["ccc", "--ddd"], }); }); diff --git a/flags/unknown_test.ts b/flags/unknown_test.ts index acbb131ee6be..90c638b67b86 100755 --- a/flags/unknown_test.ts +++ b/flags/unknown_test.ts @@ -13,7 +13,7 @@ Deno.test(function booleanAndAliasIsNotUnknown(): void { const opts = { alias: { h: "herp" }, boolean: "h", - unknown: unknownFn + unknown: unknownFn, }; parse(aliased, opts); parse(regular, opts); @@ -29,12 +29,12 @@ Deno.test(function flagBooleanTrueAnyDoubleHyphenArgumentIsNotUnknown(): void { } const argv = parse(["--honk", "--tacos=good", "cow", "-p", "55"], { boolean: true, - unknown: unknownFn + unknown: unknownFn, }); assertEquals(unknown, ["--tacos=good", "cow", "-p"]); assertEquals(argv, { honk: true, - _: [] + _: [], }); }); @@ -49,7 +49,7 @@ Deno.test(function stringAndAliasIsNotUnkown(): void { const opts = { alias: { h: "herp" }, string: "h", - unknown: unknownFn + unknown: unknownFn, }; parse(aliased, opts); parse(regular, opts); @@ -68,7 +68,7 @@ Deno.test(function defaultAndAliasIsNotUnknown(): void { const opts = { default: { h: "bar" }, alias: { h: "herp" }, - unknown: unknownFn + unknown: unknownFn, }; parse(aliased, opts); parse(regular, opts); @@ -85,13 +85,13 @@ Deno.test(function valueFollowingDoubleHyphenIsNotUnknown(): void { const aliased = ["--bad", "--", "good", "arg"]; const opts = { "--": true, - unknown: unknownFn + unknown: unknownFn, }; const argv = parse(aliased, opts); assertEquals(unknown, ["--bad"]); assertEquals(argv, { "--": ["good", "arg"], - _: [] + _: [], }); }); diff --git a/fmt/colors.ts b/fmt/colors.ts index 9476ce076a28..ad2a6a1bea54 100644 --- a/fmt/colors.ts +++ b/fmt/colors.ts @@ -37,7 +37,7 @@ function code(open: number, close: number): Code { return { open: `\x1b[${open}m`, close: `\x1b[${close}m`, - regexp: new RegExp(`\\x1b\\[${close}m`, "g") + regexp: new RegExp(`\\x1b\\[${close}m`, "g"), }; } diff --git a/fmt/sprintf.ts b/fmt/sprintf.ts index dd7ac7f55e4f..d79b9095e1ef 100644 --- a/fmt/sprintf.ts +++ b/fmt/sprintf.ts @@ -3,11 +3,11 @@ enum State { PERCENT, POSITIONAL, PRECISION, - WIDTH + WIDTH, } enum WorP { WIDTH, - PRECISION + PRECISION, } class Flags { @@ -34,7 +34,7 @@ enum F { mantissa, fractional, esign, - exponent + exponent, } class Printf { diff --git a/fmt/sprintf_test.ts b/fmt/sprintf_test.ts index 917878bc169a..24d0b4727c78 100644 --- a/fmt/sprintf_test.ts +++ b/fmt/sprintf_test.ts @@ -229,7 +229,6 @@ const tests: Array<[string, any, string]> = [ ["%d", 12345, "12345"], ["%v", 12345, "12345"], ["%t", true, "true"], - // basic string ["%s", "abc", "abc"], // ["%q", "abc", `"abc"`], // TODO: need %q? @@ -248,7 +247,6 @@ const tests: Array<[string, any, string]> = [ ["%#X", "xyz", "0X78797A"], ["%# x", "xyz", "0x78 0x79 0x7a"], ["%# X", "xyz", "0X78 0X79 0X7A"], - // basic bytes : TODO special handling for Buffer? other std types? // escaped strings : TODO decide whether to have %q @@ -261,7 +259,6 @@ const tests: Array<[string, any, string]> = [ ["%.0c", "⌘".charCodeAt(0), "⌘"], ["%3c", "⌘".charCodeAt(0), " ⌘"], ["%-3c", "⌘".charCodeAt(0), "⌘ "], - // Runes that are not printable. // {"%c", '\U00000e00', "\u0e00"}, // TODO check if \U escape exists in js //["%c", '\U0010ffff'.codePointAt(0), "\U0010ffff"], @@ -273,7 +270,6 @@ const tests: Array<[string, any, string]> = [ // ["%c", 0xDC80, "�"], ["%c", 0x110000, "�"], ["%c", 0xfffffffff, "�"], - // TODO // escaped characters // Runes that are not printable. @@ -351,7 +347,6 @@ const tests: Array<[string, any, string]> = [ ["%-#20.8x", 0x1234abc, "0x01234abc "], ["%-#20.8X", 0x1234abc, "0X01234ABC "], ["%-#20.8o", parseInt("01234", 8), "00001234 "], - // Test correct f.intbuf overflow checks. // TODO, lazy // unicode format // TODO, decide whether unicode verb makes sense %U @@ -433,7 +428,6 @@ const tests: Array<[string, any, string]> = [ ["%+020e", Number.POSITIVE_INFINITY, " +Inf"], ["%-020f", Number.NEGATIVE_INFINITY, "-Inf "], ["%-020E", NaN, "NaN "], - // complex values // go specific // old test/fmt_test.go ["%e", 1.0, "1.000000e+00"], @@ -490,7 +484,6 @@ const tests: Array<[string, any, string]> = [ ["%g", 1.23456789e-3, "0.00123457"], // see above prec6 = precdef6 - (-3+1) //["%g", 1.23456789e20, "1.23456789e+20"], ["%g", 1.23456789e20, "1.23457e+20"], - // arrays // TODO // slice : go specific @@ -527,7 +520,6 @@ const tests: Array<[string, any, string]> = [ ["% -010X", "\xab", "AB "], ["%#-10X", "\xab\xcd", "0XABCD "], ["%# -010X", "\xab\xcd", "0XAB 0XCD "], - // renamings // Formatter // GoStringer @@ -541,7 +533,6 @@ const tests: Array<[string, any, string]> = [ ["%T", S, "function"], ["%T", true, "boolean"], ["%T", Symbol(), "symbol"], - // %p with pointers // erroneous things @@ -582,7 +573,7 @@ const tests: Array<[string, any, string]> = [ ["%+07.2f", 1.0, "+001.00"], ["%+07.2f", -1.0, "-001.00"], ["% +07.2f", 1.0, "+001.00"], - ["% +07.2f", -1.0, "-001.00"] + ["% +07.2f", -1.0, "-001.00"], ]; Deno.test(function testThorough(): void { diff --git a/fs/README.md b/fs/README.md index 56c190ccc148..8c69faa7635e 100644 --- a/fs/README.md +++ b/fs/README.md @@ -52,7 +52,7 @@ created. ```ts import { ensureSymlink, - ensureSymlinkSync + ensureSymlinkSync, } from "https://deno.land/std/fs/mod.ts"; ensureSymlink( @@ -110,7 +110,7 @@ import { globToRegExp } from "https://deno.land/std/fs/mod.ts"; globToRegExp("foo/**/*.json", { flags: "g", extended: true, - globstar: true + globstar: true, }); // returns the regex to find all .json files in the folder foo ``` @@ -212,7 +212,7 @@ Write the string to file. ```ts import { writeFileStr, - writeFileStrSync + writeFileStrSync, } from "https://deno.land/std/fs/mod.ts"; writeFileStr("./target.dat", "file content"); // returns a promise diff --git a/fs/copy_test.ts b/fs/copy_test.ts index 9ba5f2b2135d..0fbc90579279 100644 --- a/fs/copy_test.ts +++ b/fs/copy_test.ts @@ -3,7 +3,7 @@ import { assertEquals, assertThrows, assertThrowsAsync, - assert + assert, } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { copy, copySync } from "./copy.ts"; @@ -22,11 +22,11 @@ function testCopy(name: string, cb: (tempDir: string) => Promise): void { name, async fn(): Promise { const tempDir = await Deno.makeTempDir({ - prefix: "deno_std_copy_async_test_" + prefix: "deno_std_copy_async_test_", }); await cb(tempDir); await Deno.remove(tempDir, { recursive: true }); - } + }, }); } @@ -35,11 +35,11 @@ function testCopySync(name: string, cb: (tempDir: string) => void): void { name, fn: (): void => { const tempDir = Deno.makeTempDirSync({ - prefix: "deno_std_copy_sync_test_" + prefix: "deno_std_copy_sync_test_", }); cb(tempDir); Deno.removeSync(tempDir, { recursive: true }); - } + }, }); } @@ -149,7 +149,7 @@ testCopy( // Copy with overwrite and preserve timestamps options. await copy(srcFile, destFile, { overwrite: true, - preserveTimestamps: true + preserveTimestamps: true, }); const destStatInfo = await Deno.stat(destFile); @@ -333,7 +333,7 @@ testCopySync( // Copy with overwrite and preserve timestamps options. copySync(srcFile, destFile, { overwrite: true, - preserveTimestamps: true + preserveTimestamps: true, }); const destStatInfo = Deno.statSync(destFile); diff --git a/fs/empty_dir_test.ts b/fs/empty_dir_test.ts index 7015516ab0f0..f30f434dfa81 100644 --- a/fs/empty_dir_test.ts +++ b/fs/empty_dir_test.ts @@ -4,7 +4,7 @@ import { assertEquals, assertStrContains, assertThrows, - assertThrowsAsync + assertThrowsAsync, } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { emptyDir, emptyDirSync } from "./empty_dir.ts"; @@ -137,59 +137,59 @@ const scenes: Scenes[] = [ read: false, write: false, async: true, - output: "run again with the --allow-read flag" + output: "run again with the --allow-read flag", }, { read: false, write: false, async: false, - output: "run again with the --allow-read flag" + output: "run again with the --allow-read flag", }, // 2 { read: true, write: false, async: true, - output: "run again with the --allow-write flag" + output: "run again with the --allow-write flag", }, { read: true, write: false, async: false, - output: "run again with the --allow-write flag" + output: "run again with the --allow-write flag", }, // 3 { read: false, write: true, async: true, - output: "run again with the --allow-read flag" + output: "run again with the --allow-read flag", }, { read: false, write: true, async: false, - output: "run again with the --allow-read flag" + output: "run again with the --allow-read flag", }, // 4 { read: true, write: true, async: true, - output: "success" + output: "success", }, { read: true, write: true, async: false, - output: "success" - } + output: "success", + }, ]; for (const s of scenes) { let title = `test ${s.async ? "emptyDir" : "emptyDirSync"}`; title += `("testdata/testfolder") ${s.read ? "with" : "without"}`; title += ` --allow-read & ${s.write ? "with" : "without"} --allow-write`; - Deno.test(`[fs] emptyDirPermission ${title}`, async function(): Promise< + Deno.test(`[fs] emptyDirPermission ${title}`, async function (): Promise< void > { const testfolder = path.join(testdataDir, "testfolder"); @@ -221,7 +221,7 @@ for (const s of scenes) { const p = Deno.run({ stdout: "piped", cwd: testdataDir, - cmd: args + cmd: args, }); assert(p.stdout); diff --git a/fs/ensure_link_test.ts b/fs/ensure_link_test.ts index 7549814a25d9..3c7720dc0b66 100644 --- a/fs/ensure_link_test.ts +++ b/fs/ensure_link_test.ts @@ -3,7 +3,7 @@ import { assertEquals, assertThrows, - assertThrowsAsync + assertThrowsAsync, } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { ensureLink, ensureLinkSync } from "./ensure_link.ts"; diff --git a/fs/ensure_symlink_test.ts b/fs/ensure_symlink_test.ts index f0dc4fbe491b..5188dc0354e5 100644 --- a/fs/ensure_symlink_test.ts +++ b/fs/ensure_symlink_test.ts @@ -3,7 +3,7 @@ import { assertEquals, assertThrows, - assertThrowsAsync + assertThrowsAsync, } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts"; diff --git a/fs/eol.ts b/fs/eol.ts index d4bb8032c6a4..2f15be269e00 100644 --- a/fs/eol.ts +++ b/fs/eol.ts @@ -3,7 +3,7 @@ /** EndOfLine character enum */ export enum EOL { LF = "\n", - CRLF = "\r\n" + CRLF = "\r\n", } const regDetect = /(?:\r?\n)/g; diff --git a/fs/eol_test.ts b/fs/eol_test.ts index aa2dcf3953ed..35b3e0d9ae80 100644 --- a/fs/eol_test.ts +++ b/fs/eol_test.ts @@ -12,21 +12,21 @@ Deno.test({ name: "[EOL] Detect CR LF", fn(): void { assertEquals(detect(CRLFinput), EOL.CRLF); - } + }, }); Deno.test({ name: "[EOL] Detect LF", fn(): void { assertEquals(detect(LFinput), EOL.LF); - } + }, }); Deno.test({ name: "[EOL] Detect No New Line", fn(): void { assertEquals(detect(NoNLinput), null); - } + }, }); Deno.test({ @@ -34,7 +34,7 @@ Deno.test({ fn(): void { assertEquals(detect(Mixedinput), EOL.CRLF); assertEquals(detect(Mixedinput2), EOL.CRLF); - } + }, }); Deno.test({ @@ -50,5 +50,5 @@ Deno.test({ assertEquals(format(Mixedinput, EOL.LF), LFinput); assertEquals(format(Mixedinput2, EOL.CRLF), CRLFinput); assertEquals(format(Mixedinput2, EOL.LF), LFinput); - } + }, }); diff --git a/fs/exists_test.ts b/fs/exists_test.ts index 1f296538c6e1..04c58d8d6569 100644 --- a/fs/exists_test.ts +++ b/fs/exists_test.ts @@ -5,7 +5,7 @@ import { exists, existsSync } from "./exists.ts"; const testdataDir = path.resolve("fs", "testdata"); -Deno.test("[fs] existsFile", async function(): Promise { +Deno.test("[fs] existsFile", async function (): Promise { assertEquals( await exists(path.join(testdataDir, "not_exist_file.ts")), false @@ -13,12 +13,12 @@ Deno.test("[fs] existsFile", async function(): Promise { assertEquals(await existsSync(path.join(testdataDir, "0.ts")), true); }); -Deno.test("[fs] existsFileSync", function(): void { +Deno.test("[fs] existsFileSync", function (): void { assertEquals(existsSync(path.join(testdataDir, "not_exist_file.ts")), false); assertEquals(existsSync(path.join(testdataDir, "0.ts")), true); }); -Deno.test("[fs] existsDirectory", async function(): Promise { +Deno.test("[fs] existsDirectory", async function (): Promise { assertEquals( await exists(path.join(testdataDir, "not_exist_directory")), false @@ -26,7 +26,7 @@ Deno.test("[fs] existsDirectory", async function(): Promise { assertEquals(existsSync(testdataDir), true); }); -Deno.test("[fs] existsDirectorySync", function(): void { +Deno.test("[fs] existsDirectorySync", function (): void { assertEquals( existsSync(path.join(testdataDir, "not_exist_directory")), false @@ -34,16 +34,16 @@ Deno.test("[fs] existsDirectorySync", function(): void { assertEquals(existsSync(testdataDir), true); }); -Deno.test("[fs] existsLinkSync", function(): void { +Deno.test("[fs] existsLinkSync", function (): void { // TODO(axetroy): generate link file use Deno api instead of set a link file // in repository - assertEquals(existsSync(path.join(testdataDir, "0-link.ts")), true); + assertEquals(existsSync(path.join(testdataDir, "0-link")), true); }); -Deno.test("[fs] existsLink", async function(): Promise { +Deno.test("[fs] existsLink", async function (): Promise { // TODO(axetroy): generate link file use Deno api instead of set a link file // in repository - assertEquals(await exists(path.join(testdataDir, "0-link.ts")), true); + assertEquals(await exists(path.join(testdataDir, "0-link")), true); }); interface Scenes { @@ -59,59 +59,59 @@ const scenes: Scenes[] = [ read: false, async: true, output: "run again with the --allow-read flag", - file: "0.ts" + file: "0.ts", }, { read: false, async: false, output: "run again with the --allow-read flag", - file: "0.ts" + file: "0.ts", }, // 2 { read: true, async: true, output: "exist", - file: "0.ts" + file: "0.ts", }, { read: true, async: false, output: "exist", - file: "0.ts" + file: "0.ts", }, // 3 { read: false, async: true, output: "run again with the --allow-read flag", - file: "no_exist_file_for_test.ts" + file: "no_exist_file_for_test.ts", }, { read: false, async: false, output: "run again with the --allow-read flag", - file: "no_exist_file_for_test.ts" + file: "no_exist_file_for_test.ts", }, // 4 { read: true, async: true, output: "not exist", - file: "no_exist_file_for_test.ts" + file: "no_exist_file_for_test.ts", }, { read: true, async: false, output: "not exist", - file: "no_exist_file_for_test.ts" - } + file: "no_exist_file_for_test.ts", + }, ]; for (const s of scenes) { let title = `test ${s.async ? "exists" : "existsSync"}("testdata/${s.file}")`; title += ` ${s.read ? "with" : "without"} --allow-read`; - Deno.test(`[fs] existsPermission ${title}`, async function(): Promise { + Deno.test(`[fs] existsPermission ${title}`, async function (): Promise { const args = [Deno.execPath(), "run"]; if (s.read) { @@ -124,7 +124,7 @@ for (const s of scenes) { const p = Deno.run({ stdout: "piped", cwd: testdataDir, - cmd: args + cmd: args, }); const output = await p.output(); diff --git a/fs/expand_glob.ts b/fs/expand_glob.ts index c6653eda1235..10a8c2c520ef 100644 --- a/fs/expand_glob.ts +++ b/fs/expand_glob.ts @@ -6,7 +6,7 @@ import { isGlob, isWindows, joinGlobs, - normalize + normalize, } from "../path/mod.ts"; import { WalkInfo, walk, walkSync } from "./walk.ts"; import { assert } from "../testing/asserts.ts"; @@ -38,7 +38,7 @@ function split(path: string): SplitPath { segments, isAbsolute: isAbsolute_, hasTrailingSep: !!path.match(new RegExp(`${s}$`)), - winRoot: isWindows && isAbsolute_ ? segments.shift() : undefined + winRoot: isWindows && isAbsolute_ ? segments.shift() : undefined, }; } @@ -59,7 +59,7 @@ export async function* expandGlob( exclude = [], includeDirs = true, extended = false, - globstar = false + globstar = false, }: ExpandGlobOptions = {} ): AsyncIterableIterator { const globOptions: GlobOptions = { extended, globstar }; @@ -110,7 +110,7 @@ export async function* expandGlob( } else if (globSegment == "**") { return yield* walk(walkInfo.filename, { includeFiles: false, - skip: excludePatterns + skip: excludePatterns, }); } yield* walk(walkInfo.filename, { @@ -119,9 +119,9 @@ export async function* expandGlob( globToRegExp( joinGlobs([walkInfo.filename, globSegment], globOptions), globOptions - ) + ), ], - skip: excludePatterns + skip: excludePatterns, }); } @@ -138,7 +138,7 @@ export async function* expandGlob( currentMatches = [...nextMatchMap].sort().map( ([filename, info]): WalkInfo => ({ filename, - info + info, }) ); } @@ -163,7 +163,7 @@ export function* expandGlobSync( exclude = [], includeDirs = true, extended = false, - globstar = false + globstar = false, }: ExpandGlobOptions = {} ): IterableIterator { const globOptions: GlobOptions = { extended, globstar }; @@ -214,7 +214,7 @@ export function* expandGlobSync( } else if (globSegment == "**") { return yield* walkSync(walkInfo.filename, { includeFiles: false, - skip: excludePatterns + skip: excludePatterns, }); } yield* walkSync(walkInfo.filename, { @@ -223,9 +223,9 @@ export function* expandGlobSync( globToRegExp( joinGlobs([walkInfo.filename, globSegment], globOptions), globOptions - ) + ), ], - skip: excludePatterns + skip: excludePatterns, }); } @@ -242,7 +242,7 @@ export function* expandGlobSync( currentMatches = [...nextMatchMap].sort().map( ([filename, info]): WalkInfo => ({ filename, - info + info, }) ); } diff --git a/fs/expand_glob_test.ts b/fs/expand_glob_test.ts index adc94c1e9f83..6be9c518f411 100644 --- a/fs/expand_glob_test.ts +++ b/fs/expand_glob_test.ts @@ -6,12 +6,12 @@ import { join, joinGlobs, normalize, - relative + relative, } from "../path/mod.ts"; import { ExpandGlobOptions, expandGlob, - expandGlobSync + expandGlobSync, } from "./expand_glob.ts"; async function expandGlobArray( @@ -48,7 +48,7 @@ const EG_OPTIONS: ExpandGlobOptions = { root: urlToFilePath(new URL(join("testdata", "glob"), import.meta.url)), includeDirs: true, extended: false, - globstar: false + globstar: false, }; Deno.test(async function expandGlobWildcard(): Promise { @@ -57,7 +57,7 @@ Deno.test(async function expandGlobWildcard(): Promise { "abc", "abcdef", "abcdefghi", - "subdir" + "subdir", ]); }); @@ -72,7 +72,7 @@ Deno.test(async function expandGlobParent(): Promise { "abc", "abcdef", "abcdefghi", - "subdir" + "subdir", ]); }); @@ -80,16 +80,16 @@ Deno.test(async function expandGlobExt(): Promise { const options = { ...EG_OPTIONS, extended: true }; assertEquals(await expandGlobArray("abc?(def|ghi)", options), [ "abc", - "abcdef" + "abcdef", ]); assertEquals(await expandGlobArray("abc*(def|ghi)", options), [ "abc", "abcdef", - "abcdefghi" + "abcdefghi", ]); assertEquals(await expandGlobArray("abc+(def|ghi)", options), [ "abcdef", - "abcdefghi" + "abcdefghi", ]); assertEquals(await expandGlobArray("abc@(def|ghi)", options), ["abcdef"]); assertEquals(await expandGlobArray("abc{def,ghi}", options), ["abcdef"]); @@ -123,7 +123,7 @@ Deno.test(async function expandGlobPermError(): Promise { cmd: [execPath(), exampleUrl.toString()], stdin: "null", stdout: "piped", - stderr: "piped" + stderr: "piped", }); assertEquals(await p.status(), { code: 1, success: false }); assertEquals(decode(await p.output()), ""); diff --git a/fs/move_test.ts b/fs/move_test.ts index b835e6dfa7ca..999b67cf0610 100644 --- a/fs/move_test.ts +++ b/fs/move_test.ts @@ -2,7 +2,7 @@ import { assertEquals, assertThrows, - assertThrowsAsync + assertThrowsAsync, } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { move, moveSync } from "./move.ts"; @@ -68,7 +68,7 @@ Deno.test(async function moveFileIfDestExists(): Promise { // write file content await Promise.all([ Deno.writeFile(srcFile, srcContent), - Deno.writeFile(destFile, destContent) + Deno.writeFile(destFile, destContent), ]); // make sure the test file have been created @@ -100,7 +100,7 @@ Deno.test(async function moveFileIfDestExists(): Promise { // clean up await Promise.all([ Deno.remove(srcDir, { recursive: true }), - Deno.remove(destDir, { recursive: true }) + Deno.remove(destDir, { recursive: true }), ]); }); @@ -141,13 +141,13 @@ Deno.test(async function moveIfSrcAndDestDirectoryExistsAndOverwrite(): Promise< await Promise.all([ Deno.mkdir(srcDir, { recursive: true }), - Deno.mkdir(destDir, { recursive: true }) + Deno.mkdir(destDir, { recursive: true }), ]); assertEquals(await exists(srcDir), true); assertEquals(await exists(destDir), true); await Promise.all([ Deno.writeFile(srcFile, srcContent), - Deno.writeFile(destFile, destContent) + Deno.writeFile(destFile, destContent), ]); await move(srcDir, destDir, { overwrite: true }); diff --git a/fs/read_json_test.ts b/fs/read_json_test.ts index c394963b0fb0..bdb5edbe5b68 100644 --- a/fs/read_json_test.ts +++ b/fs/read_json_test.ts @@ -2,7 +2,7 @@ import { assertEquals, assertThrowsAsync, - assertThrows + assertThrows, } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { readJson, readJsonSync } from "./read_json.ts"; diff --git a/fs/testdata/0-link b/fs/testdata/0-link new file mode 120000 index 000000000000..937f1e899f79 --- /dev/null +++ b/fs/testdata/0-link @@ -0,0 +1 @@ +0.ts \ No newline at end of file diff --git a/fs/testdata/0-link.ts b/fs/testdata/0-link.ts deleted file mode 120000 index 24c6b8053c8e..000000000000 --- a/fs/testdata/0-link.ts +++ /dev/null @@ -1 +0,0 @@ -./fs/testdata/0.ts \ No newline at end of file diff --git a/fs/testdata/empty_dir.ts b/fs/testdata/empty_dir.ts index aa9cf60a175e..f8fcc1cebee6 100644 --- a/fs/testdata/empty_dir.ts +++ b/fs/testdata/empty_dir.ts @@ -2,8 +2,8 @@ import { emptyDir } from "../empty_dir.ts"; emptyDir(Deno.args[0]) .then(() => { - Deno.stdout.write(new TextEncoder().encode("success")) + Deno.stdout.write(new TextEncoder().encode("success")); }) .catch((err) => { - Deno.stdout.write(new TextEncoder().encode(err.message)) - }) \ No newline at end of file + Deno.stdout.write(new TextEncoder().encode(err.message)); + }); diff --git a/fs/testdata/exists_sync.ts b/fs/testdata/exists_sync.ts index 27dee268b63b..8cc51e9f8a33 100644 --- a/fs/testdata/exists_sync.ts +++ b/fs/testdata/exists_sync.ts @@ -1,10 +1,8 @@ import { existsSync } from "../exists.ts"; try { - const isExist = existsSync(Deno.args[0]) - Deno.stdout.write(new TextEncoder().encode(isExist ? 'exist' :'not exist')) + const isExist = existsSync(Deno.args[0]); + Deno.stdout.write(new TextEncoder().encode(isExist ? "exist" : "not exist")); } catch (err) { - Deno.stdout.write(new TextEncoder().encode(err.message)) + Deno.stdout.write(new TextEncoder().encode(err.message)); } - - diff --git a/fs/utils_test.ts b/fs/utils_test.ts index 93f4664e7df7..95686d8243c5 100644 --- a/fs/utils_test.ts +++ b/fs/utils_test.ts @@ -17,10 +17,10 @@ Deno.test(function _isSubdir(): void { ["first", "first/second", true, path.posix.sep], ["../first", "../first/second", true, path.posix.sep], ["c:\\first", "c:\\first", false, path.win32.sep], - ["c:\\first", "c:\\first\\second", true, path.win32.sep] + ["c:\\first", "c:\\first\\second", true, path.win32.sep], ]; - pairs.forEach(function(p): void { + pairs.forEach(function (p): void { const src = p[0] as string; const dest = p[1] as string; const expected = p[2] as boolean; @@ -36,10 +36,10 @@ Deno.test(function _isSubdir(): void { Deno.test(function _getFileInfoType(): void { const pairs = [ [path.join(testdataDir, "file_type_1"), "file"], - [path.join(testdataDir, "file_type_dir_1"), "dir"] + [path.join(testdataDir, "file_type_dir_1"), "dir"], ]; - pairs.forEach(function(p): void { + pairs.forEach(function (p): void { const filePath = p[0] as string; const type = p[1] as PathType; switch (type) { diff --git a/fs/walk.ts b/fs/walk.ts index fbd14740b68e..3f178c0c568f 100644 --- a/fs/walk.ts +++ b/fs/walk.ts @@ -67,7 +67,7 @@ export async function* walk( followSymlinks = false, exts = undefined, match = undefined, - skip = undefined + skip = undefined, }: WalkOptions = {} ): AsyncIterableIterator { if (maxDepth < 0) { @@ -105,7 +105,7 @@ export async function* walk( followSymlinks, exts, match, - skip + skip, }); } } @@ -121,7 +121,7 @@ export function* walkSync( followSymlinks = false, exts = undefined, match = undefined, - skip = undefined + skip = undefined, }: WalkOptions = {} ): IterableIterator { if (maxDepth < 0) { @@ -158,7 +158,7 @@ export function* walkSync( followSymlinks, exts, match, - skip + skip, }); } } diff --git a/fs/write_json_test.ts b/fs/write_json_test.ts index 09fa05d604a9..335d35bfe06c 100644 --- a/fs/write_json_test.ts +++ b/fs/write_json_test.ts @@ -2,7 +2,7 @@ import { assertEquals, assertThrowsAsync, - assertThrows + assertThrows, } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { writeJson, writeJsonSync } from "./write_json.ts"; @@ -108,7 +108,7 @@ Deno.test(async function writeJsonWithReplacer(): Promise { existsJsonFile, { a: "1", b: "2", c: "3" }, { - replacer: ["a"] + replacer: ["a"], } ); throw new Error("should write success"); @@ -226,7 +226,7 @@ Deno.test(function writeJsonWithReplacer(): void { existsJsonFile, { a: "1", b: "2", c: "3" }, { - replacer: ["a"] + replacer: ["a"], } ); throw new Error("should write success"); diff --git a/http/cookie.ts b/http/cookie.ts index 10c9bd689a02..062019f14eea 100644 --- a/http/cookie.ts +++ b/http/cookie.ts @@ -130,6 +130,6 @@ export function delCookie(res: Response, name: string): void { setCookie(res, { name: name, value: "", - expires: new Date(0) + expires: new Date(0), }); } diff --git a/http/cookie_test.ts b/http/cookie_test.ts index 8ab862bb3a2a..1b78b2bff2a9 100644 --- a/http/cookie_test.ts +++ b/http/cookie_test.ts @@ -27,9 +27,9 @@ test({ assertEquals(getCookies(req), { PREF: "al=en-GB&f1=123", wide: "1", - SID: "123" + SID: "123", }); - } + }, }); test({ @@ -41,7 +41,7 @@ test({ res.headers?.get("Set-Cookie"), "deno=; Expires=Thu, 01 Jan 1970 00:00:00 GMT" ); - } + }, }); test({ @@ -66,7 +66,7 @@ test({ name: "Space", value: "Cat", httpOnly: true, - secure: true + secure: true, }); assertEquals(res.headers.get("Set-Cookie"), "Space=Cat; Secure; HttpOnly"); @@ -76,7 +76,7 @@ test({ value: "Cat", httpOnly: true, secure: true, - maxAge: 2 + maxAge: 2, }); assertEquals( res.headers.get("Set-Cookie"), @@ -91,7 +91,7 @@ test({ value: "Cat", httpOnly: true, secure: true, - maxAge: 0 + maxAge: 0, }); } catch (e) { error = true; @@ -105,7 +105,7 @@ test({ httpOnly: true, secure: true, maxAge: 2, - domain: "deno.land" + domain: "deno.land", }); assertEquals( res.headers.get("Set-Cookie"), @@ -120,7 +120,7 @@ test({ secure: true, maxAge: 2, domain: "deno.land", - sameSite: "Strict" + sameSite: "Strict", }); assertEquals( res.headers.get("Set-Cookie"), @@ -136,7 +136,7 @@ test({ secure: true, maxAge: 2, domain: "deno.land", - sameSite: "Lax" + sameSite: "Lax", }); assertEquals( res.headers.get("Set-Cookie"), @@ -151,7 +151,7 @@ test({ secure: true, maxAge: 2, domain: "deno.land", - path: "/" + path: "/", }); assertEquals( res.headers.get("Set-Cookie"), @@ -167,7 +167,7 @@ test({ maxAge: 2, domain: "deno.land", path: "/", - unparsed: ["unparsed=keyvalue", "batman=Bruce"] + unparsed: ["unparsed=keyvalue", "batman=Bruce"], }); assertEquals( res.headers.get("Set-Cookie"), @@ -184,7 +184,7 @@ test({ maxAge: 2, domain: "deno.land", path: "/", - expires: new Date(Date.UTC(1983, 0, 7, 15, 32)) + expires: new Date(Date.UTC(1983, 0, 7, 15, 32)), }); assertEquals( res.headers.get("Set-Cookie"), @@ -200,11 +200,11 @@ test({ setCookie(res, { name: "__Host-Kitty", value: "Meow", - domain: "deno.land" + domain: "deno.land", }); assertEquals( res.headers.get("Set-Cookie"), "__Host-Kitty=Meow; Secure; Path=/" ); - } + }, }); diff --git a/http/file_server.ts b/http/file_server.ts index 20d5d61e64ec..5582afd076f3 100755 --- a/http/file_server.ts +++ b/http/file_server.ts @@ -108,7 +108,7 @@ async function serveFile( const res = { status: 200, body: file, - headers + headers, }; return res; } @@ -137,7 +137,7 @@ async function serveDir( mode: modeToString(fileInfo.isDirectory(), mode), size: fileInfo.isFile() ? fileLenToString(fileInfo.size) : "", name: fileInfo.name ?? "", - url: fileUrl + url: fileUrl, }); } listEntry.sort((a, b) => @@ -152,7 +152,7 @@ async function serveDir( const res = { status: 200, body: page, - headers + headers, }; setContentLength(res); return res; @@ -162,12 +162,12 @@ function serveFallback(req: ServerRequest, e: Error): Promise { if (e instanceof Deno.errors.NotFound) { return Promise.resolve({ status: 404, - body: encoder.encode("Not found") + body: encoder.encode("Not found"), }); } else { return Promise.resolve({ status: 500, - body: encoder.encode("Internal server error") + body: encoder.encode("Internal server error"), }); } } @@ -258,19 +258,20 @@ function dirViewerTemplate(dirname: string, entries: EntryInfo[]): string { Name ${entries.map( - entry => html` - - - ${entry.mode} - - - ${entry.size} - - - ${entry.name} - - - ` + (entry) => + html` + + + ${entry.mode} + + + ${entry.size} + + + ${entry.name} + + + ` )} diff --git a/http/file_server_test.ts b/http/file_server_test.ts index fcf776ea29e6..3a3817ce0662 100644 --- a/http/file_server_test.ts +++ b/http/file_server_test.ts @@ -14,10 +14,10 @@ async function startFileServer(): Promise { "--allow-net", "http/file_server.ts", ".", - "--cors" + "--cors", ], stdout: "piped", - stderr: "null" + stderr: "null", }); // Once fileServer is ready it will write to its stdout. assert(fileServer.stdout != null); @@ -106,7 +106,7 @@ test(async function servePermissionDenied(): Promise { const deniedServer = Deno.run({ cmd: [Deno.execPath(), "run", "--allow-net", "http/file_server.ts"], stdout: "piped", - stderr: "piped" + stderr: "piped", }); assert(deniedServer.stdout != null); const reader = new TextProtoReader(new BufReader(deniedServer.stdout)); @@ -132,7 +132,7 @@ test(async function servePermissionDenied(): Promise { test(async function printHelp(): Promise { const helpProcess = Deno.run({ cmd: [Deno.execPath(), "run", "http/file_server.ts", "--help"], - stdout: "piped" + stdout: "piped", }); assert(helpProcess.stdout != null); const r = new TextProtoReader(new BufReader(helpProcess.stdout)); diff --git a/http/http_bench.ts b/http/http_bench.ts index 9d191283170c..15f2233233e4 100644 --- a/http/http_bench.ts +++ b/http/http_bench.ts @@ -9,7 +9,7 @@ console.log(`http://${addr}/`); for await (const req of server) { const res = { body, - headers: new Headers() + headers: new Headers(), }; res.headers.set("Date", new Date().toUTCString()); res.headers.set("Connection", "keep-alive"); diff --git a/http/http_status.ts b/http/http_status.ts index ead1e1ff0e2c..ce4338705c14 100644 --- a/http/http_status.ts +++ b/http/http_status.ts @@ -125,14 +125,13 @@ export enum Status { /** RFC 2774, 7 */ NotExtended = 510, /** RFC 6585, 6 */ - NetworkAuthenticationRequired = 511 + NetworkAuthenticationRequired = 511, } export const STATUS_TEXT = new Map([ [Status.Continue, "Continue"], [Status.SwitchingProtocols, "Switching Protocols"], [Status.Processing, "Processing"], - [Status.OK, "OK"], [Status.Created, "Created"], [Status.Accepted, "Accepted"], @@ -143,7 +142,6 @@ export const STATUS_TEXT = new Map([ [Status.MultiStatus, "Multi-Status"], [Status.AlreadyReported, "Already Reported"], [Status.IMUsed, "IM Used"], - [Status.MultipleChoices, "Multiple Choices"], [Status.MovedPermanently, "Moved Permanently"], [Status.Found, "Found"], @@ -152,7 +150,6 @@ export const STATUS_TEXT = new Map([ [Status.UseProxy, "Use Proxy"], [Status.TemporaryRedirect, "Temporary Redirect"], [Status.PermanentRedirect, "Permanent Redirect"], - [Status.BadRequest, "Bad Request"], [Status.Unauthorized, "Unauthorized"], [Status.PaymentRequired, "Payment Required"], @@ -181,7 +178,6 @@ export const STATUS_TEXT = new Map([ [Status.TooManyRequests, "Too Many Requests"], [Status.RequestHeaderFieldsTooLarge, "Request Header Fields Too Large"], [Status.UnavailableForLegalReasons, "Unavailable For Legal Reasons"], - [Status.InternalServerError, "Internal Server Error"], [Status.NotImplemented, "Not Implemented"], [Status.BadGateway, "Bad Gateway"], @@ -192,5 +188,5 @@ export const STATUS_TEXT = new Map([ [Status.InsufficientStorage, "Insufficient Storage"], [Status.LoopDetected, "Loop Detected"], [Status.NotExtended, "Not Extended"], - [Status.NetworkAuthenticationRequired, "Network Authentication Required"] + [Status.NetworkAuthenticationRequired, "Network Authentication Required"], ]); diff --git a/http/io.ts b/http/io.ts index 6d5d1f66537c..2875be44fd65 100644 --- a/http/io.ts +++ b/http/io.ts @@ -9,7 +9,7 @@ export function emptyReader(): Deno.Reader { return { read(_: Uint8Array): Promise { return Promise.resolve(Deno.EOF); - } + }, }; } @@ -83,7 +83,7 @@ export function chunkedBodyReader(h: Headers, r: BufReader): Deno.Reader { } else { chunks.push({ offset: 0, - data: restChunk + data: restChunk, }); } return buf.byteLength; @@ -116,7 +116,7 @@ export function chunkedBodyReader(h: Headers, r: BufReader): Deno.Reader { const kProhibitedTrailerHeaders = [ "transfer-encoding", "content-length", - "trailer" + "trailer", ]; /** @@ -147,7 +147,7 @@ function parseTrailer(field: string | null): Set | undefined { if (field == null) { return undefined; } - const keys = field.split(",").map(v => v.trim()); + const keys = field.split(",").map((v) => v.trim()); if (keys.length === 0) { throw new Error("Empty trailer"); } @@ -196,7 +196,7 @@ export async function writeTrailers( const writer = BufWriter.create(w); const trailerHeaderFields = trailer .split(",") - .map(s => s.trim().toLowerCase()); + .map((s) => s.trim().toLowerCase()); for (const f of trailerHeaderFields) { assert( !kProhibitedTrailerHeaders.includes(f), diff --git a/http/io_test.ts b/http/io_test.ts index 6c96d0b95f70..7261964d07da 100644 --- a/http/io_test.ts +++ b/http/io_test.ts @@ -4,7 +4,7 @@ import { assertEquals, assert, assertNotEOF, - assertNotEquals + assertNotEquals, } from "../testing/asserts.ts"; import { bodyReader, @@ -12,7 +12,7 @@ import { readTrailers, parseHTTPVersion, readRequest, - writeResponse + writeResponse, } from "./io.ts"; import { encode, decode } from "../strings/mod.ts"; import { BufReader, ReadLineResult } from "../io/bufio.ts"; @@ -39,7 +39,7 @@ test("chunkedBodyReader", async () => { chunkify(5, "b"), chunkify(11, "c"), chunkify(22, "d"), - chunkify(0, "") + chunkify(0, ""), ].join(""); const h = new Headers(); const r = chunkedBodyReader(h, new BufReader(new Buffer(encode(body)))); @@ -64,10 +64,10 @@ test("chunkedBodyReader with trailers", async () => { chunkify(0, ""), "deno: land\r\n", "node: js\r\n", - "\r\n" + "\r\n", ].join(""); const h = new Headers({ - trailer: "deno,node" + trailer: "deno,node", }); const r = chunkedBodyReader(h, new BufReader(new Buffer(encode(body)))); assertEquals(h.has("trailer"), true); @@ -83,7 +83,7 @@ test("chunkedBodyReader with trailers", async () => { test("readTrailers", async () => { const h = new Headers({ - trailer: "deno,node" + trailer: "deno,node", }); const trailer = ["deno: land", "node: js", "", ""].join("\r\n"); await readTrailers(h, new BufReader(new Buffer(encode(trailer)))); @@ -96,11 +96,11 @@ test("readTrailer should throw if undeclared headers found in trailer", async () const patterns = [ ["deno,node", "deno: land\r\nnode: js\r\ngo: lang\r\n\r\n"], ["deno", "node: js\r\n\r\n"], - ["deno", "node:js\r\ngo: lang\r\n\r\n"] + ["deno", "node:js\r\ngo: lang\r\n\r\n"], ]; for (const [header, trailer] of patterns) { const h = new Headers({ - trailer: header + trailer: header, }); await assertThrowsAsync( async () => { @@ -115,7 +115,7 @@ test("readTrailer should throw if undeclared headers found in trailer", async () test("readTrailer should throw if trailer contains prohibited fields", async () => { for (const f of ["content-length", "trailer", "transfer-encoding"]) { const h = new Headers({ - trailer: f + trailer: f, }); await assertThrowsAsync( async () => { @@ -192,7 +192,7 @@ test("parseHttpVersion", (): void => { { in: "HTTP/-1.0", err: true }, { in: "HTTP/0.-1", err: true }, { in: "HTTP/", err: true }, - { in: "HTTP/1,0", err: true } + { in: "HTTP/1,0", err: true }, ]; for (const t of testCases) { let r, err; @@ -320,10 +320,10 @@ test("writeResponse with trailer", async () => { status: 200, headers: new Headers({ "transfer-encoding": "chunked", - trailer: "deno,node" + trailer: "deno,node", }), body, - trailers: () => new Headers({ deno: "land", node: "js" }) + trailers: () => new Headers({ deno: "land", node: "js" }), }); const ret = w.toString(); const exp = [ @@ -338,7 +338,7 @@ test("writeResponse with trailer", async () => { "deno: land", "node: js", "", - "" + "", ].join("\r\n"); assertEquals(ret, exp); }); @@ -365,20 +365,20 @@ test(async function testReadRequestError(): Promise { const testCases = [ { in: "GET / HTTP/1.1\r\nheader: foo\r\n\r\n", - headers: [{ key: "header", value: "foo" }] + headers: [{ key: "header", value: "foo" }], }, { in: "GET / HTTP/1.1\r\nheader:foo\r\n", - err: Deno.errors.UnexpectedEof + err: Deno.errors.UnexpectedEof, }, { in: "", err: Deno.EOF }, { in: "HEAD / HTTP/1.1\r\nContent-Length:4\r\n\r\n", - err: "http: method cannot contain a Content-Length" + err: "http: method cannot contain a Content-Length", }, { in: "HEAD / HTTP/1.1\r\n\r\n", - headers: [] + headers: [], }, // Multiple Content-Length values should either be // deduplicated if same or reject otherwise @@ -387,23 +387,23 @@ test(async function testReadRequestError(): Promise { in: "POST / HTTP/1.1\r\nContent-Length: 10\r\nContent-Length: 0\r\n\r\n" + "Gopher hey\r\n", - err: "cannot contain multiple Content-Length headers" + err: "cannot contain multiple Content-Length headers", }, { in: "POST / HTTP/1.1\r\nContent-Length: 10\r\nContent-Length: 6\r\n\r\n" + "Gopher\r\n", - err: "cannot contain multiple Content-Length headers" + err: "cannot contain multiple Content-Length headers", }, { in: "PUT / HTTP/1.1\r\nContent-Length: 6 \r\nContent-Length: 6\r\n" + "Content-Length:6\r\n\r\nGopher\r\n", - headers: [{ key: "Content-Length", value: "6" }] + headers: [{ key: "Content-Length", value: "6" }], }, { in: "PUT / HTTP/1.1\r\nContent-Length: 1\r\nContent-Length: 6 \r\n\r\n", - err: "cannot contain multiple Content-Length headers" + err: "cannot contain multiple Content-Length headers", }, // Setting an empty header is swallowed by textproto // see: readMIMEHeader() @@ -413,15 +413,15 @@ test(async function testReadRequestError(): Promise { // }, { in: "HEAD / HTTP/1.1\r\nContent-Length:0\r\nContent-Length: 0\r\n\r\n", - headers: [{ key: "Content-Length", value: "0" }] + headers: [{ key: "Content-Length", value: "0" }], }, { in: "POST / HTTP/1.1\r\nContent-Length:0\r\ntransfer-encoding: " + "chunked\r\n\r\n", headers: [], - err: "http: Transfer-Encoding and Content-Length cannot be send together" - } + err: "http: Transfer-Encoding and Content-Length cannot be send together", + }, ]; for (const test of testCases) { const reader = new BufReader(new StringReader(test.in)); diff --git a/http/mock.ts b/http/mock.ts index cee697bed899..64bd3fcb99c9 100644 --- a/http/mock.ts +++ b/http/mock.ts @@ -4,12 +4,12 @@ export function mockConn(base: Partial = {}): Deno.Conn { localAddr: { transport: "tcp", hostname: "", - port: 0 + port: 0, }, remoteAddr: { transport: "tcp", hostname: "", - port: 0 + port: 0, }, rid: -1, closeRead: (): void => {}, @@ -21,6 +21,6 @@ export function mockConn(base: Partial = {}): Deno.Conn { return Promise.resolve(-1); }, close: (): void => {}, - ...base + ...base, }; } diff --git a/http/racing_server_test.ts b/http/racing_server_test.ts index 865777599fe6..037e91ef9780 100644 --- a/http/racing_server_test.ts +++ b/http/racing_server_test.ts @@ -7,7 +7,7 @@ let server: Deno.Process; async function startServer(): Promise { server = run({ cmd: [Deno.execPath(), "run", "-A", "http/racing_server.ts"], - stdout: "piped" + stdout: "piped", }); // Once racing server is ready it will write to its stdout. assert(server.stdout != null); @@ -27,7 +27,7 @@ const input = [ "POST / HTTP/1.1\r\ncontent-length: 4\r\n\r\ndeno", "POST / HTTP/1.1\r\ntransfer-encoding: chunked\r\n\r\n4\r\ndeno\r\n0\r\n\r\n", "POST / HTTP/1.1\r\ntransfer-encoding: chunked\r\ntrailer: deno\r\n\r\n4\r\ndeno\r\n0\r\n\r\ndeno: land\r\n\r\n", - "GET / HTTP/1.1\r\n\r\n" + "GET / HTTP/1.1\r\n\r\n", ].join(""); const HUGE_BODY_SIZE = 1024 * 1024; const output = `HTTP/1.1 200 OK diff --git a/http/server.ts b/http/server.ts index 2cd51b005136..00f401f62731 100644 --- a/http/server.ts +++ b/http/server.ts @@ -7,7 +7,7 @@ import { chunkedBodyReader, emptyReader, writeResponse, - readRequest + readRequest, } from "./io.ts"; import Listener = Deno.Listener; import Conn = Deno.Conn; @@ -298,7 +298,7 @@ export type HTTPSOptions = Omit; export function serveTLS(options: HTTPSOptions): Server { const tlsOptions: Deno.ListenTLSOptions = { ...options, - transport: "tcp" + transport: "tcp", }; const listener = listenTLS(tlsOptions); return new Server(listener); diff --git a/http/server_test.ts b/http/server_test.ts index f66b190b2669..d6b2be053cdf 100644 --- a/http/server_test.ts +++ b/http/server_test.ts @@ -11,7 +11,7 @@ import { assertEquals, assertNotEOF, assertStrContains, - assertThrowsAsync + assertThrowsAsync, } from "../testing/asserts.ts"; import { Response, ServerRequest, Server, serve } from "./server.ts"; import { BufReader, BufWriter } from "../io/bufio.ts"; @@ -30,27 +30,27 @@ const responseTests: ResponseTest[] = [ // Default response { response: {}, - raw: "HTTP/1.1 200 OK\r\n" + "content-length: 0" + "\r\n\r\n" + raw: "HTTP/1.1 200 OK\r\n" + "content-length: 0" + "\r\n\r\n", }, // Empty body with status { response: { - status: 404 + status: 404, }, - raw: "HTTP/1.1 404 Not Found\r\n" + "content-length: 0" + "\r\n\r\n" + raw: "HTTP/1.1 404 Not Found\r\n" + "content-length: 0" + "\r\n\r\n", }, // HTTP/1.1, chunked coding; empty trailer; close { response: { status: 200, - body: new Buffer(new TextEncoder().encode("abcdef")) + body: new Buffer(new TextEncoder().encode("abcdef")), }, raw: "HTTP/1.1 200 OK\r\n" + "transfer-encoding: chunked\r\n\r\n" + - "6\r\nabcdef\r\n0\r\n\r\n" - } + "6\r\nabcdef\r\n0\r\n\r\n", + }, ]; test(async function responseWrite(): Promise { @@ -118,7 +118,7 @@ function totalReader(r: Deno.Reader): TotalReader { read, get total(): number { return _total; - } + }, }; } test(async function requestBodyWithContentLength(): Promise { @@ -169,7 +169,7 @@ test("ServerRequest.finalize() should consume unread body / chunked, trailers", "deno: land", "node: js", "", - "" + "", ].join("\r\n"); const req = new ServerRequest(); req.headers = new Headers(); @@ -357,7 +357,7 @@ test({ // Runs a simple server as another process const p = Deno.run({ cmd: [Deno.execPath(), "--allow-net", "http/testdata/simple_server.ts"], - stdout: "piped" + stdout: "piped", }); let serverIsRunning = true; @@ -387,7 +387,7 @@ test({ p.stdout!.close(); p.close(); } - } + }, }); test({ @@ -401,9 +401,9 @@ test({ Deno.execPath(), "--allow-net", "--allow-read", - "http/testdata/simple_https_server.ts" + "http/testdata/simple_https_server.ts", ], - stdout: "piped" + stdout: "piped", }); let serverIsRunning = true; @@ -425,7 +425,7 @@ test({ const conn = await Deno.connectTLS({ hostname: "localhost", port: 4503, - certFile: "http/testdata/tls/RootCA.pem" + certFile: "http/testdata/tls/RootCA.pem", }); await Deno.writeAll( conn, @@ -444,7 +444,7 @@ test({ p.stdout!.close(); p.close(); } - } + }, }); test("close server while iterating", async (): Promise => { @@ -485,7 +485,7 @@ test({ const resources = Deno.resources(); assertEquals(resources[conn.rid], "tcpStream"); conn.close(); - } + }, }); test({ @@ -498,7 +498,7 @@ test({ await assertThrowsAsync(async () => { await req.respond({ status: 12345, - body: new TextEncoder().encode("Hello World") + body: new TextEncoder().encode("Hello World"), }); }, Deno.errors.InvalidData); // The connection should be destroyed @@ -509,7 +509,7 @@ test({ const p = serverRoutine(); const conn = await Deno.connect({ hostname: "127.0.0.1", - port: 8124 + port: 8124, }); await Deno.writeAll( conn, @@ -517,5 +517,5 @@ test({ ); conn.close(); await p; - } + }, }); diff --git a/io/bufio.ts b/io/bufio.ts index a944adfed4cb..87613e3418c0 100644 --- a/io/bufio.ts +++ b/io/bufio.ts @@ -212,8 +212,9 @@ export class BufReader implements Reader { * For simple uses, a Scanner may be more convenient. */ async readString(delim: string): Promise { - if (delim.length !== 1) + if (delim.length !== 1) { throw new Error("Delimiter should be a single character"); + } const buffer = await this.readSlice(delim.charCodeAt(0)); if (buffer == Deno.EOF) return Deno.EOF; return new TextDecoder().decode(buffer); diff --git a/io/bufio_test.ts b/io/bufio_test.ts index ae38f66673f3..c1b1b856b7a5 100644 --- a/io/bufio_test.ts +++ b/io/bufio_test.ts @@ -9,7 +9,7 @@ import { assert, assertEquals, fail, - assertNotEOF + assertNotEOF, } from "../testing/asserts.ts"; import { BufReader, @@ -17,7 +17,7 @@ import { BufferFullError, PartialReadError, readStringDelim, - readLines + readLines, } from "./bufio.ts"; import * as iotest from "./iotest.ts"; import { charCode, copyBytes, stringsReader } from "./util.ts"; @@ -55,9 +55,9 @@ const readMakers: ReadMaker[] = [ { name: "full", fn: (r): Reader => r }, { name: "byte", - fn: (r): iotest.OneByteReader => new iotest.OneByteReader(r) + fn: (r): iotest.OneByteReader => new iotest.OneByteReader(r), }, - { name: "half", fn: (r): iotest.HalfReader => new iotest.HalfReader(r) } + { name: "half", fn: (r): iotest.HalfReader => new iotest.HalfReader(r) }, // TODO { name: "data+err", r => new iotest.DataErrReader(r) }, // { name: "timeout", fn: r => new iotest.TimeoutReader(r) }, ]; @@ -89,7 +89,7 @@ const bufreaders: NamedBufReader[] = [ { name: "4", fn: (b: BufReader): Promise => reads(b, 4) }, { name: "5", fn: (b: BufReader): Promise => reads(b, 5) }, { name: "7", fn: (b: BufReader): Promise => reads(b, 7) }, - { name: "bytes", fn: readBytes } + { name: "bytes", fn: readBytes }, // { name: "lines", fn: readLines }, ]; @@ -104,7 +104,7 @@ const bufsizes: number[] = [ 93, 128, 1024, - 4096 + 4096, ]; Deno.test(async function bufioBufReader(): Promise { diff --git a/io/ioutil_test.ts b/io/ioutil_test.ts index 3d85a0fa174a..d00986da5c1d 100644 --- a/io/ioutil_test.ts +++ b/io/ioutil_test.ts @@ -7,7 +7,7 @@ import { readInt, readLong, readShort, - sliceLongToBytes + sliceLongToBytes, } from "./ioutil.ts"; import { BufReader } from "./bufio.ts"; import { stringsReader } from "./util.ts"; diff --git a/io/util_test.ts b/io/util_test.ts index 2fcad930576e..17f11b945669 100644 --- a/io/util_test.ts +++ b/io/util_test.ts @@ -4,7 +4,7 @@ import { assert, assertEquals } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; import { copyBytes, tempFile } from "./util.ts"; -test("[io/tuil] copyBytes", function(): void { +test("[io/tuil] copyBytes", function (): void { const dst = new Uint8Array(4); dst.fill(0); @@ -40,14 +40,14 @@ test("[io/tuil] copyBytes", function(): void { test({ name: "[io/util] tempfile", - fn: async function(): Promise { + fn: async function (): Promise { const f = await tempFile(".", { prefix: "prefix-", - postfix: "-postfix" + postfix: "-postfix", }); const base = path.basename(f.filepath); assert(!!base.match(/^prefix-.+?-postfix$/)); f.file.close(); await remove(f.filepath); - } + }, }); diff --git a/log/README.md b/log/README.md index 613e69922e56..dea1e5fe7e23 100644 --- a/log/README.md +++ b/log/README.md @@ -21,22 +21,22 @@ await log.setup({ file: new log.handlers.FileHandler("WARNING", { filename: "./log.txt", // you can change format of output message - formatter: "{levelName} {msg}" - }) + formatter: "{levelName} {msg}", + }), }, loggers: { // configure default logger available via short-hand methods above default: { level: "DEBUG", - handlers: ["console", "file"] + handlers: ["console", "file"], }, tasks: { level: "ERROR", - handlers: ["console"] - } - } + handlers: ["console"], + }, + }, }); let logger; diff --git a/log/handlers_test.ts b/log/handlers_test.ts index 693d2a48554d..4feffdaf9443 100644 --- a/log/handlers_test.ts +++ b/log/handlers_test.ts @@ -21,8 +21,8 @@ test(function simpleHandler(): void { "INFO info-test", "WARNING warning-test", "ERROR error-test", - "CRITICAL critical-test" - ] + "CRITICAL critical-test", + ], ], [ LogLevel.INFO, @@ -30,15 +30,15 @@ test(function simpleHandler(): void { "INFO info-test", "WARNING warning-test", "ERROR error-test", - "CRITICAL critical-test" - ] + "CRITICAL critical-test", + ], ], [ LogLevel.WARNING, - ["WARNING warning-test", "ERROR error-test", "CRITICAL critical-test"] + ["WARNING warning-test", "ERROR error-test", "CRITICAL critical-test"], ], [LogLevel.ERROR, ["ERROR error-test", "CRITICAL critical-test"]], - [LogLevel.CRITICAL, ["CRITICAL critical-test"]] + [LogLevel.CRITICAL, ["CRITICAL critical-test"]], ]); for (const [testCase, messages] of cases.entries()) { @@ -52,7 +52,7 @@ test(function simpleHandler(): void { args: [], datetime: new Date(), level: level, - levelName: levelName + levelName: levelName, }); } @@ -64,7 +64,7 @@ test(function simpleHandler(): void { test(function testFormatterAsString(): void { const handler = new TestHandler("DEBUG", { - formatter: "test {levelName} {msg}" + formatter: "test {levelName} {msg}", }); handler.handle({ @@ -72,7 +72,7 @@ test(function testFormatterAsString(): void { args: [], datetime: new Date(), level: LogLevel.DEBUG, - levelName: "DEBUG" + levelName: "DEBUG", }); assertEquals(handler.messages, ["test DEBUG Hello, world!"]); @@ -81,7 +81,7 @@ test(function testFormatterAsString(): void { test(function testFormatterAsFunction(): void { const handler = new TestHandler("DEBUG", { formatter: (logRecord): string => - `fn formmatter ${logRecord.levelName} ${logRecord.msg}` + `fn formmatter ${logRecord.levelName} ${logRecord.msg}`, }); handler.handle({ @@ -89,7 +89,7 @@ test(function testFormatterAsFunction(): void { args: [], datetime: new Date(), level: LogLevel.ERROR, - levelName: "ERROR" + levelName: "ERROR", }); assertEquals(handler.messages, ["fn formmatter ERROR Hello, world!"]); diff --git a/log/levels.ts b/log/levels.ts index 599629f858ed..be960dd572d0 100644 --- a/log/levels.ts +++ b/log/levels.ts @@ -5,7 +5,7 @@ export const LogLevel: Record = { INFO: 20, WARNING: 30, ERROR: 40, - CRITICAL: 50 + CRITICAL: 50, }; const byLevel = { @@ -14,7 +14,7 @@ const byLevel = { [LogLevel.INFO]: "INFO", [LogLevel.WARNING]: "WARNING", [LogLevel.ERROR]: "ERROR", - [LogLevel.CRITICAL]: "CRITICAL" + [LogLevel.CRITICAL]: "CRITICAL", }; export function getLevelByName(name: string): number { diff --git a/log/logger.ts b/log/logger.ts index 99d17ef48f01..226b8dba6117 100644 --- a/log/logger.ts +++ b/log/logger.ts @@ -34,7 +34,7 @@ export class Logger { args: args, datetime: new Date(), level: level, - levelName: getLevelName(level) + levelName: getLevelName(level), }; this.handlers.forEach((handler): void => { handler.handle(record); diff --git a/log/logger_test.ts b/log/logger_test.ts index 76ff4cf95590..3e8898afaabe 100644 --- a/log/logger_test.ts +++ b/log/logger_test.ts @@ -67,7 +67,7 @@ test(function logFunctions(): void { "INFO bar", "WARNING baz", "ERROR boo", - "CRITICAL doo" + "CRITICAL doo", ]); handler = doLog("INFO"); @@ -76,7 +76,7 @@ test(function logFunctions(): void { "INFO bar", "WARNING baz", "ERROR boo", - "CRITICAL doo" + "CRITICAL doo", ]); handler = doLog("WARNING"); diff --git a/log/mod.ts b/log/mod.ts index b89896264f75..333e90fb9a69 100644 --- a/log/mod.ts +++ b/log/mod.ts @@ -4,7 +4,7 @@ import { BaseHandler, ConsoleHandler, WriterHandler, - FileHandler + FileHandler, } from "./handlers.ts"; import { assert } from "../testing/asserts.ts"; @@ -25,28 +25,28 @@ export interface LogConfig { const DEFAULT_LEVEL = "INFO"; const DEFAULT_CONFIG: LogConfig = { handlers: { - default: new ConsoleHandler(DEFAULT_LEVEL) + default: new ConsoleHandler(DEFAULT_LEVEL), }, loggers: { default: { level: DEFAULT_LEVEL, - handlers: ["default"] - } - } + handlers: ["default"], + }, + }, }; const state = { handlers: new Map(), loggers: new Map(), - config: DEFAULT_CONFIG + config: DEFAULT_CONFIG, }; export const handlers = { BaseHandler, ConsoleHandler, WriterHandler, - FileHandler + FileHandler, }; export function getLogger(name?: string): Logger { @@ -81,7 +81,7 @@ export const critical = (msg: string, ...args: unknown[]): void => export async function setup(config: LogConfig): Promise { state.config = { handlers: { ...DEFAULT_CONFIG.handlers, ...config.handlers }, - loggers: { ...DEFAULT_CONFIG.loggers, ...config.loggers } + loggers: { ...DEFAULT_CONFIG.loggers, ...config.loggers }, }; // tear down existing handlers diff --git a/log/test.ts b/log/test.ts index d4385968c616..858f722e273f 100644 --- a/log/test.ts +++ b/log/test.ts @@ -20,7 +20,7 @@ test(async function defaultHandlers(): Promise { INFO: log.info, WARNING: log.warning, ERROR: log.error, - CRITICAL: log.critical + CRITICAL: log.critical, }; for (const levelName in LogLevel) { @@ -33,14 +33,14 @@ test(async function defaultHandlers(): Promise { await log.setup({ handlers: { - default: handler + default: handler, }, loggers: { default: { level: levelName, - handlers: ["default"] - } - } + handlers: ["default"], + }, + }, }); logger("foo"); @@ -55,14 +55,14 @@ test(async function getLogger(): Promise { await log.setup({ handlers: { - default: handler + default: handler, }, loggers: { default: { level: "DEBUG", - handlers: ["default"] - } - } + handlers: ["default"], + }, + }, }); const logger = log.getLogger(); @@ -76,14 +76,14 @@ test(async function getLoggerWithName(): Promise { await log.setup({ handlers: { - foo: fooHandler + foo: fooHandler, }, loggers: { bar: { level: "INFO", - handlers: ["foo"] - } - } + handlers: ["foo"], + }, + }, }); const logger = log.getLogger("bar"); @@ -95,7 +95,7 @@ test(async function getLoggerWithName(): Promise { test(async function getLoggerUnknown(): Promise { await log.setup({ handlers: {}, - loggers: {} + loggers: {}, }); const logger = log.getLogger("nonexistent"); diff --git a/manual.md b/manual.md index f073d1508003..1e8fefcb106d 100644 --- a/manual.md +++ b/manual.md @@ -366,7 +366,7 @@ Example: ```ts // create subprocess const p = Deno.run({ - cmd: ["echo", "hello"] + cmd: ["echo", "hello"], }); // await its completion @@ -398,10 +398,10 @@ const p = Deno.run({ "run", "--allow-read", "https://deno.land/std/examples/cat.ts", - ...fileNames + ...fileNames, ], stdout: "piped", - stderr: "piped" + stderr: "piped", }); const { code } = await p.status(); @@ -557,7 +557,7 @@ assertion library across a large project. Rather than importing export { assert, assertEquals, - assertStrContains + assertStrContains, } from "https://deno.land/std/testing/asserts.ts"; ``` @@ -676,10 +676,10 @@ TypeScript `"dom"` library: const [errors, emitted] = await Deno.compile( "main.ts", { - "main.ts": `document.getElementById("foo");\n` + "main.ts": `document.getElementById("foo");\n`, }, { - lib: ["dom", "esnext"] + lib: ["dom", "esnext"], } ); ``` @@ -716,10 +716,10 @@ lib in the array. For example: const [errors, emitted] = await Deno.compile( "main.ts", { - "main.ts": `document.getElementById("foo");\n` + "main.ts": `document.getElementById("foo");\n`, }, { - lib: ["dom", "esnext", "deno.ns"] + lib: ["dom", "esnext", "deno.ns"], } ); ``` @@ -745,7 +745,7 @@ It would compiler without errors like this: ```ts const [errors, emitted] = await Deno.compile("./main.ts", undefined, { - lib: ["esnext"] + lib: ["esnext"], }); ``` @@ -1059,7 +1059,7 @@ An example of providing sources: ```ts const [diagnostics, emitMap] = await Deno.compile("/foo.ts", { "/foo.ts": `import * as bar from "./bar.ts";\nconsole.log(bar);\n`, - "/bar.ts": `export const bar = "bar";\n` + "/bar.ts": `export const bar = "bar";\n`, }); assert(diagnostics == null); // ensuring no diagnostics are returned @@ -1104,7 +1104,7 @@ An example of providing sources: ```ts const [diagnostics, emit] = await Deno.bundle("/foo.ts", { "/foo.ts": `import * as bar from "./bar.ts";\nconsole.log(bar);\n`, - "/bar.ts": `export const bar = "bar";\n` + "/bar.ts": `export const bar = "bar";\n`, }); assert(diagnostics == null); // ensuring no diagnostics are returned @@ -1145,7 +1145,7 @@ An example: ```ts const result = await Deno.transpileOnly({ - "/foo.ts": `enum Foo { Foo, Bar, Baz };\n` + "/foo.ts": `enum Foo { Foo, Bar, Baz };\n`, }); console.log(result["/foo.ts"].source); diff --git a/media_types/test.ts b/media_types/test.ts index 3a9a7d9fefb8..c3caf71df132 100644 --- a/media_types/test.ts +++ b/media_types/test.ts @@ -8,7 +8,7 @@ import { extension, charset, extensions, - types + types, } from "./mod.ts"; test(function testLookup(): void { diff --git a/mime/multipart.ts b/mime/multipart.ts index d4bd693fd0de..a0f40f3b0914 100644 --- a/mime/multipart.ts +++ b/mime/multipart.ts @@ -305,7 +305,7 @@ export class MultipartReader { const ext = extname(p.fileName); const { file, filepath } = await tempFile(".", { prefix: "multipart-", - postfix: ext + postfix: ext, }); try { const size = await copyN( @@ -318,7 +318,7 @@ export class MultipartReader { filename: p.fileName, type: contentType, tempfile: filepath, - size + size, }; } catch (e) { await remove(filepath); @@ -328,7 +328,7 @@ export class MultipartReader { filename: p.fileName, type: contentType, content: buf.bytes(), - size: buf.length + size: buf.length, }; maxMemory -= n; maxValueBytes -= n; diff --git a/mime/multipart_test.ts b/mime/multipart_test.ts index 7c383d4472c8..9b96a2f4cfa4 100644 --- a/mime/multipart_test.ts +++ b/mime/multipart_test.ts @@ -5,7 +5,7 @@ import { assert, assertEquals, assertThrows, - assertThrowsAsync + assertThrowsAsync, } from "../testing/asserts.ts"; const { test } = Deno; import * as path from "../path/mod.ts"; @@ -15,7 +15,7 @@ import { MultipartWriter, isFormFile, matchAfterPrefix, - scanUntilBoundary + scanUntilBoundary, } from "./multipart.ts"; import { StringWriter } from "../io/writers.ts"; diff --git a/node/_fs/_fs_appendFile.ts b/node/_fs/_fs_appendFile.ts index 49a4fc29f0ea..f3b44dd7b722 100644 --- a/node/_fs/_fs_appendFile.ts +++ b/node/_fs/_fs_appendFile.ts @@ -55,7 +55,7 @@ export function appendFile( closeRidIfNecessary(typeof pathOrRid === "string", rid); callbackFn(); }) - .catch(err => { + .catch((err) => { closeRidIfNecessary(typeof pathOrRid === "string", rid); callbackFn(err); }); diff --git a/node/_fs/_fs_appendFile_test.ts b/node/_fs/_fs_appendFile_test.ts index 47d552740639..ca48dc5d3b5c 100644 --- a/node/_fs/_fs_appendFile_test.ts +++ b/node/_fs/_fs_appendFile_test.ts @@ -15,7 +15,7 @@ test({ Error, "No callback function supplied" ); - } + }, }); test({ @@ -48,12 +48,12 @@ test({ assertThrows( () => appendFileSync("some/path", "some data", { - encoding: "made-up-encoding" + encoding: "made-up-encoding", }), Error, "Only 'utf8' encoding is currently supported" ); - } + }, }); test({ @@ -63,10 +63,10 @@ test({ const file: Deno.File = await Deno.open(tempFile, { create: true, write: true, - read: true + read: true, }); await new Promise((resolve, reject) => { - appendFile(file.rid, "hello world", err => { + appendFile(file.rid, "hello world", (err) => { if (err) reject(); else resolve(); }); @@ -82,7 +82,7 @@ test({ Deno.close(file.rid); await Deno.remove(tempFile); }); - } + }, }); test({ @@ -90,7 +90,7 @@ test({ async fn() { const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); await new Promise((resolve, reject) => { - appendFile("_fs_appendFile_test_file.txt", "hello world", err => { + appendFile("_fs_appendFile_test_file.txt", "hello world", (err) => { if (err) reject(err); else resolve(); }); @@ -100,13 +100,13 @@ test({ const data = await Deno.readFile("_fs_appendFile_test_file.txt"); assertEquals(decoder.decode(data), "hello world"); }) - .catch(err => { + .catch((err) => { fail("No error was expected: " + err); }) .finally(async () => { await Deno.remove("_fs_appendFile_test_file.txt"); }); - } + }, }); test({ @@ -116,7 +116,7 @@ test({ const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources(); const tempFile: string = await Deno.makeTempFile(); await new Promise((resolve, reject) => { - appendFile(tempFile, "hello world", { flag: "ax" }, err => { + appendFile(tempFile, "hello world", { flag: "ax" }, (err) => { if (err) reject(err); else resolve(); }); @@ -130,7 +130,7 @@ test({ .finally(async () => { await Deno.remove(tempFile); }); - } + }, }); test({ @@ -140,14 +140,14 @@ test({ const file: Deno.File = Deno.openSync(tempFile, { create: true, write: true, - read: true + read: true, }); appendFileSync(file.rid, "hello world"); Deno.close(file.rid); const data = Deno.readFileSync(tempFile); assertEquals(decoder.decode(data), "hello world"); Deno.removeSync(tempFile); - } + }, }); test({ @@ -159,7 +159,7 @@ test({ const data = Deno.readFileSync("_fs_appendFile_test_file_sync.txt"); assertEquals(decoder.decode(data), "hello world"); Deno.removeSync("_fs_appendFile_test_file_sync.txt"); - } + }, }); test({ @@ -175,5 +175,5 @@ test({ ); assertEquals(Deno.resources(), openResourcesBeforeAppend); Deno.removeSync(tempFile); - } + }, }); diff --git a/node/_fs/_fs_chmod.ts b/node/_fs/_fs_chmod.ts index cecb878eca30..0eb01a8a6f4f 100644 --- a/node/_fs/_fs_chmod.ts +++ b/node/_fs/_fs_chmod.ts @@ -24,7 +24,7 @@ export function chmod( .then(() => { callback(); }) - .catch(err => { + .catch((err) => { callback(err); }); } diff --git a/node/_fs/_fs_chmod_test.ts b/node/_fs/_fs_chmod_test.ts index 8d420b3bedef..a3d814b51d3b 100644 --- a/node/_fs/_fs_chmod_test.ts +++ b/node/_fs/_fs_chmod_test.ts @@ -10,7 +10,7 @@ test({ const tempFile: string = await Deno.makeTempFile(); const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode; await new Promise((resolve, reject) => { - chmod(tempFile, 0o777, err => { + chmod(tempFile, 0o777, (err) => { if (err) reject(err); else resolve(); }); @@ -26,7 +26,7 @@ test({ .finally(() => { Deno.removeSync(tempFile); }); - } + }, }); test({ @@ -41,5 +41,5 @@ test({ assert(newFileMode && originalFileMode); assert(newFileMode === 33279 && newFileMode > originalFileMode); Deno.removeSync(tempFile); - } + }, }); diff --git a/node/_fs/_fs_chown.ts b/node/_fs/_fs_chown.ts index 008b30c47e35..94b7401d08fa 100644 --- a/node/_fs/_fs_chown.ts +++ b/node/_fs/_fs_chown.ts @@ -23,7 +23,7 @@ export function chown( .then(() => { callback(); }) - .catch(err => { + .catch((err) => { callback(err); }); } diff --git a/node/_fs/_fs_chown_test.ts b/node/_fs/_fs_chown_test.ts index bdf2ae09af6c..fd31a8c62e77 100644 --- a/node/_fs/_fs_chown_test.ts +++ b/node/_fs/_fs_chown_test.ts @@ -14,7 +14,7 @@ test({ const originalUserId: number | null = (await Deno.lstat(tempFile)).uid; const originalGroupId: number | null = (await Deno.lstat(tempFile)).gid; await new Promise((resolve, reject) => { - chown(tempFile, originalUserId!, originalGroupId!, err => { + chown(tempFile, originalUserId!, originalGroupId!, (err) => { if (err) reject(err); else resolve(); }); @@ -31,7 +31,7 @@ test({ .finally(() => { Deno.removeSync(tempFile); }); - } + }, }); test({ @@ -48,5 +48,5 @@ test({ assertEquals(newUserId, originalUserId); assertEquals(newGroupId, originalGroupId); Deno.removeSync(tempFile); - } + }, }); diff --git a/node/_fs/_fs_close.ts b/node/_fs/_fs_close.ts index 4ec10eefb8d6..469bdc77b624 100644 --- a/node/_fs/_fs_close.ts +++ b/node/_fs/_fs_close.ts @@ -14,7 +14,7 @@ export function close(fd: number, callback: CallbackWithError): void { .then(() => { callback(); }) - .catch(err => { + .catch((err) => { callback(err); }); } diff --git a/node/_fs/_fs_close_test.ts b/node/_fs/_fs_close_test.ts index 7c6dd684cd80..8bcd662c96f7 100644 --- a/node/_fs/_fs_close_test.ts +++ b/node/_fs/_fs_close_test.ts @@ -11,7 +11,7 @@ test({ assert(Deno.resources()[file.rid]); await new Promise((resolve, reject) => { - close(file.rid, err => { + close(file.rid, (err) => { if (err) reject(); else resolve(); }); @@ -25,7 +25,7 @@ test({ .finally(async () => { await Deno.remove(tempFile); }); - } + }, }); test({ @@ -38,5 +38,5 @@ test({ closeSync(file.rid); assert(!Deno.resources()[file.rid]); Deno.removeSync(tempFile); - } + }, }); diff --git a/node/_fs/_fs_dir.ts b/node/_fs/_fs_dir.ts index e3830bb317ef..c5bb368c9460 100644 --- a/node/_fs/_fs_dir.ts +++ b/node/_fs/_fs_dir.ts @@ -30,7 +30,7 @@ export default class Dir { try { if (this.initializationOfDirectoryFilesIsRequired()) { const denoFiles: Deno.FileInfo[] = await Deno.readdir(this.path); - this.files = denoFiles.map(file => new Dirent(file)); + this.files = denoFiles.map((file) => new Dirent(file)); } const nextFile = this.files.pop(); if (nextFile) { @@ -55,7 +55,7 @@ export default class Dir { readSync(): Dirent | null { if (this.initializationOfDirectoryFilesIsRequired()) { this.files.push( - ...Deno.readdirSync(this.path).map(file => new Dirent(file)) + ...Deno.readdirSync(this.path).map((file) => new Dirent(file)) ); } const dirent: Dirent | undefined = this.files.pop(); diff --git a/node/_fs/_fs_dir_test.ts b/node/_fs/_fs_dir_test.ts index be276887bde1..6ee04439134e 100644 --- a/node/_fs/_fs_dir_test.ts +++ b/node/_fs/_fs_dir_test.ts @@ -13,21 +13,21 @@ test({ calledBack = true; }); assert(calledBack); - } + }, }); test({ name: "Closing current directory without callback returns void Promise", async fn() { await new Dir(".").close(); - } + }, }); test({ name: "Closing current directory synchronously works", fn() { new Dir(".").closeSync(); - } + }, }); test({ @@ -37,7 +37,7 @@ test({ const enc: Uint8Array = new TextEncoder().encode("std/node"); assertEquals(new Dir(enc).path, "std/node"); - } + }, }); test({ @@ -64,7 +64,7 @@ test({ } finally { Deno.removeSync(testDir); } - } + }, }); test({ @@ -103,7 +103,7 @@ test({ } finally { Deno.removeSync(testDir, { recursive: true }); } - } + }, }); test({ @@ -132,7 +132,7 @@ test({ } finally { Deno.removeSync(testDir, { recursive: true }); } - } + }, }); test({ @@ -158,5 +158,5 @@ test({ } finally { Deno.removeSync(testDir, { recursive: true }); } - } + }, }); diff --git a/node/_fs/_fs_dirent_test.ts b/node/_fs/_fs_dirent_test.ts index 36091d3e1320..1b1d38d38be0 100644 --- a/node/_fs/_fs_dirent_test.ts +++ b/node/_fs/_fs_dirent_test.ts @@ -40,7 +40,7 @@ test({ fileInfo.blocks = 5; assert(new Dirent(fileInfo).isBlockDevice()); assert(!new Dirent(fileInfo).isCharacterDevice()); - } + }, }); test({ @@ -50,7 +50,7 @@ test({ fileInfo.blocks = null; assert(new Dirent(fileInfo).isCharacterDevice()); assert(!new Dirent(fileInfo).isBlockDevice()); - } + }, }); test({ @@ -63,7 +63,7 @@ test({ assert(new Dirent(fileInfo).isDirectory()); assert(!new Dirent(fileInfo).isFile()); assert(!new Dirent(fileInfo).isSymbolicLink()); - } + }, }); test({ @@ -76,7 +76,7 @@ test({ assert(!new Dirent(fileInfo).isDirectory()); assert(new Dirent(fileInfo).isFile()); assert(!new Dirent(fileInfo).isSymbolicLink()); - } + }, }); test({ @@ -89,7 +89,7 @@ test({ assert(!new Dirent(fileInfo).isDirectory()); assert(!new Dirent(fileInfo).isFile()); assert(new Dirent(fileInfo).isSymbolicLink()); - } + }, }); test({ @@ -98,7 +98,7 @@ test({ const fileInfo: FileInfoMock = new FileInfoMock(); fileInfo.name = "my_file"; assertEquals(new Dirent(fileInfo).name, "my_file"); - } + }, }); test({ @@ -119,5 +119,5 @@ test({ Error, "does not yet support" ); - } + }, }); diff --git a/node/_fs/_fs_readFile.ts b/node/_fs/_fs_readFile.ts index 05bad6f3df7b..13e82bfe1dcc 100644 --- a/node/_fs/_fs_readFile.ts +++ b/node/_fs/_fs_readFile.ts @@ -3,7 +3,7 @@ import { notImplemented, intoCallbackAPIWithIntercept, - MaybeEmpty + MaybeEmpty, } from "../_utils.ts"; const { readFile: denoReadFile, readFileSync: denoReadFileSync } = Deno; diff --git a/node/_fs/_fs_readlink.ts b/node/_fs/_fs_readlink.ts index d1cb69f517b0..1fd7e3c148f8 100644 --- a/node/_fs/_fs_readlink.ts +++ b/node/_fs/_fs_readlink.ts @@ -2,7 +2,7 @@ import { intoCallbackAPIWithIntercept, MaybeEmpty, - notImplemented + notImplemented, } from "../_utils.ts"; const { readlink: denoReadlink, readlinkSync: denoReadlinkSync } = Deno; diff --git a/node/_fs/_fs_readlink_test.ts b/node/_fs/_fs_readlink_test.ts index 653d1a59886c..151d3f78269c 100644 --- a/node/_fs/_fs_readlink_test.ts +++ b/node/_fs/_fs_readlink_test.ts @@ -25,7 +25,7 @@ test({ assertEquals(typeof data, "string"); assertEquals(data as string, oldname); - } + }, }); test({ @@ -43,7 +43,7 @@ test({ assert(data instanceof Uint8Array); assertEquals(new TextDecoder().decode(data as Uint8Array), oldname); - } + }, }); test({ @@ -53,7 +53,7 @@ test({ const data = readlinkSync(newname); assertEquals(typeof data, "string"); assertEquals(data as string, oldname); - } + }, }); test({ @@ -63,5 +63,5 @@ test({ const data = readlinkSync(newname, { encoding: "buffer" }); assert(data instanceof Uint8Array); assertEquals(new TextDecoder().decode(data as Uint8Array), oldname); - } + }, }); diff --git a/node/_utils.ts b/node/_utils.ts index f0808e82b1dd..ec89d11a8ee4 100644 --- a/node/_utils.ts +++ b/node/_utils.ts @@ -17,8 +17,8 @@ export function intoCallbackAPI( ...args: any[] ): void { func(...args) - .then(value => cb && cb(null, value)) - .catch(err => cb && cb(err, null)); + .then((value) => cb && cb(null, value)) + .catch((err) => cb && cb(err, null)); } export function intoCallbackAPIWithIntercept( @@ -30,6 +30,6 @@ export function intoCallbackAPIWithIntercept( ...args: any[] ): void { func(...args) - .then(value => cb && cb(null, interceptor(value))) - .catch(err => cb && cb(err, null)); + .then((value) => cb && cb(null, interceptor(value))) + .catch((err) => cb && cb(err, null)); } diff --git a/node/events.ts b/node/events.ts index b2f1d60260dd..aa62e4d43236 100644 --- a/node/events.ts +++ b/node/events.ts @@ -219,7 +219,7 @@ export default class EventEmitter { eventName: string | symbol, listener: Function ): WrappedFunction { - const wrapper = function( + const wrapper = function ( this: { eventName: string | symbol; listener: Function; @@ -235,7 +235,7 @@ export default class EventEmitter { eventName: eventName, listener: listener, rawListener: (wrapper as unknown) as WrappedFunction, - context: this + context: this, }; const wrapped = (wrapper.bind( wrapperContext @@ -462,7 +462,7 @@ export function on( } // Wait until an event happens - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { unconsumedPromises.push({ resolve, reject }); }); }, @@ -489,7 +489,7 @@ export function on( // eslint-disable-next-line @typescript-eslint/no-explicit-any [Symbol.asyncIterator](): any { return this; - } + }, }; emitter.on(event, eventHandler); diff --git a/node/events_test.ts b/node/events_test.ts index b0b74e499c1f..5960290afc63 100644 --- a/node/events_test.ts +++ b/node/events_test.ts @@ -3,7 +3,7 @@ import { assert, assertEquals, fail, - assertThrows + assertThrows, } from "../testing/asserts.ts"; import EventEmitter, { WrappedFunction, once, on } from "./events.ts"; @@ -29,7 +29,7 @@ test({ eventsFired = []; testEmitter.emit("event"); assertEquals(eventsFired, ["event"]); - } + }, }); test({ @@ -41,7 +41,7 @@ test({ testEmitter.on("removeListener", () => { eventsFired.push("removeListener"); }); - const eventFunction = function(): void { + const eventFunction = function (): void { eventsFired.push("event"); }; testEmitter.on("event", eventFunction); @@ -49,7 +49,7 @@ test({ assertEquals(eventsFired, []); testEmitter.removeListener("event", eventFunction); assertEquals(eventsFired, ["removeListener"]); - } + }, }); test({ @@ -62,7 +62,7 @@ test({ EventEmitter.defaultMaxListeners = 20; assertEquals(EventEmitter.defaultMaxListeners, 20); EventEmitter.defaultMaxListeners = 10; //reset back to original value - } + }, }); test({ @@ -73,7 +73,7 @@ test({ assertEquals(1, testEmitter.listenerCount("event")); testEmitter.on("event", shouldNeverBeEmitted); assertEquals(2, testEmitter.listenerCount("event")); - } + }, }); test({ @@ -100,7 +100,7 @@ test({ ); testEmitter.emit("event", 1, 2, 3); assertEquals(eventsFired, ["event(1)", "event(1, 2)", "event(1, 2, 3)"]); - } + }, }); test({ @@ -112,7 +112,7 @@ test({ const sym = Symbol("symbol"); testEmitter.on(sym, shouldNeverBeEmitted); assertEquals(testEmitter.eventNames(), ["event", sym]); - } + }, }); test({ @@ -122,7 +122,7 @@ test({ assertEquals(testEmitter.getMaxListeners(), 10); testEmitter.setMaxListeners(20); assertEquals(testEmitter.getMaxListeners(), 20); - } + }, }); test({ @@ -135,9 +135,9 @@ test({ testEmitter.on("event", testFunction); assertEquals(testEmitter.listeners("event"), [ shouldNeverBeEmitted, - testFunction + testFunction, ]); - } + }, }); test({ @@ -148,7 +148,7 @@ test({ assertEquals(testEmitter.listenerCount("event"), 1); testEmitter.off("event", shouldNeverBeEmitted); assertEquals(testEmitter.listenerCount("event"), 0); - } + }, }); test({ @@ -159,7 +159,7 @@ test({ .on("event", shouldNeverBeEmitted) .on("event", shouldNeverBeEmitted); assertEquals(testEmitter.listenerCount("event"), 2); - } + }, }); test({ @@ -183,7 +183,7 @@ test({ testEmitter.emit("single event"); testEmitter.emit("single event"); assertEquals(eventsFired, ["single event"]); - } + }, }); test({ @@ -203,7 +203,7 @@ test({ }); testEmitter.emit("event"); assertEquals(eventsFired, ["third", "first", "second"]); - } + }, }); test({ @@ -223,7 +223,7 @@ test({ testEmitter.emit("event"); testEmitter.emit("event"); assertEquals(eventsFired, ["third", "first", "second", "first", "second"]); - } + }, }); test({ @@ -242,7 +242,7 @@ test({ assertEquals(testEmitter.listenerCount("event"), 0); assertEquals(testEmitter.listenerCount("other event"), 0); - } + }, }); test({ @@ -265,7 +265,7 @@ test({ assertEquals(testEmitter.listenerCount("event"), 0); assertEquals(testEmitter.listenerCount("other event"), 0); - } + }, }); test({ @@ -284,7 +284,7 @@ test({ testEmitter.removeListener("non-existant event", madeUpEvent); assertEquals(testEmitter.listenerCount("event"), 1); - } + }, }); test({ @@ -307,7 +307,7 @@ test({ eventsProcessed = []; testEmitter.emit("event"); assertEquals(eventsProcessed, ["A"]); - } + }, }); test({ @@ -330,7 +330,7 @@ test({ (rawListenersForOnceEvent[0] as WrappedFunction).listener, listenerB ); - } + }, }); test({ @@ -353,7 +353,7 @@ test({ wrappedFn(); // executing the wrapped listener function will remove it from the event assertEquals(eventsProcessed, ["A"]); assertEquals(testEmitter.listeners("once-event").length, 0); - } + }, }); test({ @@ -366,7 +366,7 @@ test({ // eslint-disable-next-line @typescript-eslint/no-explicit-any const valueArr: any[] = await once(ee, "event"); assertEquals(valueArr, [42, "foo"]); - } + }, }); test({ @@ -380,7 +380,7 @@ test({ // eslint-disable-next-line @typescript-eslint/no-explicit-any const eventObj: any[] = await once(et, "event"); assert(!eventObj[0].isTrusted); - } + }, }); test({ @@ -402,7 +402,7 @@ test({ Error, "must be 'an integer'" ); - } + }, }); test({ @@ -440,7 +440,7 @@ test({ }); ee.emit("error"); assertEquals(events, ["errorMonitor event", "error"]); - } + }, }); test({ @@ -468,7 +468,7 @@ test({ } assertEquals(ee.listenerCount("foo"), 0); assertEquals(ee.listenerCount("error"), 0); - } + }, }); test({ @@ -493,7 +493,7 @@ test({ assertEquals(err, _err); } assertEquals(thrown, true); - } + }, }); test({ @@ -522,7 +522,7 @@ test({ assertEquals(thrown, true); assertEquals(ee.listenerCount("foo"), 0); assertEquals(ee.listenerCount("error"), 0); - } + }, }); test({ @@ -548,7 +548,7 @@ test({ assertEquals(ee.listenerCount("foo"), 0); assertEquals(ee.listenerCount("error"), 0); - } + }, }); test({ @@ -557,7 +557,7 @@ test({ const ee = new EventEmitter(); const iterable = on(ee, "foo"); - setTimeout(function() { + setTimeout(function () { ee.emit("foo", "bar"); ee.emit("foo", 42); iterable.return(); @@ -566,29 +566,29 @@ test({ const results = await Promise.all([ iterable.next(), iterable.next(), - iterable.next() + iterable.next(), ]); assertEquals(results, [ { value: ["bar"], - done: false + done: false, }, { value: [42], - done: false + done: false, }, { value: undefined, - done: true - } + done: true, + }, ]); assertEquals(await iterable.next(), { value: undefined, - done: true + done: true, }); - } + }, }); test({ @@ -620,5 +620,5 @@ test({ assertEquals(expected.length, 0); assertEquals(ee.listenerCount("foo"), 0); assertEquals(ee.listenerCount("error"), 0); - } + }, }); diff --git a/node/fs.ts b/node/fs.ts index 9135441bb256..0681ee5a1cf2 100755 --- a/node/fs.ts +++ b/node/fs.ts @@ -24,5 +24,5 @@ export { readFile, readFileSync, readlink, - readlinkSync + readlinkSync, }; diff --git a/node/module.ts b/node/module.ts index 21992f743110..522eaec7e741 100644 --- a/node/module.ts +++ b/node/module.ts @@ -108,7 +108,7 @@ class Module { // Proxy related code removed. static wrapper = [ "(function (exports, require, module, __filename, __dirname) { ", - "\n});" + "\n});", ]; // Loads a module at the given file path. Returns that module's @@ -235,7 +235,9 @@ class Module { const lookupPaths = Module._resolveLookupPaths(request, fakeParent); for (let j = 0; j < lookupPaths!.length; j++) { - if (!paths.includes(lookupPaths![j])) paths.push(lookupPaths![j]); + if (!paths.includes(lookupPaths![j])) { + paths.push(lookupPaths![j]); + } } } } @@ -357,8 +359,9 @@ class Module { const cachedModule = Module._cache[filename]; if (cachedModule !== undefined) { updateChildren(parent, cachedModule, true); - if (!cachedModule.loaded) + if (!cachedModule.loaded) { return getExportsForCircularRequire(cachedModule); + } return cachedModule.exports; } delete relativeResolveCache[relResolveCacheIdentifier]; @@ -370,8 +373,9 @@ class Module { const cachedModule = Module._cache[filename]; if (cachedModule !== undefined) { updateChildren(parent, cachedModule, true); - if (!cachedModule.loaded) + if (!cachedModule.loaded) { return getExportsForCircularRequire(cachedModule); + } return cachedModule.exports; } @@ -436,8 +440,9 @@ class Module { if ( from.charCodeAt(from.length - 1) === CHAR_BACKWARD_SLASH && from.charCodeAt(from.length - 2) === CHAR_COLON - ) + ) { return [from + "node_modules"]; + } const paths = []; for (let i = from.length - 1, p = 0, last = from.length; i >= 0; --i) { @@ -663,7 +668,7 @@ function readPackage(requestPath: string): PackageInfo | null { name: parsed.name, main: parsed.main, exports: parsed.exports, - type: parsed.type + type: parsed.type, }; packageJsonCache.set(jsonPath, filtered); return filtered; @@ -685,11 +690,12 @@ function readPackageScope( checkPath = checkPath.slice(0, separatorIndex); if (checkPath.endsWith(path.sep + "node_modules")) return false; const pjson = readPackage(checkPath); - if (pjson) + if (pjson) { return { path: checkPath, - data: pjson + data: pjson, }; + } } return false; } @@ -822,11 +828,13 @@ function applyExports(basePath: string, expansion: string): string { const mappingKey = `.${expansion}`; let pkgExports = readPackageExports(basePath); - if (pkgExports === undefined || pkgExports === null) + if (pkgExports === undefined || pkgExports === null) { return path.resolve(basePath, mappingKey); + } - if (isConditionalDotExportSugar(pkgExports, basePath)) + if (isConditionalDotExportSugar(pkgExports, basePath)) { pkgExports = { ".": pkgExports }; + } if (typeof pkgExports === "object") { if (pkgExports.hasOwnProperty(mappingKey)) { @@ -1005,11 +1013,12 @@ const CircularRequirePrototypeWarningProxy = new Proxy( }, getOwnPropertyDescriptor(target, prop): PropertyDescriptor | undefined { - if (target.hasOwnProperty(prop)) + if (target.hasOwnProperty(prop)) { return Object.getOwnPropertyDescriptor(target, prop); + } emitCircularRequireWarning(prop); return undefined; - } + }, } ); @@ -1230,16 +1239,21 @@ function pathToFileURL(filepath: string): URL { (filePathLast === CHAR_FORWARD_SLASH || (isWindows && filePathLast === CHAR_BACKWARD_SLASH)) && resolved[resolved.length - 1] !== path.sep - ) + ) { resolved += "/"; + } const outURL = new URL("file://"); if (resolved.includes("%")) resolved = resolved.replace(percentRegEx, "%25"); // In posix, "/" is a valid character in paths - if (!isWindows && resolved.includes("\\")) + if (!isWindows && resolved.includes("\\")) { resolved = resolved.replace(backslashRegEx, "%5C"); - if (resolved.includes("\n")) resolved = resolved.replace(newlineRegEx, "%0A"); - if (resolved.includes("\r")) + } + if (resolved.includes("\n")) { + resolved = resolved.replace(newlineRegEx, "%0A"); + } + if (resolved.includes("\r")) { resolved = resolved.replace(carriageReturnRegEx, "%0D"); + } if (resolved.includes("\t")) resolved = resolved.replace(tabRegEx, "%09"); outURL.pathname = resolved; return outURL; diff --git a/node/os.ts b/node/os.ts index 4bc70d1ffa4a..7c61e910b1f7 100644 --- a/node/os.ts +++ b/node/os.ts @@ -219,7 +219,7 @@ export const constants = { signals: Deno.Signal, priority: { // see https://nodejs.org/docs/latest-v12.x/api/os.html#os_priority_constants - } + }, }; export const EOL = Deno.build.os == "win" ? fsEOL.CRLF : fsEOL.LF; diff --git a/node/os_test.ts b/node/os_test.ts index a73a2d4e99d2..f0b9ca79d425 100644 --- a/node/os_test.ts +++ b/node/os_test.ts @@ -6,42 +6,42 @@ test({ name: "build architecture is a string", fn() { assertEquals(typeof os.arch(), "string"); - } + }, }); test({ name: "home directory is a string", fn() { assertEquals(typeof os.homedir(), "string"); - } + }, }); test({ name: "tmp directory is a string", fn() { assertEquals(typeof os.tmpdir(), "string"); - } + }, }); test({ name: "hostname is a string", fn() { assertEquals(typeof os.hostname(), "string"); - } + }, }); test({ name: "platform is a string", fn() { assertEquals(typeof os.platform(), "string"); - } + }, }); test({ name: "release is a string", fn() { assertEquals(typeof os.release(), "string"); - } + }, }); test({ @@ -61,7 +61,7 @@ test({ Error, "must be >= -2147483648 && <= 2147483647" ); - } + }, }); test({ @@ -81,7 +81,7 @@ test({ Error, "pid must be >= -2147483648 && <= 2147483647" ); - } + }, }); test({ @@ -115,7 +115,7 @@ test({ Error, "priority must be >= -20 && <= 19" ); - } + }, }); test({ @@ -150,7 +150,7 @@ test({ Error, "priority must be >= -20 && <= 19" ); - } + }, }); test({ @@ -160,21 +160,21 @@ test({ assertEquals(os.constants.signals.SIGKILL, Deno.Signal.SIGKILL); assertEquals(os.constants.signals.SIGCONT, Deno.Signal.SIGCONT); assertEquals(os.constants.signals.SIGXFSZ, Deno.Signal.SIGXFSZ); - } + }, }); test({ name: "EOL is as expected", fn() { assert(os.EOL == "\r\n" || os.EOL == "\n"); - } + }, }); test({ name: "Endianness is determined", fn() { assert(["LE", "BE"].includes(os.endianness())); - } + }, }); test({ @@ -185,7 +185,7 @@ test({ assertEquals(typeof result[0], "number"); assertEquals(typeof result[1], "number"); assertEquals(typeof result[2], "number"); - } + }, }); test({ @@ -196,7 +196,7 @@ test({ assertEquals(`${os.homedir}`, os.homedir()); assertEquals(`${os.hostname}`, os.hostname()); assertEquals(`${os.platform}`, os.platform()); - } + }, }); test({ @@ -265,5 +265,5 @@ test({ Error, "Not implemented" ); - } + }, }); diff --git a/node/process.ts b/node/process.ts index 35de23b8802f..89d383e8ef1f 100644 --- a/node/process.ts +++ b/node/process.ts @@ -4,7 +4,7 @@ const version = `v${Deno.version.deno}`; const versions = { node: Deno.version.deno, - ...Deno.version + ...Deno.version, }; const osToPlatform = (os: Deno.OperatingSystem): string => @@ -38,5 +38,5 @@ export const process = { get argv(): string[] { // Deno.execPath() also requires --allow-env return [Deno.execPath(), ...Deno.args]; - } + }, }; diff --git a/node/process_test.ts b/node/process_test.ts index f44143acbc3f..b9d5388eace1 100644 --- a/node/process_test.ts +++ b/node/process_test.ts @@ -14,7 +14,7 @@ test({ assert(process.cwd().match(/\Wnode$/)); process.chdir(".."); assert(process.cwd().match(/\Wstd$/)); - } + }, }); test({ @@ -30,7 +30,7 @@ test({ // "The system cannot find the file specified. (os error 2)" so "file" is // the only common string here. ); - } + }, }); test({ @@ -40,14 +40,14 @@ test({ assertEquals(typeof process.version, "string"); assertEquals(typeof process.versions, "object"); assertEquals(typeof process.versions.node, "string"); - } + }, }); test({ name: "process.platform", fn() { assertEquals(typeof process.platform, "string"); - } + }, }); test({ @@ -56,7 +56,7 @@ test({ assertEquals(typeof process.arch, "string"); // TODO(rsp): make sure that the arch strings should be the same in Node and Deno: assertEquals(process.arch, Deno.build.arch); - } + }, }); test({ @@ -64,7 +64,7 @@ test({ fn() { assertEquals(typeof process.pid, "number"); assertEquals(process.pid, Deno.pid); - } + }, }); test({ @@ -78,7 +78,7 @@ test({ Error, "implemented" ); - } + }, }); test({ @@ -90,12 +90,12 @@ test({ "deno included in the file name of argv[0]" ); // we cannot test for anything else (we see test runner arguments here) - } + }, }); test({ name: "process.env", fn() { assertEquals(typeof process.env.PATH, "string"); - } + }, }); diff --git a/node/querystring.ts b/node/querystring.ts index fc5a00a13e51..427183bf0277 100644 --- a/node/querystring.ts +++ b/node/querystring.ts @@ -13,7 +13,7 @@ export function parse( ): { [key: string]: string[] | string } { const entries = str .split(sep) - .map(entry => entry.split(eq).map(decodeURIComponent)); + .map((entry) => entry.split(eq).map(decodeURIComponent)); const final: { [key: string]: string[] | string } = {}; let i = 0; diff --git a/node/querystring_test.ts b/node/querystring_test.ts index d8cb1ec35a34..0a37eee6b098 100644 --- a/node/querystring_test.ts +++ b/node/querystring_test.ts @@ -10,11 +10,11 @@ test({ a: "hello", b: 5, c: true, - d: ["foo", "bar"] + d: ["foo", "bar"], }), "a=hello&b=5&c=true&d=foo&d=bar" ); - } + }, }); test({ @@ -24,7 +24,7 @@ test({ a: "hello", b: "5", c: "true", - d: ["foo", "bar"] + d: ["foo", "bar"], }); - } + }, }); diff --git a/node/tests/cjs/cjs_builtin.js b/node/tests/cjs/cjs_builtin.js index 3d182981aa2b..d821d2558b67 100644 --- a/node/tests/cjs/cjs_builtin.js +++ b/node/tests/cjs/cjs_builtin.js @@ -6,5 +6,5 @@ const path = require("path"); module.exports = { readFileSync: fs.readFileSync, isNull: util.isNull, - extname: path.extname + extname: path.extname, }; diff --git a/node/tests/node_modules/left-pad/index.js b/node/tests/node_modules/left-pad/index.js index e90aec35d979..8501bca1b663 100644 --- a/node/tests/node_modules/left-pad/index.js +++ b/node/tests/node_modules/left-pad/index.js @@ -3,37 +3,37 @@ * and/or modify it under the terms of the Do What The Fuck You Want * To Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ -'use strict'; +"use strict"; module.exports = leftPad; var cache = [ - '', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ' + "", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " ]; -function leftPad (str, len, ch) { +function leftPad(str, len, ch) { // convert `str` to a `string` - str = str + ''; + str = str + ""; // `len` is the `pad`'s length now len = len - str.length; // doesn't need to pad if (len <= 0) return str; // `ch` defaults to `' '` - if (!ch && ch !== 0) ch = ' '; + if (!ch && ch !== 0) ch = " "; // convert `ch` to a `string` cuz it could be a number - ch = ch + ''; + ch = ch + ""; // cache common use cases - if (ch === ' ' && len < 10) return cache[len] + str; + if (ch === " " && len < 10) return cache[len] + str; // `pad` starts with an empty string - var pad = ''; + var pad = ""; // loop while (true) { // add `ch` to `pad` if `len` is odd diff --git a/node/util_test.ts b/node/util_test.ts index 751dba57e77e..05cec15df671 100644 --- a/node/util_test.ts +++ b/node/util_test.ts @@ -11,7 +11,7 @@ test({ assert(util.isBoolean(false)); assert(!util.isBoolean("deno")); assert(!util.isBoolean("true")); - } + }, }); test({ @@ -22,7 +22,7 @@ test({ assert(!util.isNull(n)); assert(!util.isNull(0)); assert(!util.isNull({})); - } + }, }); test({ @@ -33,7 +33,7 @@ test({ assert(util.isNullOrUndefined(n)); assert(!util.isNullOrUndefined({})); assert(!util.isNullOrUndefined("undefined")); - } + }, }); test({ @@ -43,7 +43,7 @@ test({ assert(util.isNumber(new Number(666))); assert(!util.isNumber("999")); assert(!util.isNumber(null)); - } + }, }); test({ @@ -52,7 +52,7 @@ test({ assert(util.isString("deno")); assert(util.isString(new String("DIO"))); assert(!util.isString(1337)); - } + }, }); test({ @@ -61,7 +61,7 @@ test({ assert(util.isSymbol(Symbol())); assert(!util.isSymbol(123)); assert(!util.isSymbol("string")); - } + }, }); test({ @@ -71,7 +71,7 @@ test({ assert(util.isUndefined(t)); assert(!util.isUndefined("undefined")); assert(!util.isUndefined({})); - } + }, }); test({ @@ -81,7 +81,7 @@ test({ assert(util.isObject(dio)); assert(util.isObject(new RegExp(/Toki Wo Tomare/))); assert(!util.isObject("Jotaro")); - } + }, }); test({ @@ -93,17 +93,17 @@ test({ assert(util.isError(java)); assert(util.isError(nodejs)); assert(!util.isError(deno)); - } + }, }); test({ name: "[util] isFunction", fn() { - const f = function(): void {}; + const f = function (): void {}; assert(util.isFunction(f)); assert(!util.isFunction({})); assert(!util.isFunction(new RegExp(/f/))); - } + }, }); test({ @@ -113,7 +113,7 @@ test({ assert(util.isRegExp(/fuManchu/)); assert(!util.isRegExp({ evil: "eye" })); assert(!util.isRegExp(null)); - } + }, }); test({ @@ -122,5 +122,5 @@ test({ assert(util.isArray([])); assert(!util.isArray({ yaNo: "array" })); assert(!util.isArray(null)); - } + }, }); diff --git a/path/extname_test.ts b/path/extname_test.ts index d9e14bb48f7b..16ca7a2f9c6b 100644 --- a/path/extname_test.ts +++ b/path/extname_test.ts @@ -49,11 +49,11 @@ const pairs = [ ["file/", ""], ["file//", ""], ["file./", "."], - ["file.//", "."] + ["file.//", "."], ]; test(function extname() { - pairs.forEach(function(p) { + pairs.forEach(function (p) { const input = p[0]; const expected = p[1]; assertEquals(expected, path.posix.extname(input)); @@ -71,7 +71,7 @@ test(function extname() { }); test(function extnameWin32() { - pairs.forEach(function(p) { + pairs.forEach(function (p) { const input = p[0].replace(slashRE, "\\"); const expected = p[1]; assertEquals(expected, path.win32.extname(input)); diff --git a/path/glob.ts b/path/glob.ts index 8eb106b251da..a11865c26efa 100644 --- a/path/glob.ts +++ b/path/glob.ts @@ -44,7 +44,7 @@ export function globToRegExp( extended, globstar, strict: false, - filepath: true + filepath: true, }); assert(result.path != null); return result.path.regex; diff --git a/path/glob_test.ts b/path/glob_test.ts index d8da1a47b624..8c49adecae28 100644 --- a/path/glob_test.ts +++ b/path/glob_test.ts @@ -32,17 +32,17 @@ test({ ); assertEquals( globToRegExp(join("unicorn", "!(sleeping)", "bathroom.ts"), { - extended: true + extended: true, }).test(join("unicorn", "flying", "bathroom.ts")), true ); assertEquals( globToRegExp(join("unicorn", "(!sleeping)", "bathroom.ts"), { - extended: true + extended: true, }).test(join("unicorn", "sleeping", "bathroom.ts")), false ); - } + }, }); testWalk( @@ -55,7 +55,7 @@ testWalk( }, async function globInWalkWildcard(): Promise { const arr = await walkArray(".", { - match: [globToRegExp(join("*", "*.ts"))] + match: [globToRegExp(join("*", "*.ts"))], }); assertEquals(arr.length, 2); assertEquals(arr[0], "a/x.ts"); @@ -74,9 +74,9 @@ testWalk( match: [ globToRegExp(join("a", "**", "*.ts"), { flags: "g", - globstar: true - }) - ] + globstar: true, + }), + ], }); assertEquals(arr.length, 1); assertEquals(arr[0], "a/yo/x.ts"); @@ -98,9 +98,9 @@ testWalk( match: [ globToRegExp(join("a", "+(raptor|deno)", "*.ts"), { flags: "g", - extended: true - }) - ] + extended: true, + }), + ], }); assertEquals(arr.length, 2); assertEquals(arr[0], "a/deno/x.ts"); @@ -116,7 +116,7 @@ testWalk( }, async function globInWalkWildcardExtension(): Promise { const arr = await walkArray(".", { - match: [globToRegExp("x.*", { flags: "g", globstar: true })] + match: [globToRegExp("x.*", { flags: "g", globstar: true })], }); assertEquals(arr.length, 2); assertEquals(arr[0], "x.js"); @@ -236,7 +236,7 @@ test({ assert(!isGlob("\\a/b/c/\\[a-z\\].js")); assert(!isGlob("abc/\\(aaa|bbb).js")); assert(!isGlob("abc/\\?.js")); - } + }, }); test(function normalizeGlobGlobstar(): void { diff --git a/path/globrex.ts b/path/globrex.ts index 695294834c6d..0fe833a52ed1 100644 --- a/path/globrex.ts +++ b/path/globrex.ts @@ -54,7 +54,7 @@ export function globrex( globstar = false, strict = false, filepath = false, - flags = "" + flags = "", }: GlobrexOptions = {} ): GlobrexResult { const sepPattern = new RegExp(`^${SEP}${strict ? "" : "+"}$`); @@ -319,7 +319,7 @@ export function globrex( globstar: new RegExp( !flags.includes("g") ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT, flags - ) + ), }; } diff --git a/path/globrex_test.ts b/path/globrex_test.ts index 29f039837d84..27541a5c8c69 100644 --- a/path/globrex_test.ts +++ b/path/globrex_test.ts @@ -34,7 +34,7 @@ test({ t.equal(typeof globrex, "function", "constructor is a typeof function"); t.equal(res instanceof Object, true, "returns object"); t.equal(res.regex.toString(), "/^.*\\.js$/", "returns regex object"); - } + }, }); test({ @@ -64,7 +64,7 @@ test({ true, "match zero characters" ); - } + }, }); test({ @@ -72,7 +72,7 @@ test({ fn(): void { t.equal( match("*.min.js", "http://example.com/jquery.min.js", { - globstar: false + globstar: false, }), true, "complex match" @@ -84,7 +84,7 @@ test({ ); t.equal( match("*/js/*.js", "http://example.com/js/jquery.min.js", { - globstar: false + globstar: false, }), true, "complex match" @@ -171,11 +171,11 @@ test({ t.equal(match("/js*jq*.js", "http://example.com/js/jquery.min.js"), false); t.equal( match("/js*jq*.js", "http://example.com/js/jquery.min.js", { - flags: "g" + flags: "g", }), true ); - } + }, }); test({ @@ -215,7 +215,7 @@ test({ tester(true); tester(false); - } + }, }); test({ @@ -246,7 +246,7 @@ test({ tester(true); tester(false); - } + }, }); test({ @@ -304,7 +304,7 @@ test({ match("[[:digit:]b]/bar.txt", "a/bar.txt", { extended: true }), false ); - } + }, }); test({ @@ -320,7 +320,7 @@ test({ match("foo{bar,baaz}", "foobaaz", { extended: true, globstar, - flag: "g" + flag: "g", }), true ); @@ -328,7 +328,7 @@ test({ match("foo{bar,baaz}", "foobar", { extended: true, globstar, - flag: "g" + flag: "g", }), true ); @@ -336,7 +336,7 @@ test({ match("foo{bar,baaz}", "foobuzz", { extended: true, globstar, - flag: "g" + flag: "g", }), false ); @@ -344,7 +344,7 @@ test({ match("foo{bar,b*z}", "foobuzz", { extended: true, globstar, - flag: "g" + flag: "g", }), true ); @@ -352,7 +352,7 @@ test({ tester(true); tester(false); - } + }, }); test({ @@ -444,7 +444,7 @@ test({ tester(true); tester(false); - } + }, }); test({ @@ -471,7 +471,7 @@ test({ match("http://foo.com/**", "http://foo.com/bar/baz/jquery.min.js", { extended: true, globstar, - flags: "g" + flags: "g", }), true ); @@ -479,7 +479,7 @@ test({ tester(true); tester(false); - } + }, }); test({ @@ -496,7 +496,7 @@ test({ tester(true); tester(false); - } + }, }); test({ @@ -574,25 +574,25 @@ test({ t.equal( match("http://foo.com/*", "http://foo.com/bar/baz/jquery.min.js", { extended: true, - globstar: true + globstar: true, }), false ); t.equal( match("http://foo.com/*", "http://foo.com/bar/baz/jquery.min.js", { - globstar: true + globstar: true, }), false ); t.equal( match("http://foo.com/*", "http://foo.com/bar/baz/jquery.min.js", { - globstar: false + globstar: false, }), true ); t.equal( match("http://foo.com/**", "http://foo.com/bar/baz/jquery.min.js", { - globstar: true + globstar: true, }), true ); @@ -636,7 +636,7 @@ test({ ), false ); - } + }, }); test({ @@ -689,7 +689,7 @@ test({ match("?(ba[!zr]|qux)baz.txt", "bazbaz.txt", { extended: true }), false ); - } + }, }); test({ @@ -715,18 +715,18 @@ test({ t.equal( match("*(foo|bar)/**/*.txt", "foo/hello/world/bar.txt", { extended: true, - globstar: true + globstar: true, }), true ); t.equal( match("*(foo|bar)/**/*.txt", "foo/world/bar.txt", { extended: true, - globstar: true + globstar: true, }), true ); - } + }, }); test({ @@ -736,7 +736,7 @@ test({ t.equal(match("+foo.txt", "+foo.txt", { extended: true }), true); t.equal(match("+(foo).txt", ".txt", { extended: true }), false); t.equal(match("+(foo|bar).txt", "foobar.txt", { extended: true }), true); - } + }, }); test({ @@ -757,7 +757,7 @@ test({ match("@(foo|baz)bar.txt", "toofoobar.txt", { extended: true }), false ); - } + }, }); test({ @@ -774,7 +774,7 @@ test({ match("!({foo,bar})baz.txt", "foobaz.txt", { extended: true }), false ); - } + }, }); test({ @@ -783,7 +783,7 @@ test({ t.equal(match("foo//bar.txt", "foo/bar.txt"), true); t.equal(match("foo///bar.txt", "foo/bar.txt"), true); t.equal(match("foo///bar.txt", "foo/bar.txt", { strict: true }), false); - } + }, }); test({ @@ -791,7 +791,7 @@ test({ fn(): void { t.equal( match("**/*/?yfile.{md,js,txt}", "foo/bar/baz/myfile.md", { - extended: true + extended: true, }), true ); @@ -823,5 +823,5 @@ test({ match("[[:digit:]_.]/file.js", "z/file.js", { extended: true }), false ); - } + }, }); diff --git a/path/join_test.ts b/path/join_test.ts index a73cf36794ed..d9a38fb8219a 100644 --- a/path/join_test.ts +++ b/path/join_test.ts @@ -53,7 +53,7 @@ const joinTests = [["/", "//foo"], "/foo"], [["/", "", "/foo"], "/foo"], [["", "/", "foo"], "/foo"], - [["", "/", "/foo"], "/foo"] + [["", "/", "/foo"], "/foo"], ]; // Windows-specific join tests @@ -103,11 +103,11 @@ const windowsJoinTests = [ [["c:.", "/"], "c:.\\"], [["c:.", "file"], "c:file"], [["c:", "/"], "c:\\"], - [["c:", "file"], "c:\\file"] + [["c:", "file"], "c:\\file"], ]; test(function join() { - joinTests.forEach(function(p) { + joinTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.posix.join.apply(null, _p); assertEquals(actual, p[1]); @@ -115,12 +115,12 @@ test(function join() { }); test(function joinWin32() { - joinTests.forEach(function(p) { + joinTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.win32.join.apply(null, _p).replace(backslashRE, "/"); assertEquals(actual, p[1]); }); - windowsJoinTests.forEach(function(p) { + windowsJoinTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.win32.join.apply(null, _p); assertEquals(actual, p[1]); diff --git a/path/parse_format_test.ts b/path/parse_format_test.ts index 0a7e83bbad46..60be3c9a1d27 100644 --- a/path/parse_format_test.ts +++ b/path/parse_format_test.ts @@ -24,15 +24,14 @@ const winPaths = [ ["C:\\", "C:\\"], ["C:\\abc", "C:\\"], ["", ""], - // unc ["\\\\server\\share\\file_path", "\\\\server\\share\\"], [ "\\\\server two\\shared folder\\file path.zip", - "\\\\server two\\shared folder\\" + "\\\\server two\\shared folder\\", ], ["\\\\teela\\admin$\\system32", "\\\\teela\\admin$\\"], - ["\\\\?\\UNC\\server\\share", "\\\\?\\UNC\\"] + ["\\\\?\\UNC\\server\\share", "\\\\?\\UNC\\"], ]; const winSpecialCaseParseTests = [["/foo/bar", { root: "/" }]]; @@ -44,7 +43,7 @@ const winSpecialCaseFormatTests = [ [{ name: "index", ext: ".html" }, "index.html"], [{ dir: "some\\dir", name: "index", ext: ".html" }, "some\\dir\\index.html"], [{ root: "C:\\", name: "index", ext: ".html" }, "C:\\index.html"], - [{}, ""] + [{}, ""], ]; const unixPaths = [ @@ -68,7 +67,7 @@ const unixPaths = [ ["/.", "/"], ["/.foo", "/"], ["/.foo.bar", "/"], - ["/foo/bar.baz", "/"] + ["/foo/bar.baz", "/"], ]; const unixSpecialCaseFormatTests = [ @@ -78,11 +77,11 @@ const unixSpecialCaseFormatTests = [ [{ name: "index", ext: ".html" }, "index.html"], [{ dir: "some/dir", name: "index", ext: ".html" }, "some/dir/index.html"], [{ root: "/", name: "index", ext: ".html" }, "/index.html"], - [{}, ""] + [{}, ""], ]; function checkParseFormat(path: any, paths: any): void { - paths.forEach(function(p: Array>) { + paths.forEach(function (p: Array>) { const element = p[0]; const output = path.parse(element); assertEquals(typeof output.root, "string"); @@ -98,18 +97,18 @@ function checkParseFormat(path: any, paths: any): void { } function checkSpecialCaseParseFormat(path: any, testCases: any): void { - testCases.forEach(function(testCase: Array>) { + testCases.forEach(function (testCase: Array>) { const element = testCase[0]; const expect = testCase[1]; const output = path.parse(element); - Object.keys(expect).forEach(function(key) { + Object.keys(expect).forEach(function (key) { assertEquals(output[key], expect[key]); }); }); } function checkFormat(path: any, testCases: unknown[][]): void { - testCases.forEach(function(testCase) { + testCases.forEach(function (testCase) { assertEquals(path.format(testCase[0]), testCase[1]); }); } @@ -138,7 +137,7 @@ const windowsTrailingTests = [ ["\\\\", { root: "\\", dir: "\\", base: "", ext: "", name: "" }], [ "c:\\foo\\\\\\", - { root: "c:\\", dir: "c:\\", base: "foo", ext: "", name: "foo" } + { root: "c:\\", dir: "c:\\", base: "foo", ext: "", name: "foo" }, ], [ "D:\\foo\\\\\\bar.baz", @@ -147,9 +146,9 @@ const windowsTrailingTests = [ dir: "D:\\foo\\\\", base: "bar.baz", ext: ".baz", - name: "bar" - } - ] + name: "bar", + }, + ], ]; const posixTrailingTests = [ @@ -159,12 +158,12 @@ const posixTrailingTests = [ ["/foo///", { root: "/", dir: "/", base: "foo", ext: "", name: "foo" }], [ "/foo///bar.baz", - { root: "/", dir: "/foo//", base: "bar.baz", ext: ".baz", name: "bar" } - ] + { root: "/", dir: "/foo//", base: "bar.baz", ext: ".baz", name: "bar" }, + ], ]; test(function parseTrailingWin32() { - windowsTrailingTests.forEach(function(p) { + windowsTrailingTests.forEach(function (p) { const actual = path.win32.parse(p[0] as string); const expected = p[1]; assertEquals(actual, expected); @@ -172,7 +171,7 @@ test(function parseTrailingWin32() { }); test(function parseTrailing() { - posixTrailingTests.forEach(function(p) { + posixTrailingTests.forEach(function (p) { const actual = path.posix.parse(p[0] as string); const expected = p[1]; assertEquals(actual, expected); diff --git a/path/posix.ts b/path/posix.ts index 4377fd542769..ba4cf74992d5 100644 --- a/path/posix.ts +++ b/path/posix.ts @@ -9,7 +9,7 @@ import { assertPath, normalizeString, isPosixPathSeparator, - _format + _format, } from "./utils.ts"; export const sep = "/"; @@ -205,8 +205,9 @@ export function dirname(path: string): string { } export function basename(path: string, ext = ""): string { - if (ext !== undefined && typeof ext !== "string") + if (ext !== undefined && typeof ext !== "string") { throw new TypeError('"ext" argument must be a string'); + } assertPath(path); let start = 0; diff --git a/path/relative_test.ts b/path/relative_test.ts index 3fe5aab4b7e0..af5896236219 100644 --- a/path/relative_test.ts +++ b/path/relative_test.ts @@ -6,58 +6,52 @@ import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; const relativeTests = { - win32: - // arguments result - [ - ["c:/blah\\blah", "d:/games", "d:\\games"], - ["c:/aaaa/bbbb", "c:/aaaa", ".."], - ["c:/aaaa/bbbb", "c:/cccc", "..\\..\\cccc"], - ["c:/aaaa/bbbb", "c:/aaaa/bbbb", ""], - ["c:/aaaa/bbbb", "c:/aaaa/cccc", "..\\cccc"], - ["c:/aaaa/", "c:/aaaa/cccc", "cccc"], - ["c:/", "c:\\aaaa\\bbbb", "aaaa\\bbbb"], - ["c:/aaaa/bbbb", "d:\\", "d:\\"], - ["c:/AaAa/bbbb", "c:/aaaa/bbbb", ""], - ["c:/aaaaa/", "c:/aaaa/cccc", "..\\aaaa\\cccc"], - ["C:\\foo\\bar\\baz\\quux", "C:\\", "..\\..\\..\\.."], - [ - "C:\\foo\\test", - "C:\\foo\\test\\bar\\package.json", - "bar\\package.json" - ], - ["C:\\foo\\bar\\baz-quux", "C:\\foo\\bar\\baz", "..\\baz"], - ["C:\\foo\\bar\\baz", "C:\\foo\\bar\\baz-quux", "..\\baz-quux"], - ["\\\\foo\\bar", "\\\\foo\\bar\\baz", "baz"], - ["\\\\foo\\bar\\baz", "\\\\foo\\bar", ".."], - ["\\\\foo\\bar\\baz-quux", "\\\\foo\\bar\\baz", "..\\baz"], - ["\\\\foo\\bar\\baz", "\\\\foo\\bar\\baz-quux", "..\\baz-quux"], - ["C:\\baz-quux", "C:\\baz", "..\\baz"], - ["C:\\baz", "C:\\baz-quux", "..\\baz-quux"], - ["\\\\foo\\baz-quux", "\\\\foo\\baz", "..\\baz"], - ["\\\\foo\\baz", "\\\\foo\\baz-quux", "..\\baz-quux"], - ["C:\\baz", "\\\\foo\\bar\\baz", "\\\\foo\\bar\\baz"], - ["\\\\foo\\bar\\baz", "C:\\baz", "C:\\baz"] - ], - posix: - // arguments result - [ - ["/var/lib", "/var", ".."], - ["/var/lib", "/bin", "../../bin"], - ["/var/lib", "/var/lib", ""], - ["/var/lib", "/var/apache", "../apache"], - ["/var/", "/var/lib", "lib"], - ["/", "/var/lib", "var/lib"], - ["/foo/test", "/foo/test/bar/package.json", "bar/package.json"], - ["/Users/a/web/b/test/mails", "/Users/a/web/b", "../.."], - ["/foo/bar/baz-quux", "/foo/bar/baz", "../baz"], - ["/foo/bar/baz", "/foo/bar/baz-quux", "../baz-quux"], - ["/baz-quux", "/baz", "../baz"], - ["/baz", "/baz-quux", "../baz-quux"] - ] + // arguments result + win32: [ + ["c:/blah\\blah", "d:/games", "d:\\games"], + ["c:/aaaa/bbbb", "c:/aaaa", ".."], + ["c:/aaaa/bbbb", "c:/cccc", "..\\..\\cccc"], + ["c:/aaaa/bbbb", "c:/aaaa/bbbb", ""], + ["c:/aaaa/bbbb", "c:/aaaa/cccc", "..\\cccc"], + ["c:/aaaa/", "c:/aaaa/cccc", "cccc"], + ["c:/", "c:\\aaaa\\bbbb", "aaaa\\bbbb"], + ["c:/aaaa/bbbb", "d:\\", "d:\\"], + ["c:/AaAa/bbbb", "c:/aaaa/bbbb", ""], + ["c:/aaaaa/", "c:/aaaa/cccc", "..\\aaaa\\cccc"], + ["C:\\foo\\bar\\baz\\quux", "C:\\", "..\\..\\..\\.."], + ["C:\\foo\\test", "C:\\foo\\test\\bar\\package.json", "bar\\package.json"], + ["C:\\foo\\bar\\baz-quux", "C:\\foo\\bar\\baz", "..\\baz"], + ["C:\\foo\\bar\\baz", "C:\\foo\\bar\\baz-quux", "..\\baz-quux"], + ["\\\\foo\\bar", "\\\\foo\\bar\\baz", "baz"], + ["\\\\foo\\bar\\baz", "\\\\foo\\bar", ".."], + ["\\\\foo\\bar\\baz-quux", "\\\\foo\\bar\\baz", "..\\baz"], + ["\\\\foo\\bar\\baz", "\\\\foo\\bar\\baz-quux", "..\\baz-quux"], + ["C:\\baz-quux", "C:\\baz", "..\\baz"], + ["C:\\baz", "C:\\baz-quux", "..\\baz-quux"], + ["\\\\foo\\baz-quux", "\\\\foo\\baz", "..\\baz"], + ["\\\\foo\\baz", "\\\\foo\\baz-quux", "..\\baz-quux"], + ["C:\\baz", "\\\\foo\\bar\\baz", "\\\\foo\\bar\\baz"], + ["\\\\foo\\bar\\baz", "C:\\baz", "C:\\baz"], + ], + // arguments result + posix: [ + ["/var/lib", "/var", ".."], + ["/var/lib", "/bin", "../../bin"], + ["/var/lib", "/var/lib", ""], + ["/var/lib", "/var/apache", "../apache"], + ["/var/", "/var/lib", "lib"], + ["/", "/var/lib", "var/lib"], + ["/foo/test", "/foo/test/bar/package.json", "bar/package.json"], + ["/Users/a/web/b/test/mails", "/Users/a/web/b", "../.."], + ["/foo/bar/baz-quux", "/foo/bar/baz", "../baz"], + ["/foo/bar/baz", "/foo/bar/baz-quux", "../baz-quux"], + ["/baz-quux", "/baz", "../baz"], + ["/baz", "/baz-quux", "../baz-quux"], + ], }; test(function relative() { - relativeTests.posix.forEach(function(p) { + relativeTests.posix.forEach(function (p) { const expected = p[2]; const actual = path.posix.relative(p[0], p[1]); assertEquals(actual, expected); @@ -65,7 +59,7 @@ test(function relative() { }); test(function relativeWin32() { - relativeTests.win32.forEach(function(p) { + relativeTests.win32.forEach(function (p) { const expected = p[2]; const actual = path.win32.relative(p[0], p[1]); assertEquals(actual, expected); diff --git a/path/resolve_test.ts b/path/resolve_test.ts index 2fc49e398dd8..95aa84cce351 100644 --- a/path/resolve_test.ts +++ b/path/resolve_test.ts @@ -20,8 +20,8 @@ const windowsTests = [["c:/", "///some//dir"], "c:\\some\\dir"], [ ["C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js"], - "C:\\foo\\tmp.3\\cycles\\root.js" - ] + "C:\\foo\\tmp.3\\cycles\\root.js", + ], ]; const posixTests = // arguments result @@ -31,11 +31,11 @@ const posixTests = [["a/b/c/", "../../.."], cwd()], [["."], cwd()], [["/some/dir", ".", "/absolute/"], "/absolute"], - [["/foo/tmp.3/", "../tmp.3/cycles/root.js"], "/foo/tmp.3/cycles/root.js"] + [["/foo/tmp.3/", "../tmp.3/cycles/root.js"], "/foo/tmp.3/cycles/root.js"], ]; test(function resolve() { - posixTests.forEach(function(p) { + posixTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.posix.resolve.apply(null, _p); assertEquals(actual, p[1]); @@ -43,7 +43,7 @@ test(function resolve() { }); test(function resolveWin32() { - windowsTests.forEach(function(p) { + windowsTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.win32.resolve.apply(null, _p); assertEquals(actual, p[1]); diff --git a/path/utils.ts b/path/utils.ts index cb1c14c16148..fc3dc5be9517 100644 --- a/path/utils.ts +++ b/path/utils.ts @@ -9,7 +9,7 @@ import { CHAR_LOWERCASE_Z, CHAR_DOT, CHAR_FORWARD_SLASH, - CHAR_BACKWARD_SLASH + CHAR_BACKWARD_SLASH, } from "./constants.ts"; export function assertPath(path: string): void { diff --git a/path/win32.ts b/path/win32.ts index 2f28d22c19f4..d4febf706a2f 100644 --- a/path/win32.ts +++ b/path/win32.ts @@ -7,7 +7,7 @@ import { CHAR_DOT, CHAR_BACKWARD_SLASH, CHAR_COLON, - CHAR_QUESTION_MARK + CHAR_QUESTION_MARK, } from "./constants.ts"; import { @@ -15,7 +15,7 @@ import { isPathSeparator, isWindowsDeviceRoot, normalizeString, - _format + _format, } from "./utils.ts"; import { assert } from "../testing/asserts.ts"; @@ -259,8 +259,9 @@ export function normalize(path: string): string { tail = ""; } if (tail.length === 0 && !isAbsolute) tail = "."; - if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) + if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) { tail += "\\"; + } if (device === undefined) { if (isAbsolute) { if (tail.length > 0) return `\\${tail}`; @@ -459,8 +460,9 @@ export function relative(from: string, to: string): string { // Lastly, append the rest of the destination (`to`) path that comes after // the common path parts - if (out.length > 0) return out + toOrig.slice(toStart + lastCommonSep, toEnd); - else { + if (out.length > 0) { + return out + toOrig.slice(toStart + lastCommonSep, toEnd); + } else { toStart += lastCommonSep; if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) ++toStart; return toOrig.slice(toStart, toEnd); @@ -590,8 +592,9 @@ export function dirname(path: string): string { } export function basename(path: string, ext = ""): string { - if (ext !== undefined && typeof ext !== "string") + if (ext !== undefined && typeof ext !== "string") { throw new TypeError('"ext" argument must be a string'); + } assertPath(path); diff --git a/permissions/mod.ts b/permissions/mod.ts index e114934267d1..b7f80117b6a6 100644 --- a/permissions/mod.ts +++ b/permissions/mod.ts @@ -5,7 +5,7 @@ const { PermissionDenied } = Deno.errors; function getPermissionString(descriptors: Deno.PermissionDescriptor[]): string { return descriptors.length ? ` ${descriptors - .map(pd => { + .map((pd) => { switch (pd.name) { case "read": case "write": diff --git a/permissions/test.ts b/permissions/test.ts index 2c96dfea1da5..6a9955b6ab50 100644 --- a/permissions/test.ts +++ b/permissions/test.ts @@ -10,9 +10,9 @@ test({ async fn() { assertEquals(await grant({ name: "net" }, { name: "env" }), [ { name: "net" }, - { name: "env" } + { name: "env" }, ]); - } + }, }); test({ @@ -20,28 +20,28 @@ test({ async fn() { assertEquals(await grant([{ name: "net" }, { name: "env" }]), [ { name: "net" }, - { name: "env" } + { name: "env" }, ]); - } + }, }); test({ name: "grant logic", async fn() { assert(await grant({ name: "net" })); - } + }, }); test({ name: "grantOrThrow basic", async fn() { await grantOrThrow({ name: "net" }, { name: "env" }); - } + }, }); test({ name: "grantOrThrow array", async fn() { await grantOrThrow([{ name: "net" }, { name: "env" }]); - } + }, }); diff --git a/signal/mod.ts b/signal/mod.ts index e368edbd123d..0f2b47534209 100644 --- a/signal/mod.ts +++ b/signal/mod.ts @@ -13,13 +13,13 @@ export function signal( const streams = signos.map(Deno.signal); - streams.forEach(stream => { + streams.forEach((stream) => { mux.add(stream); }); // Create dispose method for the muxer of signal streams. const dispose = (): void => { - streams.forEach(stream => { + streams.forEach((stream) => { stream.dispose(); }); }; diff --git a/signal/test.ts b/signal/test.ts index d59484e1225c..16d1458a2313 100644 --- a/signal/test.ts +++ b/signal/test.ts @@ -56,6 +56,6 @@ if (Deno.build.os !== "win") { // yet resolved, delay to next turn of event loop otherwise, // we'll be leaking resources. await delay(10); - } + }, }); } diff --git a/strings/README.md b/strings/README.md index 7621248bb7ad..43be553b892d 100644 --- a/strings/README.md +++ b/strings/README.md @@ -21,6 +21,6 @@ pad("denosorusrex", 6, { side: "left", strict: true, strictSide: "right", - strictChar: "..." + strictChar: "...", }); // output : "den..." ``` diff --git a/strings/pad.ts b/strings/pad.ts index dc75a29549db..b72ae2074458 100644 --- a/strings/pad.ts +++ b/strings/pad.ts @@ -48,7 +48,7 @@ export function pad( strict: false, side: "left", strictChar: "", - strictSide: "right" + strictSide: "right", } ): string { let out = input; diff --git a/strings/pad_test.ts b/strings/pad_test.ts index 9a125b9d2c06..806874bd01bd 100644 --- a/strings/pad_test.ts +++ b/strings/pad_test.ts @@ -18,7 +18,7 @@ test(function padTest(): void { pad("denosorusrex", 4, { char: "*", side: "right", - strict: false + strict: false, }), expected4 ); @@ -27,7 +27,7 @@ test(function padTest(): void { char: "*", side: "left", strict: true, - strictSide: "right" + strictSide: "right", }), expected5 ); @@ -36,7 +36,7 @@ test(function padTest(): void { char: "*", side: "left", strict: true, - strictSide: "left" + strictSide: "left", }), expected6 ); @@ -46,7 +46,7 @@ test(function padTest(): void { side: "left", strict: true, strictSide: "right", - strictChar: "..." + strictChar: "...", }), expected7 ); @@ -56,7 +56,7 @@ test(function padTest(): void { side: "left", strict: true, strictSide: "left", - strictChar: "..." + strictChar: "...", }), expected8 ); @@ -66,7 +66,7 @@ test(function padTest(): void { side: "left", strict: true, strictSide: "right", - strictChar: "..." + strictChar: "...", }), expected2 ); diff --git a/testing/README.md b/testing/README.md index a3640e7281ea..c7c614103edb 100644 --- a/testing/README.md +++ b/testing/README.md @@ -44,7 +44,7 @@ Deno.test({ fn(): void { assertEquals("world", "world"); assertEquals({ hello: "world" }, { hello: "world" }); - } + }, }); await Deno.runTests(); @@ -165,7 +165,7 @@ bench({ b.start(); for (let i = 0; i < 1e6; i++); b.stop(); - } + }, }); ``` diff --git a/testing/asserts.ts b/testing/asserts.ts index 44c3112043dc..19be68763e4c 100644 --- a/testing/asserts.ts +++ b/testing/asserts.ts @@ -66,7 +66,7 @@ function buildMessage(diffResult: ReadonlyArray>): string[] { } function isKeyedCollection(x: unknown): x is Set { - return [Symbol.iterator, "size"].every(k => k in (x as Set)); + return [Symbol.iterator, "size"].every((k) => k in (x as Set)); } export function equal(c: unknown, d: unknown): boolean { diff --git a/testing/asserts_test.ts b/testing/asserts_test.ts index 558ce1578d96..62e199298240 100644 --- a/testing/asserts_test.ts +++ b/testing/asserts_test.ts @@ -12,7 +12,7 @@ import { equal, fail, unimplemented, - unreachable + unreachable, } from "./asserts.ts"; import { red, green, white, gray, bold } from "../fmt/colors.ts"; const { test } = Deno; @@ -53,11 +53,11 @@ test(function testingEqual(): void { equal( new Map([ ["foo", "bar"], - ["baz", "baz"] + ["baz", "baz"], ]), new Map([ ["foo", "bar"], - ["baz", "baz"] + ["baz", "baz"], ]) ) ); @@ -77,11 +77,11 @@ test(function testingEqual(): void { equal( new Map([ ["foo", "bar"], - ["baz", "qux"] + ["baz", "qux"], ]), new Map([ ["baz", "qux"], - ["foo", "bar"] + ["foo", "bar"], ]) ) ); @@ -92,7 +92,7 @@ test(function testingEqual(): void { new Map([["foo", "bar"]]), new Map([ ["foo", "bar"], - ["bar", "baz"] + ["bar", "baz"], ]) ) ); @@ -253,7 +253,7 @@ const createHeader = (): string[] => [ "", ` ${gray(bold("[Diff]"))} ${red(bold("Left"))} / ${green(bold("Right"))}`, "", - "" + "", ]; const added: (s: string) => string = (s: string): string => green(bold(s)); @@ -267,7 +267,7 @@ test({ assertEquals(10, 10); assertEquals("abc", "abc"); assertEquals({ a: 10, b: { c: "1" } }, { a: 10, b: { c: "1" } }); - } + }, }); test({ @@ -278,7 +278,7 @@ test({ AssertionError, [...createHeader(), removed(`- 1`), added(`+ 2`), ""].join("\n") ); - } + }, }); test({ @@ -289,7 +289,7 @@ test({ AssertionError, [...createHeader(), removed(`- 1`), added(`+ "1"`)].join("\n") ); - } + }, }); test({ @@ -306,10 +306,10 @@ test({ white(' "2",'), white(" 3,"), white(" ]"), - "" + "", ].join("\n") ); - } + }, }); test({ @@ -329,8 +329,8 @@ test({ removed(`- "b": "2",`), removed(`- "c": 3,`), white(" }"), - "" + "", ].join("\n") ); - } + }, }); diff --git a/testing/bench.ts b/testing/bench.ts index 1c4b01c0b81f..cd7b89e8c409 100644 --- a/testing/bench.ts +++ b/testing/bench.ts @@ -65,7 +65,7 @@ function createBenchmarkTimer(clock: BenchmarkClock): BenchmarkTimer { }, stop(): void { clock.stop = performance.now(); - } + }, }; } @@ -84,7 +84,7 @@ export function bench( candidates.push({ name: benchmark.name, runs: verifyOr1Run(benchmark.runs), - func: benchmark.func + func: benchmark.func, }); } } @@ -92,7 +92,7 @@ export function bench( /** Runs all registered and non-skipped benchmarks serially. */ export async function runBenchmarks({ only = /[^\s]/, - skip = /^\s*$/ + skip = /^\s*$/, }: BenchmarkRunOptions = {}): Promise { // Filtering candidates by the "only" and "skip" constraint const benchmarks: BenchmarkDefinition[] = candidates.filter( diff --git a/testing/bench_example.ts b/testing/bench_example.ts index d27fb97e8c99..401516cca8de 100644 --- a/testing/bench_example.ts +++ b/testing/bench_example.ts @@ -16,7 +16,7 @@ bench({ b.start(); for (let i = 0; i < 1e6; i++); b.stop(); - } + }, }); // Itsabug diff --git a/testing/bench_test.ts b/testing/bench_test.ts index 904ee2a8ce89..6dfc18b10909 100644 --- a/testing/bench_test.ts +++ b/testing/bench_test.ts @@ -6,7 +6,7 @@ import "./bench_example.ts"; test({ name: "benching", - fn: async function(): Promise { + fn: async function (): Promise { bench(function forIncrementX1e9(b): void { b.start(); for (let i = 0; i < 1e9; i++); @@ -49,7 +49,7 @@ test({ b.start(); for (let i = 0; i < 1e6; i++); b.stop(); - } + }, }); bench(function throwing(b): void { @@ -58,5 +58,5 @@ test({ }); await runBenchmarks({ skip: /throw/ }); - } + }, }); diff --git a/testing/diff.ts b/testing/diff.ts index 5cedb402ac3b..97baa089f43e 100644 --- a/testing/diff.ts +++ b/testing/diff.ts @@ -7,7 +7,7 @@ interface FarthestPoint { export enum DiffType { removed = "removed", common = "common", - added = "added" + added = "added", } export interface DiffResult { @@ -60,12 +60,12 @@ export default function diff(A: T[], B: T[]): Array> { ...A.map( (a): DiffResult => ({ type: swapped ? DiffType.added : DiffType.removed, - value: a + value: a, }) ), ...suffixCommon.map( (c): DiffResult => ({ type: DiffType.common, value: c }) - ) + ), ]; } const offset = N; @@ -107,13 +107,13 @@ export default function diff(A: T[], B: T[]): Array> { if (type === REMOVED) { result.unshift({ type: swapped ? DiffType.removed : DiffType.added, - value: B[b] + value: B[b], }); b -= 1; } else if (type === ADDED) { result.unshift({ type: swapped ? DiffType.added : DiffType.removed, - value: A[a] + value: A[a], }); a -= 1; } else { @@ -133,8 +133,9 @@ export default function diff(A: T[], B: T[]): Array> { k: number, M: number ): FarthestPoint { - if (slide && slide.y === -1 && down && down.y === -1) + if (slide && slide.y === -1 && down && down.y === -1) { return { y: 0, id: 0 }; + } if ( (down && down.y === -1) || k === M || @@ -215,6 +216,6 @@ export default function diff(A: T[], B: T[]): Array> { ...backTrace(A, B, fp[delta + offset], swapped), ...suffixCommon.map( (c): DiffResult => ({ type: DiffType.common, value: c }) - ) + ), ]; } diff --git a/testing/diff_test.ts b/testing/diff_test.ts index 0e8416274098..317dc0db87bd 100644 --- a/testing/diff_test.ts +++ b/testing/diff_test.ts @@ -6,7 +6,7 @@ test({ name: "empty", fn(): void { assertEquals(diff([], []), []); - } + }, }); test({ @@ -14,30 +14,30 @@ test({ fn(): void { assertEquals(diff(["a"], ["b"]), [ { type: "removed", value: "a" }, - { type: "added", value: "b" } + { type: "added", value: "b" }, ]); - } + }, }); test({ name: '"a" vs "a"', fn(): void { assertEquals(diff(["a"], ["a"]), [{ type: "common", value: "a" }]); - } + }, }); test({ name: '"a" vs ""', fn(): void { assertEquals(diff(["a"], []), [{ type: "removed", value: "a" }]); - } + }, }); test({ name: '"" vs "a"', fn(): void { assertEquals(diff([], ["a"]), [{ type: "added", value: "a" }]); - } + }, }); test({ @@ -45,9 +45,9 @@ test({ fn(): void { assertEquals(diff(["a"], ["a", "b"]), [ { type: "common", value: "a" }, - { type: "added", value: "b" } + { type: "added", value: "b" }, ]); - } + }, }); test({ @@ -62,9 +62,9 @@ test({ { type: "common", value: "n" }, { type: "common", value: "g" }, { type: "removed", value: "t" }, - { type: "removed", value: "h" } + { type: "removed", value: "h" }, ]); - } + }, }); test({ @@ -78,9 +78,9 @@ test({ { type: "removed", value: "n" }, { type: "removed", value: "g" }, { type: "removed", value: "t" }, - { type: "removed", value: "h" } + { type: "removed", value: "h" }, ]); - } + }, }); test({ @@ -94,9 +94,9 @@ test({ { type: "added", value: "n" }, { type: "added", value: "g" }, { type: "added", value: "t" }, - { type: "added", value: "h" } + { type: "added", value: "h" }, ]); - } + }, }); test({ @@ -105,7 +105,7 @@ test({ assertEquals(diff(["abc", "c"], ["abc", "bcd", "c"]), [ { type: "common", value: "abc" }, { type: "added", value: "bcd" }, - { type: "common", value: "c" } + { type: "common", value: "c" }, ]); - } + }, }); diff --git a/testing/format.ts b/testing/format.ts index 62fdde5eb4e3..ee291dc23e39 100644 --- a/testing/format.ts +++ b/testing/format.ts @@ -56,7 +56,7 @@ const DEFAULT_OPTIONS: Options = { indent: 2, maxDepth: Infinity, min: false, - printFunctionName: true + printFunctionName: true, }; interface BasicValueOptions { @@ -358,8 +358,8 @@ function printIteratorValues( return result; } -const getKeysOfEnumerableProperties = (object: {}): Array => { - const keys: Array = Object.keys(object).sort(); +function getKeysOfEnumerableProperties(object: T): Array { + const keys = Object.keys(object).sort() as Array; if (Object.getOwnPropertySymbols) { Object.getOwnPropertySymbols(object).forEach((symbol): void => { @@ -372,7 +372,7 @@ const getKeysOfEnumerableProperties = (object: {}): Array => { } return keys; -}; +} /** * Return properties of an object @@ -519,7 +519,7 @@ const getConfig = (options: Options): Config => ({ ...options, indent: options.min ? "" : createIndent(options.indent), spacingInner: options.min ? " " : "\n", - spacingOuter: options.min ? "" : "\n" + spacingOuter: options.min ? "" : "\n", }); /** @@ -531,7 +531,7 @@ const getConfig = (options: Options): Config => ({ export function format(val: any, options: Optional = {}): string { const opts: Options = { ...DEFAULT_OPTIONS, - ...options + ...options, }; const basicResult = printBasicValue(val, opts); if (basicResult !== null) { diff --git a/testing/format_test.ts b/testing/format_test.ts index 14f84f3c2b8a..eac5b7d840bc 100644 --- a/testing/format_test.ts +++ b/testing/format_test.ts @@ -29,12 +29,12 @@ const createVal = () => [ { id: "8658c1d0-9eda-4a90-95e1-8001e8eb6036", text: "Add alternative serialize API for pretty-format plugins", - type: "ADD_TODO" + type: "ADD_TODO", }, { id: "8658c1d0-9eda-4a90-95e1-8001e8eb6036", - type: "TOGGLE_TODO" - } + type: "TOGGLE_TODO", + }, ]; // eslint-disable-next-line @typescript-eslint/explicit-function-return-type @@ -50,7 +50,7 @@ const createExpected = () => ' "id": "8658c1d0-9eda-4a90-95e1-8001e8eb6036",', ' "type": "TOGGLE_TODO",', " },", - "]" + "]", ].join("\n"); test({ @@ -58,7 +58,7 @@ test({ fn(): void { const val = returnArguments(); assertEquals(format(val), "Arguments []"); - } + }, }); test({ @@ -66,7 +66,7 @@ test({ fn(): void { const val: unknown[] = []; assertEquals(format(val), "Array []"); - } + }, }); test({ @@ -74,7 +74,7 @@ test({ fn(): void { const val = [1, 2, 3]; assertEquals(format(val), "Array [\n 1,\n 2,\n 3,\n]"); - } + }, }); test({ @@ -82,7 +82,7 @@ test({ fn(): void { const val = new Uint32Array(0); assertEquals(format(val), "Uint32Array []"); - } + }, }); test({ @@ -90,7 +90,7 @@ test({ fn(): void { const val = new Uint32Array(3); assertEquals(format(val), "Uint32Array [\n 0,\n 0,\n 0,\n]"); - } + }, }); test({ @@ -98,7 +98,7 @@ test({ fn(): void { const val = new ArrayBuffer(3); assertEquals(format(val), "ArrayBuffer []"); - } + }, }); test({ @@ -109,7 +109,7 @@ test({ format(val), "Array [\n Array [\n 1,\n 2,\n 3,\n ],\n]" ); - } + }, }); test({ @@ -117,7 +117,7 @@ test({ fn(): void { const val = true; assertEquals(format(val), "true"); - } + }, }); test({ @@ -125,7 +125,7 @@ test({ fn(): void { const val = false; assertEquals(format(val), "false"); - } + }, }); test({ @@ -133,7 +133,7 @@ test({ fn(): void { const val = new Error(); assertEquals(format(val), "[Error]"); - } + }, }); test({ @@ -141,7 +141,7 @@ test({ fn(): void { const val = new TypeError("message"); assertEquals(format(val), "[TypeError: message]"); - } + }, }); test({ @@ -150,7 +150,7 @@ test({ // tslint:disable-next-line:function-constructor const val = new Function(); assertEquals(format(val), "[Function anonymous]"); - } + }, }); test({ @@ -163,7 +163,7 @@ test({ // tslint:disable-next-line:no-empty f((): void => {}); assertEquals(format(val), "[Function anonymous]"); - } + }, }); test({ @@ -176,7 +176,7 @@ test({ formatted === "[Function anonymous]" || formatted === "[Function val]", true ); - } + }, }); test({ @@ -185,7 +185,7 @@ test({ // tslint:disable-next-line:no-empty const val = function named(): void {}; assertEquals(format(val), "[Function named]"); - } + }, }); test({ @@ -197,7 +197,7 @@ test({ yield 3; }; assertEquals(format(val), "[Function generate]"); - } + }, }); test({ @@ -207,11 +207,11 @@ test({ const val = function named(): void {}; assertEquals( format(val, { - printFunctionName: false + printFunctionName: false, }), "[Function]" ); - } + }, }); test({ @@ -219,7 +219,7 @@ test({ fn(): void { const val = Infinity; assertEquals(format(val), "Infinity"); - } + }, }); test({ @@ -227,7 +227,7 @@ test({ fn(): void { const val = -Infinity; assertEquals(format(val), "-Infinity"); - } + }, }); test({ @@ -235,7 +235,7 @@ test({ fn(): void { const val = new Map(); assertEquals(format(val), "Map {}"); - } + }, }); test({ @@ -248,7 +248,7 @@ test({ format(val), 'Map {\n "prop1" => "value1",\n "prop2" => "value2",\n}' ); - } + }, }); test({ @@ -267,7 +267,7 @@ test({ [Symbol("description"), "symbol"], ["Symbol(description)", "string"], [["array", "key"], "array"], - [{ key: "value" }, "object"] + [{ key: "value" }, "object"], ]); const expected = [ "Map {", @@ -288,10 +288,10 @@ test({ " Object {", ' "key": "value",', ' } => "object",', - "}" + "}", ].join("\n"); assertEquals(format(val), expected); - } + }, }); test({ @@ -299,7 +299,7 @@ test({ fn(): void { const val = NaN; assertEquals(format(val), "NaN"); - } + }, }); test({ @@ -307,7 +307,7 @@ test({ fn(): void { const val = null; assertEquals(format(val), "null"); - } + }, }); test({ @@ -315,7 +315,7 @@ test({ fn(): void { const val = 123; assertEquals(format(val), "123"); - } + }, }); test({ @@ -323,7 +323,7 @@ test({ fn(): void { const val = -123; assertEquals(format(val), "-123"); - } + }, }); test({ @@ -331,7 +331,7 @@ test({ fn(): void { const val = 0; assertEquals(format(val), "0"); - } + }, }); test({ @@ -339,7 +339,7 @@ test({ fn(): void { const val = -0; assertEquals(format(val), "-0"); - } + }, }); test({ @@ -347,7 +347,7 @@ test({ fn(): void { const val = new Date(10e11); assertEquals(format(val), "2001-09-09T01:46:40.000Z"); - } + }, }); test({ @@ -355,7 +355,7 @@ test({ fn(): void { const val = new Date(Infinity); assertEquals(format(val), "Date { NaN }"); - } + }, }); test({ @@ -363,7 +363,7 @@ test({ fn(): void { const val = {}; assertEquals(format(val), "Object {}"); - } + }, }); test({ @@ -374,7 +374,7 @@ test({ format(val), 'Object {\n "prop1": "value1",\n "prop2": "value2",\n}' ); - } + }, }); test({ @@ -390,7 +390,7 @@ test({ 'Object {\n "prop": "value1",\n Symbol(symbol1): "value2",\n ' + 'Symbol(symbol2): "value3",\n}' ); - } + }, }); test({ @@ -398,15 +398,15 @@ test({ "prints an object without non-enumerable properties which have string key", fn(): void { const val = { - enumerable: true + enumerable: true, }; const key = "non-enumerable"; Object.defineProperty(val, key, { enumerable: false, - value: false + value: false, }); assertEquals(format(val), 'Object {\n "enumerable": true,\n}'); - } + }, }); test({ @@ -414,15 +414,15 @@ test({ "prints an object without non-enumerable properties which have symbol key", fn(): void { const val = { - enumerable: true + enumerable: true, }; const key = Symbol("non-enumerable"); Object.defineProperty(val, key, { enumerable: false, - value: false + value: false, }); assertEquals(format(val), 'Object {\n "enumerable": true,\n}'); - } + }, }); test({ @@ -430,7 +430,7 @@ test({ fn(): void { const val = { b: 1, a: 2 }; assertEquals(format(val), 'Object {\n "a": 2,\n "b": 1,\n}'); - } + }, }); test({ @@ -438,7 +438,7 @@ test({ fn(): void { const val = new RegExp("regexp"); assertEquals(format(val), "/regexp/"); - } + }, }); test({ @@ -446,7 +446,7 @@ test({ fn(): void { const val = /regexp/gi; assertEquals(format(val), "/regexp/gi"); - } + }, }); test({ @@ -454,7 +454,7 @@ test({ fn(): void { const val = /regexp\d/gi; assertEquals(format(val), "/regexp\\d/gi"); - } + }, }); test({ @@ -462,7 +462,7 @@ test({ fn(): void { const val = /regexp\d/gi; assertEquals(format(val, { escapeRegex: true }), "/regexp\\\\d/gi"); - } + }, }); test({ @@ -473,7 +473,7 @@ test({ format(obj, { escapeRegex: true }), 'Object {\n "test": /regexp\\\\d/gi,\n}' ); - } + }, }); test({ @@ -481,7 +481,7 @@ test({ fn(): void { const val = new Set(); assertEquals(format(val), "Set {}"); - } + }, }); test({ @@ -491,7 +491,7 @@ test({ val.add("value1"); val.add("value2"); assertEquals(format(val), 'Set {\n "value1",\n "value2",\n}'); - } + }, }); test({ @@ -499,7 +499,7 @@ test({ fn(): void { const val = "string"; assertEquals(format(val), '"string"'); - } + }, }); test({ @@ -507,7 +507,7 @@ test({ fn(): void { const val = "\"'\\"; assertEquals(format(val), '"\\"\'\\\\"'); - } + }, }); test({ @@ -515,7 +515,7 @@ test({ fn(): void { const val = "\"'\\n"; assertEquals(format(val, { escapeString: false }), '""\'\\n"'); - } + }, }); test({ @@ -523,7 +523,7 @@ test({ fn(): void { assertEquals(format('"-"'), '"\\"-\\""'); assertEquals(format("\\ \\\\"), '"\\\\ \\\\\\\\"'); - } + }, }); test({ @@ -531,7 +531,7 @@ test({ fn(): void { const val = ["line 1", "line 2", "line 3"].join("\n"); assertEquals(format(val), '"' + val + '"'); - } + }, }); test({ @@ -540,15 +540,15 @@ test({ const polyline = { props: { id: "J", - points: ["0.5,0.460", "0.5,0.875", "0.25,0.875"].join("\n") + points: ["0.5,0.460", "0.5,0.875", "0.25,0.875"].join("\n"), }, - type: "polyline" + type: "polyline", }; const val = { props: { - children: polyline + children: polyline, }, - type: "svg" + type: "svg", }; assertEquals( format(val), @@ -566,10 +566,10 @@ test({ " },", " },", ' "type": "svg",', - "}" + "}", ].join("\n") ); - } + }, }); test({ @@ -577,7 +577,7 @@ test({ fn(): void { const val = Symbol("symbol"); assertEquals(format(val), "Symbol(symbol)"); - } + }, }); test({ @@ -585,7 +585,7 @@ test({ fn(): void { const val = undefined; assertEquals(format(val), "undefined"); - } + }, }); test({ @@ -593,7 +593,7 @@ test({ fn(): void { const val = new WeakMap(); assertEquals(format(val), "WeakMap {}"); - } + }, }); test({ @@ -601,7 +601,7 @@ test({ fn(): void { const val = new WeakSet(); assertEquals(format(val), "WeakSet {}"); - } + }, }); test({ @@ -613,7 +613,7 @@ test({ 'Object {\n "prop": Object {\n "prop": Object {\n "prop": ' + '"value",\n },\n },\n}' ); - } + }, }); test({ @@ -623,7 +623,7 @@ test({ const val: any = {}; val.prop = val; assertEquals(format(val), 'Object {\n "prop": [Circular],\n}'); - } + }, }); test({ @@ -635,21 +635,21 @@ test({ format(val), 'Object {\n "prop1": Object {},\n "prop2": Object {},\n}' ); - } + }, }); test({ name: "default implicit: 2 spaces", fn(): void { assertEquals(format(createVal()), createExpected()); - } + }, }); test({ name: "default explicit: 2 spaces", fn(): void { assertEquals(format(createVal(), { indent: 2 }), createExpected()); - } + }, }); // Tests assume that no strings in val contain multiple adjacent spaces! @@ -661,7 +661,7 @@ test({ format(createVal(), { indent }), createExpected().replace(/ {2}/g, " ".repeat(indent)) ); - } + }, }); test({ @@ -672,7 +672,7 @@ test({ format(createVal(), { indent }), createExpected().replace(/ {2}/g, " ".repeat(indent)) ); - } + }, }); test({ @@ -693,8 +693,8 @@ test({ "object with constructor": new MyObject("value"), "object without constructor": Object.create(null), "set empty": new Set(), - "set non-empty": new Set(["value"]) - } + "set non-empty": new Set(["value"]), + }, ]; assertEquals( format(v, { maxDepth: 2 }), @@ -715,17 +715,17 @@ test({ ' "set empty": [Set],', ' "set non-empty": [Set],', " },", - "]" + "]", ].join("\n") ); - } + }, }); test({ name: "prints objects with no constructor", fn(): void { assertEquals(format(Object.create(null)), "Object {}"); - } + }, }); test({ @@ -736,10 +736,10 @@ test({ const expected = [ "Object {", // Object instead of undefined ' "constructor": "constructor",', - "}" + "}", ].join("\n"); assertEquals(format(obj), expected); - } + }, }); test({ @@ -748,11 +748,11 @@ test({ assertEquals( format({ toJSON: (): unknown => ({ value: false }), - value: true + value: true, }), 'Object {\n "value": false,\n}' ); - } + }, }); test({ @@ -761,11 +761,11 @@ test({ assertEquals( format({ toJSON: (): string => "[Internal Object]", - value: true + value: true, }), '"[Internal Object]"' ); - } + }, }); test({ @@ -774,11 +774,11 @@ test({ assertEquals( format({ toJSON: false, - value: true + value: true, }), 'Object {\n "toJSON": false,\n "value": true,\n}' ); - } + }, }); test({ @@ -787,11 +787,11 @@ test({ assertEquals( format({ toJSON: (): unknown => ({ toJSON: (): unknown => ({ value: true }) }), - value: false + value: false, }), 'Object {\n "toJSON": [Function toJSON],\n}' ); - } + }, }); test({ @@ -801,5 +801,5 @@ test({ // eslint-disable-next-line @typescript-eslint/no-explicit-any (set as any).toJSON = (): string => "map"; assertEquals(format(set), '"map"'); - } + }, }); diff --git a/testing/runner.ts b/testing/runner.ts index 9aa31cb4a743..0abc6012bd7c 100755 --- a/testing/runner.ts +++ b/testing/runner.ts @@ -75,7 +75,7 @@ export async function* findTestModules( exclude: excludePaths, includeDirs: true, extended: true, - globstar: true + globstar: true, }; async function* expandDirectory(d: string): AsyncIterableIterator { @@ -83,7 +83,7 @@ export async function* findTestModules( for await (const walkInfo of expandGlob(dirGlob, { ...expandGlobOpts, root: d, - includeDirs: false + includeDirs: false, })) { yield filePathToUrl(walkInfo.filename); } @@ -170,7 +170,7 @@ export async function runTestModules({ exitOnFail = false, only = /[^\s]/, skip = /^\s*$/, - disableLog = false + disableLog = false, }: RunTestModulesOptions = {}): Promise { let moduleCount = 0; const testModules = []; @@ -235,7 +235,7 @@ export async function runTestModules({ exitOnFail, only, skip, - disableLog + disableLog, }); } @@ -247,14 +247,14 @@ async function main(): Promise { exclude: ["e"], failfast: ["f"], help: ["h"], - quiet: ["q"] + quiet: ["q"], }, default: { "allow-none": false, failfast: false, help: false, - quiet: false - } + quiet: false, + }, }); if (parsedArgs.help) { return showHelp(); @@ -277,7 +277,7 @@ async function main(): Promise { exclude, allowNone, disableLog, - exitOnFail: true + exitOnFail: true, }); } catch (error) { if (!disableLog) { diff --git a/textproto/test.ts b/textproto/test.ts index 1dcbfd479990..5833935baab4 100644 --- a/textproto/test.ts +++ b/textproto/test.ts @@ -10,7 +10,7 @@ import { assert, assertEquals, assertThrows, - assertNotEOF + assertNotEOF, } from "../testing/asserts.ts"; const { test } = Deno; @@ -25,7 +25,7 @@ test({ const _input = "dotlines\r\n.foo\r\n..bar\n...baz\nquux\r\n\r\n.\r\nanot.her\r\n"; return Promise.resolve(); - } + }, }); test("[textproto] ReadEmpty", async () => { @@ -56,7 +56,7 @@ test({ const m = assertNotEOF(await r.readMIMEHeader()); assertEquals(m.get("My-Key"), "Value 1, Value 2"); assertEquals(m.get("Long-key"), "Even Longer Value"); - } + }, }); test({ @@ -66,7 +66,7 @@ test({ const r = reader(input); const m = assertNotEOF(await r.readMIMEHeader()); assertEquals(m.get("Foo"), "bar"); - } + }, }); test({ @@ -76,7 +76,7 @@ test({ const r = reader(input); const m = assertNotEOF(await r.readMIMEHeader()); assertEquals(m.get("Test-1"), "1"); - } + }, }); test({ @@ -91,7 +91,7 @@ test({ const r = reader(`Cookie: ${sdata}\r\n\r\n`); const m = assertNotEOF(await r.readMIMEHeader()); assertEquals(m.get("Cookie"), sdata); - } + }, }); // Test that we read slightly-bogus MIME headers seen in the wild, @@ -115,7 +115,7 @@ test({ assertThrows((): void => { assertEquals(m.get("Audio Mode"), "None"); }); - } + }, }); test({ @@ -127,7 +127,7 @@ test({ "\tNo colon first line with leading tab\r\nFoo: foo\r\n\r\n", " First: line with leading space\r\nFoo: foo\r\n\r\n", "\tFirst: line with leading tab\r\nFoo: foo\r\n\r\n", - "Foo: foo\r\nNo colon second line\r\n\r\n" + "Foo: foo\r\nNo colon second line\r\n\r\n", ]; const r = reader(input.join("")); @@ -138,7 +138,7 @@ test({ err = e; } assert(err instanceof Deno.errors.InvalidData); - } + }, }); test({ @@ -160,7 +160,7 @@ test({ err = e; } assert(err instanceof Deno.errors.InvalidData); - } + }, }); test({ @@ -170,11 +170,11 @@ test({ "Accept: */*\r\n", 'Content-Disposition: form-data; name="test"\r\n', " \r\n", - "------WebKitFormBoundaryimeZ2Le9LjohiUiG--\r\n\n" + "------WebKitFormBoundaryimeZ2Le9LjohiUiG--\r\n\n", ]; const r = reader(input.join("")); const m = assertNotEOF(await r.readMIMEHeader()); assertEquals(m.get("Accept"), "*/*"); assertEquals(m.get("Content-Disposition"), 'form-data; name="test"'); - } + }, }); diff --git a/types/react-dom.d.ts b/types/react-dom.d.ts index f135197f2b40..3be59411fb25 100644 --- a/types/react-dom.d.ts +++ b/types/react-dom.d.ts @@ -30,7 +30,7 @@ import { DOMAttributes, DOMElement, ReactNode, - ReactPortal + ReactPortal, } from "./react.d.ts"; export function findDOMNode( diff --git a/types/react.d.ts b/types/react.d.ts index b512a43a291d..725503b13e71 100644 --- a/types/react.d.ts +++ b/types/react.d.ts @@ -3231,9 +3231,7 @@ declare namespace React { // naked 'any' type in a conditional type will short circuit and union both the then/else branches // so boolean is only resolved for T = any -type IsExactlyAny = boolean extends (T extends never -? true -: false) +type IsExactlyAny = boolean extends (T extends never ? true : false) ? true : false; diff --git a/types/tests/react-dom_mock.js b/types/tests/react-dom_mock.js index 68b4137ba38d..cbc20958bc12 100644 --- a/types/tests/react-dom_mock.js +++ b/types/tests/react-dom_mock.js @@ -3,7 +3,7 @@ const ReactDOM = { render(element) { return JSON.stringify(element); - } + }, }; export default ReactDOM; diff --git a/types/tests/react_mock.js b/types/tests/react_mock.js index 93faa6c9b171..3dec4f4220bc 100644 --- a/types/tests/react_mock.js +++ b/types/tests/react_mock.js @@ -3,7 +3,7 @@ const React = { createElement(type, props, ...children) { return JSON.stringify({ type, props, children }); - } + }, }; export default React; diff --git a/util/deep_assign_test.ts b/util/deep_assign_test.ts index a69d30b73703..e759a33acaf2 100644 --- a/util/deep_assign_test.ts +++ b/util/deep_assign_test.ts @@ -13,10 +13,10 @@ test(function deepAssignTest(): void { const expected = { foo: { deno: new Date("1979-05-27T07:32:00Z"), - bar: "deno" + bar: "deno", }, deno: { bar: { deno: ["is", "not", "node"] } }, - reg: RegExp(/DENOWOWO/) + reg: RegExp(/DENOWOWO/), }; assert(date !== expected.foo.deno); assert(reg !== expected.reg); diff --git a/uuid/mod.ts b/uuid/mod.ts index 26e4b43ffb06..8e312c5585d6 100644 --- a/uuid/mod.ts +++ b/uuid/mod.ts @@ -14,7 +14,7 @@ const NOT_IMPLEMENTED = { }, validate(): never { throw new Error("Not implemented"); - } + }, }; // TODO Implement diff --git a/uuid/tests/isNil.ts b/uuid/tests/isNil.ts index 7719f1229e3e..4514576daa76 100644 --- a/uuid/tests/isNil.ts +++ b/uuid/tests/isNil.ts @@ -11,5 +11,5 @@ test({ const u = "582cbcff-dad6-4f28-888a-e062ae36bafc"; assert(isNil(nil)); assert(!isNil(u)); - } + }, }); diff --git a/uuid/tests/v4/generate.ts b/uuid/tests/v4/generate.ts index c9946d46c065..897a53fde90c 100644 --- a/uuid/tests/v4/generate.ts +++ b/uuid/tests/v4/generate.ts @@ -9,7 +9,7 @@ test({ const u = generate(); assertEquals(typeof u, "string", "returns a string"); assert(u !== "", "return string is not empty"); - } + }, }); test({ @@ -19,5 +19,5 @@ test({ const u = generate() as string; assert(validate(u), `${u} is not a valid uuid v4`); } - } + }, }); diff --git a/uuid/tests/v4/validate.ts b/uuid/tests/v4/validate.ts index feeecf6b7c0a..3735de51e58c 100644 --- a/uuid/tests/v4/validate.ts +++ b/uuid/tests/v4/validate.ts @@ -12,5 +12,5 @@ Deno.test({ assert(validate(u), `generated ${u} should be valid`); assert(validate(t), `${t} should be valid`); assert(!validate(n), `${n} should not be valid`); - } + }, }); diff --git a/uuid/v4.ts b/uuid/v4.ts index 7688a53061a9..d291b5478d50 100644 --- a/uuid/v4.ts +++ b/uuid/v4.ts @@ -28,6 +28,6 @@ export function generate(): string { "-", ...bits.slice(8, 10), "-", - ...bits.slice(10) + ...bits.slice(10), ].join(""); } diff --git a/ws/README.md b/ws/README.md index a8101f9f0269..2379d9f96ece 100644 --- a/ws/README.md +++ b/ws/README.md @@ -12,7 +12,7 @@ import { acceptWebSocket, isWebSocketCloseEvent, isWebSocketPingEvent, - WebSocket + WebSocket, } from "https://deno.land/std/ws/mod.ts"; /** websocket echo server */ @@ -24,7 +24,7 @@ for await (const req of serve(`:${port}`)) { conn, headers, bufReader: req.r, - bufWriter: req.w + bufWriter: req.w, }) .then( async (sock: WebSocket): Promise => { @@ -73,7 +73,7 @@ import { connectWebSocket, isWebSocketCloseEvent, isWebSocketPingEvent, - isWebSocketPongEvent + isWebSocketPongEvent, } from "https://deno.land/std/ws/mod.ts"; import { encode } from "https://deno.land/std/strings/mod.ts"; import { BufReader } from "https://deno.land/std/io/bufio.ts"; @@ -84,7 +84,7 @@ const endpoint = Deno.args[0] || "ws://127.0.0.1:8080"; /** simple websocket cli */ const sock = await connectWebSocket(endpoint); console.log(green("ws connected! (type 'close' to quit)")); -(async function(): Promise { +(async function (): Promise { for await (const msg of sock.receive()) { if (typeof msg === "string") { console.log(yellow("< " + msg)); diff --git a/ws/example_client.ts b/ws/example_client.ts index 664073210d9b..e6653362d49a 100644 --- a/ws/example_client.ts +++ b/ws/example_client.ts @@ -2,7 +2,7 @@ import { connectWebSocket, isWebSocketCloseEvent, isWebSocketPingEvent, - isWebSocketPongEvent + isWebSocketPongEvent, } from "../ws/mod.ts"; import { encode } from "../strings/mod.ts"; import { BufReader } from "../io/bufio.ts"; @@ -13,7 +13,7 @@ const endpoint = Deno.args[0] || "ws://127.0.0.1:8080"; /** simple websocket cli */ const sock = await connectWebSocket(endpoint); console.log(green("ws connected! (type 'close' to quit)")); -(async function(): Promise { +(async function (): Promise { for await (const msg of sock.receive()) { if (typeof msg === "string") { console.log(yellow("< " + msg)); diff --git a/ws/example_server.ts b/ws/example_server.ts index 03adc0a4988b..048198326742 100644 --- a/ws/example_server.ts +++ b/ws/example_server.ts @@ -4,7 +4,7 @@ import { acceptWebSocket, isWebSocketCloseEvent, isWebSocketPingEvent, - WebSocket + WebSocket, } from "./mod.ts"; /** websocket echo server */ @@ -16,7 +16,7 @@ for await (const req of serve(`:${port}`)) { conn, headers, bufReader: req.r, - bufWriter: req.w + bufWriter: req.w, }) .then( async (sock: WebSocket): Promise => { diff --git a/ws/mod.ts b/ws/mod.ts index 6101260e9c67..a9b8cb67529d 100644 --- a/ws/mod.ts +++ b/ws/mod.ts @@ -19,7 +19,7 @@ export enum OpCode { BinaryFrame = 0x2, Close = 0x8, Ping = 0x9, - Pong = 0xa + Pong = 0xa, } export type WebSocketEvent = @@ -125,13 +125,13 @@ export async function writeFrame( 0x80 | frame.opcode, hasMask | 0b01111110, payloadLength >>> 8, - payloadLength & 0x00ff + payloadLength & 0x00ff, ]); } else { header = new Uint8Array([ 0x80 | frame.opcode, hasMask | 0b01111111, - ...sliceLongToBytes(payloadLength) + ...sliceLongToBytes(payloadLength), ]); } if (frame.mask) { @@ -186,7 +186,7 @@ export async function readFrame(buf: BufReader): Promise { isLastFrame, opcode, mask, - payload + payload, }; } @@ -209,7 +209,7 @@ class WebSocketImpl implements WebSocket { conn, bufReader, bufWriter, - mask + mask, }: { conn: Conn; bufReader?: BufReader; @@ -271,7 +271,7 @@ class WebSocketImpl implements WebSocket { await this.enqueue({ opcode: OpCode.Pong, payload: frame.payload, - isLastFrame: true + isLastFrame: true, }); yield ["ping", frame.payload] as WebSocketPingEvent; break; @@ -290,7 +290,7 @@ class WebSocketImpl implements WebSocket { const { d, frame } = entry; writeFrame(frame, this.bufWriter) .then(() => d.resolve()) - .catch(e => d.reject(e)) + .catch((e) => d.reject(e)) .finally(() => { this.sendQueue.shift(); this.dequeue(); @@ -318,7 +318,7 @@ class WebSocketImpl implements WebSocket { isLastFrame, opcode, payload, - mask: this.mask + mask: this.mask, }; return this.enqueue(frame); } @@ -329,7 +329,7 @@ class WebSocketImpl implements WebSocket { isLastFrame: true, opcode: OpCode.Ping, mask: this.mask, - payload + payload, }; return this.enqueue(frame); } @@ -355,7 +355,7 @@ class WebSocketImpl implements WebSocket { isLastFrame: true, opcode: OpCode.Close, mask: this.mask, - payload + payload, }); } catch (e) { throw e; @@ -378,7 +378,7 @@ class WebSocketImpl implements WebSocket { this._isClosed = true; const rest = this.sendQueue; this.sendQueue = []; - rest.forEach(e => + rest.forEach((e) => e.d.reject( new Deno.errors.ConnectionReset("Socket has already been closed") ) @@ -431,8 +431,8 @@ export async function acceptWebSocket(req: { headers: new Headers({ Upgrade: "websocket", Connection: "Upgrade", - "Sec-WebSocket-Accept": secAccept - }) + "Sec-WebSocket-Accept": secAccept, + }), }); return sock; } @@ -543,7 +543,7 @@ export async function connectWebSocket( conn, bufWriter, bufReader, - mask: createMask() + mask: createMask(), }); } diff --git a/ws/sha1.ts b/ws/sha1.ts index dc8ba680c977..fc86881f8741 100644 --- a/ws/sha1.ts +++ b/ws/sha1.ts @@ -358,7 +358,7 @@ export class Sha1 { (h4 >> 24) & 0xff, (h4 >> 16) & 0xff, (h4 >> 8) & 0xff, - h4 & 0xff + h4 & 0xff, ]; } diff --git a/ws/test.ts b/ws/test.ts index f1efa8e409b1..583750bb1a23 100644 --- a/ws/test.ts +++ b/ws/test.ts @@ -14,7 +14,7 @@ import { readFrame, unmask, writeFrame, - createWebSocket + createWebSocket, } from "./mod.ts"; import { encode, decode } from "../strings/mod.ts"; import Writer = Deno.Writer; @@ -50,7 +50,7 @@ test("[ws] read masked text frame", async () => { 0x9f, 0x4d, 0x51, - 0x58 + 0x58, ]) ) ); @@ -136,8 +136,8 @@ test("[ws] acceptable", () => { const ret = acceptable({ headers: new Headers({ upgrade: "websocket", - "sec-websocket-key": "aaa" - }) + "sec-websocket-key": "aaa", + }), }); assertEquals(ret, true); @@ -148,12 +148,12 @@ test("[ws] acceptable", () => { ["host", "127.0.0.1:9229"], [ "sec-websocket-extensions", - "permessage-deflate; client_max_window_bits" + "permessage-deflate; client_max_window_bits", ], ["sec-websocket-key", "dGhlIHNhbXBsZSBub25jZQ=="], ["sec-websocket-version", "13"], - ["upgrade", "WebSocket"] - ]) + ["upgrade", "WebSocket"], + ]), }) ); }); @@ -161,25 +161,25 @@ test("[ws] acceptable", () => { test("[ws] acceptable should return false when headers invalid", () => { assertEquals( acceptable({ - headers: new Headers({ "sec-websocket-key": "aaa" }) + headers: new Headers({ "sec-websocket-key": "aaa" }), }), false ); assertEquals( acceptable({ - headers: new Headers({ upgrade: "websocket" }) + headers: new Headers({ upgrade: "websocket" }), }), false ); assertEquals( acceptable({ - headers: new Headers({ upgrade: "invalid", "sec-websocket-key": "aaa" }) + headers: new Headers({ upgrade: "invalid", "sec-websocket-key": "aaa" }), }), false ); assertEquals( acceptable({ - headers: new Headers({ upgrade: "websocket", "sec-websocket-ky": "" }) + headers: new Headers({ upgrade: "websocket", "sec-websocket-ky": "" }), }), false ); @@ -205,7 +205,7 @@ test("[ws] write and read masked frame", async () => { isLastFrame: true, mask, opcode: OpCode.TextFrame, - payload: encode(msg) + payload: encode(msg), }, buf ); @@ -282,19 +282,19 @@ function dummyConn(r: Reader, w: Writer): Conn { write: (x): Promise => w.write(x), close: (): void => {}, localAddr: { transport: "tcp", hostname: "0.0.0.0", port: 0 }, - remoteAddr: { transport: "tcp", hostname: "0.0.0.0", port: 0 } + remoteAddr: { transport: "tcp", hostname: "0.0.0.0", port: 0 }, }; } function delayedWriter(ms: number, dest: Writer): Writer { return { write(p: Uint8Array): Promise { - return new Promise(resolve => { + return new Promise((resolve) => { setTimeout(async (): Promise => { resolve(await dest.write(p)); }, ms); }); - } + }, }; } test({ @@ -308,7 +308,7 @@ test({ sock.send("first"), sock.send("second"), sock.ping(), - sock.send(new Uint8Array([3])) + sock.send(new Uint8Array([3])), ]); const bufr = new BufReader(buf); const first = await readFrame(bufr); @@ -322,7 +322,7 @@ test({ assertEquals(ping.opcode, OpCode.Ping); assertEquals(third.opcode, OpCode.BinaryFrame); assertEquals(bytes.equal(third.payload, new Uint8Array([3])), true); - } + }, }); test("[ws] createSecKeyHasCorrectLength", () => { @@ -337,7 +337,7 @@ test("[ws] WebSocket should throw `Deno.errors.ConnectionReset` when peer closed const eofReader: Deno.Reader = { read(_: Uint8Array): Promise { return Promise.resolve(Deno.EOF); - } + }, }; const conn = dummyConn(eofReader, buf); const sock = createWebSocket({ conn }); @@ -355,7 +355,7 @@ test("[ws] WebSocket shouldn't throw `Deno.errors.UnexpectedEof` on recive()", a const eofReader: Deno.Reader = { read(_: Uint8Array): Promise { return Promise.resolve(Deno.EOF); - } + }, }; const conn = dummyConn(eofReader, buf); const sock = createWebSocket({ conn }); @@ -373,10 +373,10 @@ test({ let timer: number | undefined; const lazyWriter: Deno.Writer = { write(_: Uint8Array): Promise { - return new Promise(resolve => { + return new Promise((resolve) => { timer = setTimeout(() => resolve(0), 1000); }); - } + }, }; const conn = dummyConn(buf, lazyWriter); const sock = createWebSocket({ conn }); @@ -384,7 +384,7 @@ test({ const p = Promise.all([ sock.send("hello").catch(onError), sock.send(new Uint8Array([1, 2])).catch(onError), - sock.ping().catch(onError) + sock.ping().catch(onError), ]); sock.closeForce(); assertEquals(sock.isClosed, true); @@ -396,5 +396,5 @@ test({ // Wait for another event loop turn for `timeout` op promise // to resolve, otherwise we'll get "op leak". await delay(10); - } + }, });