diff options
39 files changed, 262 insertions, 129 deletions
diff --git a/.eslintrc.json b/.eslintrc.json index 82e28cfa7..90775af9d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,6 +18,19 @@ "@typescript-eslint/no-unused-vars": [ "error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "_" } + ], + "max-len": [ + "error", + { + "code": 80, + "tabWidth": 2, + "comments": 80, + "ignoreTrailingComments": false, + "ignoreUrls": true, + "ignoreStrings": false, + "ignoreTemplateLiterals": false, + "ignoreRegExpLiterals": false + } ] } } diff --git a/archive/tar.ts b/archive/tar.ts index 5698ae6a0..5f5b1a99e 100644 --- a/archive/tar.ts +++ b/archive/tar.ts @@ -1,5 +1,6 @@ /** - * Ported and modified from: https://github.com/jshttp/mime-types and licensed as: + * Ported and modified from: https://github.com/jshttp/mime-types and + * licensed as: * * (The MIT License) * @@ -292,7 +293,8 @@ export class Tar { /** * Append a file to this tar archive - * @param fileName file name (e.g., test.txt; use slash for directory separators) + * @param fileName file name + * e.g., test.txt; use slash for directory separators * @param opts options */ async append(fileName: string, opts: TarOptions): Promise<void> { @@ -314,7 +316,8 @@ export class Tar { } if (i < 0 || fileName.length > 100 || fileNamePrefix!.length > 155) { throw new Error( - "ustar format does not allow a long file name (length of [file name prefix] + / + [file name] must be shorter than 256 bytes)" + "ustar format does not allow a long file name (length of [file name" + + "prefix] + / + [file name] must be shorter than 256 bytes)" ); } } diff --git a/archive/tar_test.ts b/archive/tar_test.ts index 951879277..474e1e2d3 100644 --- a/archive/tar_test.ts +++ b/archive/tar_test.ts @@ -34,7 +34,10 @@ test(async function createTarArchive(): Promise<void> { const writer = new Deno.Buffer(), wrote = await Deno.copy(writer, tar.getReader()); - // 3072 = 512 (header) + 512 (content) + 512 (header) + 512 (content) + 1024 (footer) + /** + * 3072 = 512 (header) + 512 (content) + 512 (header) + 512 (content) + * + 1024 (footer) + */ assertEquals(wrote, 3072); }); diff --git a/bundle/test.ts b/bundle/test.ts index ed9ba62ce..b66c782bc 100644 --- a/bundle/test.ts +++ b/bundle/test.ts @@ -16,8 +16,8 @@ declare global { var __results: [string, string] | undefined; } } +/* eslint-disable max-len */ /* eslint-enable @typescript-eslint/no-namespace */ - const fixture = ` define("data", [], { "baz": "qat" }); define("modB", ["require", "exports", "data"], function(require, exports, data) { @@ -32,6 +32,7 @@ define("modA", ["require", "exports", "modB"], function(require, exports, modB) globalThis.__results = [modB.foo, modB.baz]; }); `; +/* eslint-enable max-len */ const fixtureQueue = ["data", "modB", "modA"]; const fixtureModules = new Map<string, ModuleMetaData>(); diff --git a/encoding/csv.ts b/encoding/csv.ts index 1c4ae546b..ccbf4df77 100644 --- a/encoding/csv.ts +++ b/encoding/csv.ts @@ -21,11 +21,12 @@ export class ParseError extends Error { /** * @property comma - Character which separates values. Default: ',' * @property comment - Character to start a comment. Default: '#' - * @property trimLeadingSpace - Flag to trim the leading space of the value. Default: 'false' + * @property trimLeadingSpace - Flag to trim the leading space of the value. + * Default: 'false' * @property lazyQuotes - Allow unquoted quote in a quoted field or non double - * quoted quotes in quoted field Default: 'false' - * @property fieldsPerRecord - Enabling the check of fields for each row. If == 0 - * first row is used as referal for the number of fields. + * quoted quotes in quoted field Default: 'false' + * @property fieldsPerRecord - Enabling the check of fields for each row. + * If == 0, first row is used as referal for the number of fields. */ export interface ParseOptions { comma?: string; diff --git a/encoding/csv_test.ts b/encoding/csv_test.ts index a68b81dc8..88a3a24d7 100644 --- a/encoding/csv_test.ts +++ b/encoding/csv_test.ts @@ -129,7 +129,7 @@ const testCases = [ Name: "BadBareQuote", Input: `a "word","b"`, Error: ErrBareQuote - // Error: true //&ParseError{StartLine: 1, Line: 1, Column: 2, Err: ErrBareQuote}, + // &ParseError{StartLine: 1, Line: 1, Column: 2, Err: ErrBareQuote} }, { Name: "BadTrailingQuote", @@ -151,7 +151,7 @@ const testCases = [ { Name: "BadFieldCount1", Input: `a,b,c`, - // Error: &ParseError{StartLine: 1, Line: 1, Err: ErrFieldCount}, + // Error: &ParseError{StartLine: 1, Line: 1, Err: ErrFieldCount}, UseFieldsPerRecord: true, FieldsPerRecord: 2, Error: ErrFieldCount @@ -298,7 +298,11 @@ x,,, // { // Name: "MultiFieldCRCRLFCRCR", // Input: "field1,field2\r\r\n\r\rfield1,field2\r\r\n\r\r,", - // Output: [["field1", "field2\r"], ["\r\rfield1", "field2\r"], ["\r\r", ""]] + // Output: [ + // ["field1", "field2\r"], + // ["\r\rfield1", "field2\r"], + // ["\r\r", ""] + // ] // }, { Name: "NonASCIICommaAndComment", @@ -339,13 +343,20 @@ x,,, // Name: "MultipleCRLF", // Input: "\r\n\r\n\r\n\r\n" // }, - // { - // // The implementation may read each line in several chunks if it doesn't fit entirely - // // in the read buffer, so we should test the code to handle that condition. - // Name: "HugeLines", - // Input: strings.Repeat("#ignore\n", 10000) + strings.Repeat("@", 5000) + "," + strings.Repeat("*", 5000), - // Output: [[strings.Repeat("@", 5000), strings.Repeat("*", 5000)]], - // Comment: '#', + /** + * The implementation may read each line in several chunks if + * it doesn't fit entirely. + * in the read buffer, so we should test the code to handle that condition. + */ + // { + // Name: "HugeLines", + // Input: + // strings.Repeat("#ignore\n", 10000) + + // strings.Repeat("@", 5000) + + // "," + + // strings.Repeat("*", 5000), + // Output: [[strings.Repeat("@", 5000), strings.Repeat("*", 5000)]], + // Comment: "#" // }, { Name: "QuoteWithTrailingCRLF", diff --git a/encoding/hex.ts b/encoding/hex.ts index 83c88ac78..d2e499cc7 100644 --- a/encoding/hex.ts +++ b/encoding/hex.ts @@ -32,7 +32,8 @@ function fromHexChar(byte: number): [number, boolean] { } /** - * EncodedLen returns the length of an encoding of n source bytes. Specifically, it returns n * 2. + * EncodedLen returns the length of an encoding of n source bytes. Specifically, + * it returns n * 2. * @param n */ export function encodedLen(n: number): number { @@ -73,8 +74,10 @@ export function encodeToString(src: Uint8Array): string { /** * Decode decodes `src` into `decodedLen(src.length)` bytes * returning the actual number of bytes written to `dst`. - * Decode expects that `src` contains only hexadecimal characters and that `src` has even length. - * If the input is malformed, Decode returns the number of bytes decoded before the error. + * Decode expects that `src` contains only hexadecimal characters and that `src` + * has even length. + * If the input is malformed, Decode returns the number of bytes decoded before + * the error. * @param dst * @param src */ @@ -110,7 +113,8 @@ export function decode( } /** - * DecodedLen returns the length of a decoding of `x` source bytes. Specifically, it returns `x / 2`. + * DecodedLen returns the length of a decoding of `x` source bytes. + * Specifically, it returns `x / 2`. * @param x */ export function decodedLen(x: number): number { @@ -119,14 +123,16 @@ export function decodedLen(x: number): number { /** * DecodeString returns the bytes represented by the hexadecimal string `s`. - * DecodeString expects that src contains only hexadecimal characters and that src has even length. + * DecodeString expects that src contains only hexadecimal characters and that + * src has even length. * If the input is malformed, DecodeString will throws an error. * @param s the `string` need to decode to `Uint8Array` */ export function decodeString(s: string): Uint8Array { const src = new TextEncoder().encode(s); // We can use the source slice itself as the destination - // because the decode loop increments by one and then the 'seen' byte is not used anymore. + // because the decode loop increments by one and then the 'seen' byte is not + // used anymore. const [n, err] = decode(src, src); if (err) { diff --git a/encoding/toml.ts b/encoding/toml.ts index e93903fae..8a53a8300 100644 --- a/encoding/toml.ts +++ b/encoding/toml.ts @@ -507,8 +507,9 @@ class Dumper { const min = dtPad(value.getUTCMinutes().toString()); const s = dtPad(value.getUTCSeconds().toString()); const ms = dtPad(value.getUTCMilliseconds().toString(), 3); - const fmtDate = `${value.getUTCFullYear()}-${m}-${d}T${h}:${min}:${s}.${ms}`; - return `${this._declaration(title)}${fmtDate}`; + // formated date + const fData = `${value.getUTCFullYear()}-${m}-${d}T${h}:${min}:${s}.${ms}`; + return `${this._declaration(title)}${fData}`; } _format(): string[] { const rDeclaration = /(.*)\s=/; diff --git a/encoding/toml_test.ts b/encoding/toml_test.ts index 13d4f0b14..28a620453 100644 --- a/encoding/toml_test.ts +++ b/encoding/toml_test.ts @@ -29,7 +29,8 @@ test({ str5: "The quick brown\nfox jumps over\nthe lazy dog.", 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." + "The first newline is\ntrimmed in raw strings.\n All other " + + "whitespace\n is preserved." } }; const actual = parseFile(path.join(testFilesDir, "string.toml")); diff --git a/examples/gist.ts b/examples/gist.ts index fb6837059..6b5611120 100755 --- a/examples/gist.ts +++ b/examples/gist.ts @@ -21,7 +21,8 @@ async function main(): Promise<void> { if (parsedArgs._.length === 0) { console.error( - "Usage: gist.ts --allow-env --allow-net [-t|--title Example] some_file [next_file]" + "Usage: gist.ts --allow-env --allow-net [-t|--title Example] some_file " + + "[next_file]" ); exit(1); } diff --git a/fs/copy.ts b/fs/copy.ts index b51106e3a..c3c97d1ba 100644 --- a/fs/copy.ts +++ b/fs/copy.ts @@ -9,7 +9,8 @@ export interface CopyOptions { */ overwrite?: boolean; /** - * When `true`, will set last modification and access times to the ones of the original source files. + * When `true`, will set last modification and access times to the ones of the + * original source files. * When `false`, timestamp behavior is OS-dependent. * Default is `false`. */ @@ -188,9 +189,10 @@ function copyDirSync(src: string, dest: string, options: CopyOptions): void { /** * Copy a file or directory. The directory can have contents. Like `cp -r`. * @param src the file/directory path. - * Note that if `src` is a directory it will copy everything inside of this directory, - * not the entire directory itself - * @param dest the destination path. Note that if `src` is a file, `dest` cannot be a directory + * Note that if `src` is a directory it will copy everything inside + * of this directory, not the entire directory itself + * @param dest the destination path. Note that if `src` is a file, `dest` cannot + * be a directory * @param options */ export async function copy( @@ -225,9 +227,10 @@ export async function copy( /** * Copy a file or directory. The directory can have contents. Like `cp -r`. * @param src the file/directory path. - * Note that if `src` is a directory it will copy everything inside of this directory, - * not the entire directory itself - * @param dest the destination path. Note that if `src` is a file, `dest` cannot be a directory + * Note that if `src` is a directory it will copy everything inside + * of this directory, not the entire directory itself + * @param dest the destination path. Note that if `src` is a file, `dest` cannot + * be a directory * @param options */ export function copySync( diff --git a/fs/copy_test.ts b/fs/copy_test.ts index 38c27e15b..09aae0ff6 100644 --- a/fs/copy_test.ts +++ b/fs/copy_test.ts @@ -431,7 +431,8 @@ testCopySync( ); testCopySync( - "[fs] copy directory synchronously, and destination exist and not a directory", + "[fs] copy directory synchronously, and destination exist and not a " + + "directory", (tempDir: string): void => { const srcDir = path.join(tempDir, "parent_sync"); const destDir = path.join(tempDir, "child.txt"); diff --git a/fs/ensure_file.ts b/fs/ensure_file.ts index 6fe8e7822..d749b95e4 100644 --- a/fs/ensure_file.ts +++ b/fs/ensure_file.ts @@ -5,8 +5,10 @@ import { getFileInfoType } from "./utils.ts"; /** * Ensures that the file exists. - * If the file that is requested to be created is in directories that do not exist, - * these directories are created. If the file already exists, it is NOT MODIFIED. + * If the file that is requested to be created is in directories that do not + * exist. + * these directories are created. If the file already exists, + * it is NOTMODIFIED. */ export async function ensureFile(filePath: string): Promise<void> { let pathExists = false; @@ -33,8 +35,10 @@ export async function ensureFile(filePath: string): Promise<void> { /** * Ensures that the file exists. - * If the file that is requested to be created is in directories that do not exist, - * these directories are created. If the file already exists, it is NOT MODIFIED. + * If the file that is requested to be created is in directories that do not + * exist, + * these directories are created. If the file already exists, + * it is NOT MODIFIED. */ export function ensureFileSync(filePath: string): void { let pathExists = false; diff --git a/fs/exists.ts b/fs/exists.ts index 4638630fd..2c68ec6cf 100644 --- a/fs/exists.ts +++ b/fs/exists.ts @@ -1,13 +1,17 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -/** Test whether or not the given path exists by checking with the file system */ +/** + * Test whether or not the given path exists by checking with the file system + */ export async function exists(filePath: string): Promise<boolean> { return Deno.lstat(filePath) .then((): boolean => true) .catch((): boolean => false); } -/** Test whether or not the given path exists by checking with the file system */ +/** + * Test whether or not the given path exists by checking with the file system + */ export function existsSync(filePath: string): boolean { try { Deno.lstatSync(filePath); diff --git a/fs/exists_test.ts b/fs/exists_test.ts index a75cdb9f4..247bb7ed6 100644 --- a/fs/exists_test.ts +++ b/fs/exists_test.ts @@ -36,11 +36,13 @@ test(function existsDirectorySync(): void { }); test(function existsLinkSync(): void { - // TODO(axetroy): generate link file use Deno api instead of set a link file in repository + // 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); }); test(async function existsLink(): Promise<void> { - // TODO(axetroy): generate link file use Deno api instead of set a link file in repository + // 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); }); diff --git a/fs/glob.ts b/fs/glob.ts index 8d322b761..506d4012c 100644 --- a/fs/glob.ts +++ b/fs/glob.ts @@ -47,6 +47,7 @@ export function glob(glob: string, options: GlobOptions = {}): RegExp { /** Test whether the given string is a glob */ export function isGlob(str: string): boolean { const chars: Record<string, string> = { "{": "}", "(": ")", "[": "]" }; + /* eslint-disable-next-line max-len */ const regex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; if (str === "") { diff --git a/fs/globrex.ts b/fs/globrex.ts index 56def02f8..32a129a67 100644 --- a/fs/globrex.ts +++ b/fs/globrex.ts @@ -76,7 +76,8 @@ export function globrex( if (split) { if (last) segment += str; if (segment !== "") { - if (!flags.includes("g")) segment = `^${segment}$`; // change it 'includes' + // change it 'includes' + if (!flags.includes("g")) segment = `^${segment}$`; path.segments.push(new RegExp(segment, flags)); } segment = ""; @@ -265,8 +266,10 @@ export function globrex( // globstar is enabled, so determine if this is a globstar segment let isGlobstar = starCount > 1 && // multiple "*"'s - (prevChar === "/" || prevChar === undefined) && // from the start of the segment - (nextChar === "/" || nextChar === undefined); // to the end of the segment + // from the start of the segment + (prevChar === "/" || prevChar === undefined) && + // to the end of the segment + (nextChar === "/" || nextChar === undefined); if (isGlobstar) { // it's a globstar, so match zero or more path segments add(GLOBSTAR, { only: "regex" }); diff --git a/fs/utils.ts b/fs/utils.ts index ab5bf2f0e..f644f4869 100644 --- a/fs/utils.ts +++ b/fs/utils.ts @@ -31,7 +31,8 @@ export type PathType = "file" | "dir" | "symlink"; /** * Get a human readable file type string. * - * @param fileInfo A FileInfo describes a file and is returned by `stat`, `lstat` + * @param fileInfo A FileInfo describes a file and is returned by `stat`, + * `lstat` */ export function getFileInfoType(fileInfo: Deno.FileInfo): PathType | undefined { return fileInfo.isFile() diff --git a/http/cookie.ts b/http/cookie.ts index 026ed1984..843f626f1 100644 --- a/http/cookie.ts +++ b/http/cookie.ts @@ -97,9 +97,10 @@ export function getCookies(req: ServerRequest): Cookies { * @param [cookie.domain] Specifies those hosts to which the cookie will be sent * @param [cookie.path] Indicates a URL path that must exist in the request. * @param [cookie.secure] Indicates if the cookie is made using SSL & HTTPS. - * @param [cookie.httpOnly] Indicates that cookie is not accessible via Javascript - * @param [cookie.sameSite] Allows servers to assert that a cookie ought not to be - * sent along with cross-site requests + * @param [cookie.httpOnly] Indicates that cookie is not accessible via + * Javascript + * @param [cookie.sameSite] Allows servers to assert that a cookie ought not to + * be sent along with cross-site requests * Example: * * setCookie(response, { name: 'deno', value: 'runtime', diff --git a/http/cookie_test.ts b/http/cookie_test.ts index 3d2e98afc..05ed324d2 100644 --- a/http/cookie_test.ts +++ b/http/cookie_test.ts @@ -124,7 +124,8 @@ test({ }); assertEquals( res.headers.get("Set-Cookie"), - "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; SameSite=Strict" + "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; " + + "SameSite=Strict" ); res.headers = new Headers(); @@ -170,7 +171,8 @@ test({ }); assertEquals( res.headers.get("Set-Cookie"), - "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; Path=/; unparsed=keyvalue; batman=Bruce" + "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; Path=/; " + + "unparsed=keyvalue; batman=Bruce" ); res.headers = new Headers(); @@ -186,7 +188,8 @@ test({ }); assertEquals( res.headers.get("Set-Cookie"), - "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; Path=/; Expires=Fri, 07 Jan 1983 15:32:00 GMT" + "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; Path=/; " + + "Expires=Fri, 07 Jan 1983 15:32:00 GMT" ); res.headers = new Headers(); diff --git a/http/file_server_test.ts b/http/file_server_test.ts index 201524e7b..1bd4e8160 100644 --- a/http/file_server_test.ts +++ b/http/file_server_test.ts @@ -59,7 +59,8 @@ test(async function serveDirectory(): Promise<void> { assert(page.includes("azure-pipelines.yml")); // `Deno.FileInfo` is not completely compatible with Windows yet - // TODO: `mode` should work correctly in the future. Correct this test case accordingly. + // TODO: `mode` should work correctly in the future. + // Correct this test case accordingly. Deno.platform.os !== "win" && assert(/<td class="mode">\([a-zA-Z-]{10}\)<\/td>/.test(page)); Deno.platform.os === "win" && diff --git a/http/server_test.ts b/http/server_test.ts index b58523787..6b50057ea 100644 --- a/http/server_test.ts +++ b/http/server_test.ts @@ -359,17 +359,20 @@ test(async function testReadRequestError(): Promise<void> { // See Issue 16490. { in: - "POST / HTTP/1.1\r\nContent-Length: 10\r\nContent-Length: 0\r\n\r\nGopher hey\r\n", + "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" }, { in: - "POST / HTTP/1.1\r\nContent-Length: 10\r\nContent-Length: 6\r\n\r\nGopher\r\n", + "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" }, { in: - "PUT / HTTP/1.1\r\nContent-Length: 6 \r\nContent-Length: 6\r\nContent-Length:6\r\n\r\nGopher\r\n", + "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" }] }, { @@ -388,7 +391,8 @@ test(async function testReadRequestError(): Promise<void> { }, { in: - "POST / HTTP/1.1\r\nContent-Length:0\r\ntransfer-encoding: chunked\r\n\r\n", + "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" } diff --git a/installer/mod.ts b/installer/mod.ts index 5d907bef5..c0a11ac9e 100644 --- a/installer/mod.ts +++ b/installer/mod.ts @@ -18,7 +18,8 @@ import { exists } from "../fs/exists.ts"; const encoder = new TextEncoder(); const decoder = new TextDecoder("utf-8"); const isWindows = Deno.platform.os === "win"; -const driverLetterReg = /^[c-z]:/i; // Regular expression to test disk driver letter. eg "C:\\User\username\path\to" +// Regular expression to test disk driver letter. eg "C:\\User\username\path\to" +const driverLetterReg = /^[c-z]:/i; enum Permission { Read, @@ -101,8 +102,10 @@ function checkIfExistsInPath(filePath: string): boolean { for (const p of paths) { const pathInEnv = path.normalize(p); - // On Windows paths from env contain drive letter. (eg. C:\Users\username\.deno\bin) - // But in the path of Deno, there is no drive letter. (eg \Users\username\.deno\bin) + // On Windows paths from env contain drive letter. + // (eg. C:\Users\username\.deno\bin) + // But in the path of Deno, there is no drive letter. + // (eg \Users\username\.deno\bin) if (isWindows) { if (driverLetterReg.test(pathInEnv)) { fileAbsolutePath = HOMEDRIVE + "\\" + fileAbsolutePath; @@ -118,7 +121,8 @@ function checkIfExistsInPath(filePath: string): boolean { } function getInstallerDir(): string { - // In Windows's Powershell $HOME environmental variable maybe null, if so use $HOMEPATH instead. + // In Windows's Powershell $HOME environmental variable maybe null + // if so use $HOMEPATH instead. let { HOME, HOMEPATH } = env(); const HOME_PATH = HOME || HOMEPATH; @@ -140,7 +144,8 @@ USAGE: ARGS: EXE_NAME Name for executable SCRIPT_URL Local or remote URL of script to install - [FLAGS...] List of flags for script, both Deno permission and script specific flag can be used. + [FLAGS...] List of flags for script, both Deno permission and script specific + flag can be used. `); } @@ -148,10 +153,14 @@ async function generateExecutable( filePath: string, commands: string[] ): Promise<void> { - // On Windows if user is using Powershell .cmd extension is need to run the installed module. + // On Windows if user is using Powershell .cmd extension is need to run the + // installed module. // Generate batch script to satisfy that. + const templateHeader = + "This executable is generated by Deno. Please don't modify it unless you " + + "know what it means."; if (isWindows) { - const template = `% This executable is generated by Deno. Please don't modify it unless you know what it means. % + const template = `% ${templateHeader} % @IF EXIST "%~dp0\deno.exe" ( "%~dp0\deno.exe" ${commands.slice(1).join(" ")} %* ) ELSE ( @@ -167,7 +176,7 @@ async function generateExecutable( // generate Shell script const template = `#/bin/sh -# This executable is generated by Deno. Please don't modify it unless you know what it means. +# ${templateHeader} basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')") case \`uname\` in @@ -198,7 +207,9 @@ export async function install( const filePath = path.join(installerDir, moduleName); if (await exists(filePath)) { - const msg = `⚠️ ${moduleName} is already installed, do you want to overwrite it?`; + const msg = + "⚠️ ${moduleName} is already installed, " + + "do you want to overwrite it?"; if (!(await yesNoPrompt(msg))) { return; } @@ -245,7 +256,8 @@ export async function install( if (!checkIfExistsInPath(installerDir)) { console.log("\nℹ️ Add ~/.deno/bin to PATH"); console.log( - " echo 'export PATH=\"$HOME/.deno/bin:$PATH\"' >> ~/.bashrc # change this to your shell" + " echo 'export PATH=\"$HOME/.deno/bin:$PATH\"' >> ~/.bashrc # change" + + " this to your shell" ); } } diff --git a/installer/test.ts b/installer/test.ts index d28a9d448..1767464d4 100644 --- a/installer/test.ts +++ b/installer/test.ts @@ -68,6 +68,7 @@ installerTest(async function installBasic(): Promise<void> { if (isWindows) { assertEquals( await fs.readFileStr(filePath + ".cmd"), + /* eslint-disable max-len */ `% This executable is generated by Deno. Please don't modify it unless you know what it means. % @IF EXIST "%~dp0\deno.exe" ( "%~dp0\deno.exe" run http://localhost:4500/http/file_server.ts %* @@ -77,11 +78,13 @@ installerTest(async function installBasic(): Promise<void> { deno run http://localhost:4500/http/file_server.ts %* ) ` + /* eslint-enable max-len */ ); } assertEquals( await fs.readFileStr(filePath), + /* eslint-disable max-len */ `#/bin/sh # This executable is generated by Deno. Please don't modify it unless you know what it means. basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')") @@ -99,6 +102,7 @@ else fi exit $ret ` + /* eslint-enable max-len */ ); }); @@ -115,6 +119,7 @@ installerTest(async function installWithFlags(): Promise<void> { if (isWindows) { assertEquals( await fs.readFileStr(filePath + ".cmd"), + /* eslint-disable max-len */ `% This executable is generated by Deno. Please don't modify it unless you know what it means. % @IF EXIST "%~dp0\deno.exe" ( "%~dp0\deno.exe" run --allow-net --allow-read http://localhost:4500/http/file_server.ts --foobar %* @@ -124,11 +129,13 @@ installerTest(async function installWithFlags(): Promise<void> { deno run --allow-net --allow-read http://localhost:4500/http/file_server.ts --foobar %* ) ` + /* eslint-enable max-len */ ); } assertEquals( await fs.readFileStr(filePath), + /* eslint-disable max-len */ `#/bin/sh # This executable is generated by Deno. Please don't modify it unless you know what it means. basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')") @@ -146,6 +153,7 @@ else fi exit $ret ` + /* eslint-enable max-len */ ); }); diff --git a/io/bufio.ts b/io/bufio.ts index dc6d6b3cc..29ca5435d 100644 --- a/io/bufio.ts +++ b/io/bufio.ts @@ -207,8 +207,10 @@ export class BufReader implements Reader { /** readString() reads until the first occurrence of delim in the input, * returning a string containing the data up to and including the delimiter. * If ReadString encounters an error before finding a delimiter, - * it returns the data read before the error and the error itself (often io.EOF). - * ReadString returns err != nil if and only if the returned data does not end in + * it returns the data read before the error and the error itself + * (often io.EOF). + * ReadString returns err != nil if and only if the returned data does not end + * in * delim. * For simple uses, a Scanner may be more convenient. */ diff --git a/io/bufio_test.ts b/io/bufio_test.ts index 6433c7a5a..1ea664c5c 100644 --- a/io/bufio_test.ts +++ b/io/bufio_test.ts @@ -143,7 +143,8 @@ test(async function bufioBufReader(): Promise<void> { test(async function bufioBufferFull(): Promise<void> { const longString = - "And now, hello, world! It is the time for all good men to come to the aid of their party"; + "And now, hello, world! It is the time for all good men to come to the" + + " aid of their party"; const buf = new BufReader(stringsReader(longString), MIN_READ_BUFFER_SIZE); const decoder = new TextDecoder(); @@ -165,7 +166,8 @@ const testInput = encoder.encode( "012\n345\n678\n9ab\ncde\nfgh\nijk\nlmn\nopq\nrst\nuvw\nxy" ); const testInputrn = encoder.encode( - "012\r\n345\r\n678\r\n9ab\r\ncde\r\nfgh\r\nijk\r\nlmn\r\nopq\r\nrst\r\nuvw\r\nxy\r\n\n\r\n" + "012\r\n345\r\n678\r\n9ab\r\ncde\r\nfgh\r\nijk\r\nlmn\r\nopq\r\nrst\r\n" + + "uvw\r\nxy\r\n\n\r\n" ); const testOutput = encoder.encode("0123456789abcdefghijklmnopqrstuvwxy"); @@ -281,13 +283,17 @@ test(async function bufioPeek(): Promise<void> { const r = await buf.peek(1); assert(r === EOF); /* TODO - // Test for issue 3022, not exposing a reader's error on a successful Peek. + Test for issue 3022, not exposing a reader's error on a successful Peek. buf = NewReaderSize(dataAndEOFReader("abcd"), 32) if s, err := buf.Peek(2); string(s) != "ab" || err != nil { t.Errorf(`Peek(2) on "abcd", EOF = %q, %v; want "ab", nil`, string(s), err) } if s, err := buf.Peek(4); string(s) != "abcd" || err != nil { - t.Errorf(`Peek(4) on "abcd", EOF = %q, %v; want "abcd", nil`, string(s), err) + t.Errorf( + `Peek(4) on "abcd", EOF = %q, %v; want "abcd", nil`, + string(s), + err + ) } if n, err := buf.Read(p[0:5]); string(p[0:n]) != "abcd" || err != nil { t.Fatalf("Read after peek = %q, %v; want abcd, EOF", p[0:n], err) diff --git a/io/ioutil.ts b/io/ioutil.ts index 979549fbf..c13eff0d4 100644 --- a/io/ioutil.ts +++ b/io/ioutil.ts @@ -4,7 +4,9 @@ type Reader = Deno.Reader; type Writer = Deno.Writer; import { assert } from "../testing/asserts.ts"; -/** copy N size at the most. If read size is lesser than N, then returns nread */ +/** copy N size at the most. + * If read size is lesser than N, then returns nread + * */ export async function copyN( dest: Writer, r: Reader, diff --git a/io/util.ts b/io/util.ts index a0cf08102..96ff10b0e 100644 --- a/io/util.ts +++ b/io/util.ts @@ -25,7 +25,9 @@ export function stringsReader(s: string): Reader { return new Buffer(encode(s).buffer); } -/** Create or open a temporal file at specified directory with prefix and postfix */ +/** Create or open a temporal file at specified directory with prefix and + * postfix + * */ export async function tempFile( dir: string, opts: { diff --git a/mime/multipart_test.ts b/mime/multipart_test.ts index a2fc960b7..df2f042b1 100644 --- a/mime/multipart_test.ts +++ b/mime/multipart_test.ts @@ -111,7 +111,8 @@ test(function multipartMultipartWriter2(): void { (): MultipartWriter => new MultipartWriter( w, - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + + "aaaaaaaa" ), Error, "invalid boundary length" diff --git a/multipart/formfile.ts b/multipart/formfile.ts index 8bbdcffbc..592f4e529 100644 --- a/multipart/formfile.ts +++ b/multipart/formfile.ts @@ -10,7 +10,9 @@ export interface FormFile { size: number; /** in-memory content of file. Either content or tempfile is set */ content?: Uint8Array; - /** temporal file path. Set if file size is bigger than specified max-memory size at reading form */ + /** temporal file path. + * Set if file size is bigger than specified max-memory size at reading form + * */ tempfile?: string; } diff --git a/prettier/main.ts b/prettier/main.ts index 584b90b39..82a213d41 100755 --- a/prettier/main.ts +++ b/prettier/main.ts @@ -2,11 +2,23 @@ /** * Copyright © James Long and contributors * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // This script formats the given source files. If the files are omitted, it @@ -23,49 +35,47 @@ Formats the given files. If no arg is passed, then formats the all files. Usage: deno prettier/main.ts [options] [files...] Options: - -H, --help Show this help message and exit. - --check Check if the source files are formatted. - --write Whether to write to the file, otherwise it will output to stdout, Defaults to false. - --ignore <path> Ignore the given path(s). + -H, --help Show this help message and exit. + --check Check if the source files are formatted. + --write Whether to write to the file, otherwise + it will output to stdout, Defaults to + false. + --ignore <path> Ignore the given path(s). JS/TS Styling Options: - --print-width <int> The line length where Prettier will try wrap. - Defaults to 80. - --tab-width <int> Number of spaces per indentation level. - Defaults to 2. - --use-tabs Indent with tabs instead of spaces. - Defaults to false. - --no-semi Do not print semicolons, except at the beginning of lines which may need them. - --single-quote Use single quotes instead of double quotes. - Defaults to false. - --trailing-comma <none|es5|all> - Print trailing commas wherever possible when multi-line. - Defaults to none. - --no-bracket-spacing Do not print spaces between brackets. - --arrow-parens <avoid|always> - Include parentheses around a sole arrow function parameter. - Defaults to avoid. - --end-of-line <auto|lf|crlf|cr> - Which end of line characters to apply. - Defaults to auto. + --print-width <int> The line length where Prettier will try + wrap. Defaults to 80. + --tab-width <int> Number of spaces per indentation level. + Defaults to 2. + --use-tabs Indent with tabs instead of spaces. + Defaults to false. + --no-semi Do not print semicolons, except at the + beginning of lines which may need them. + --single-quote Use single quotes instead of double + quotes. Defaults to false. + --trailing-comma <none|es5|all> Print trailing commas wherever possible + when multi-line. Defaults to none. + --no-bracket-spacing Do not print spaces between brackets. + --arrow-parens <avoid|always> Include parentheses around a sole arrow + function parameter. Defaults to avoid. + --end-of-line <auto|lf|crlf|cr> Which end of line characters to apply. + Defaults to auto. Markdown Styling Options: - --prose-wrap <always|never|preserve> - How to wrap prose. - Defaults to preserve. + --prose-wrap <always|never|preserve> How to wrap prose. Defaults to preserve. Example: deno run prettier/main.ts --write script1.ts script2.js - Formats the files + Formats the files deno run prettier/main.ts --check script1.ts script2.js - Checks if the files are formatted + Checks if the files are formatted deno run prettier/main.ts --write - Formats the all files in the repository + Formats the all files in the repository deno run prettier/main.ts script1.ts - Print the formatted code to stdout + Print the formatted code to stdout `; // Available parsers @@ -230,7 +240,8 @@ async function formatSourceFiles( /** * Get the files to format. * @param selectors The glob patterns to select the files. - * eg `cmd/*.ts` to select all the typescript files in cmd directory. + * eg `cmd/*.ts` to select all the typescript files in cmd + * directory. * eg `cmd/run.ts` to select `cmd/run.ts` file as only. * @param ignore The glob patterns to ignore files. * eg `*_test.ts` to ignore all the test file. diff --git a/prettier/main_test.ts b/prettier/main_test.ts index 13340b04e..a2bc25702 100644 --- a/prettier/main_test.ts +++ b/prettier/main_test.ts @@ -197,9 +197,9 @@ console.log([function foo() {}, function baz() {}, (a) => {}]); await run([...cmd, "--prose-wrap", "always", "--write", file3]); assertEquals( normalizeSourceCode(await getSourceCode(file3)), - `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor -incididunt ut labore et dolore magna aliqua. -` + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, " + + "sed do eiusmod tempor" + + "\nincididunt ut labore et dolore magna aliqua.\n" ); await run([...cmd, "--end-of-line", "crlf", "--write", file2]); @@ -227,7 +227,8 @@ test(async function testPrettierPrintToStdout(): Promise<void> { const { stdout: formattedCode } = await run([...cmd, file1]); // The source file will not change without `--write` flags. assertEquals(await getSourceCode(file1), "console.log(0);" + EOL); - // The output will be formatted code even it is the same as the source file's content. + // The output will be formatted code even it is the same as the source file's + // content. assertEquals(formattedCode, "console.log(0);" + EOL); emptyDir(tempDir); diff --git a/testing/diff.ts b/testing/diff.ts index 4c96b3b28..dd544ac24 100644 --- a/testing/diff.ts +++ b/testing/diff.ts @@ -72,9 +72,14 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> { const delta = M - N; const size = M + N + 1; const fp = new Array(size).fill({ y: -1 }); - // INFO: This buffer is used to save memory and improve performance. - // The first half is used to save route and last half is used to save diff type. - // This is because, when I kept new uint8array area to save type, performance worsened. + /** + * INFO: + * This buffer is used to save memory and improve performance. + * The first half is used to save route and last half is used to save diff + * type. + * This is because, when I kept new uint8array area to save type,performance + * worsened. + */ const routes = new Uint32Array((M * N + size + 1) * 2); const diffTypesPtrOffset = routes.length / 2; let ptr = 0; diff --git a/testing/format.ts b/testing/format.ts index af8391b23..7a0d8c173 100644 --- a/testing/format.ts +++ b/testing/format.ts @@ -72,7 +72,9 @@ const getConstructorName = (val: new (...args: any[]) => any): string => (typeof val.constructor === "function" && val.constructor.name) || "Object"; /* global window */ -/** Is val is equal to global window object? Works even if it does not exist :) */ +/** Is val is equal to global window object? + * Works even if it does not exist :) + * */ // eslint-disable-next-line @typescript-eslint/no-explicit-any const isWindow = (val: any): val is Window => typeof window !== "undefined" && val === window; diff --git a/testing/format_test.ts b/testing/format_test.ts index 0601a5db2..39884d484 100644 --- a/testing/format_test.ts +++ b/testing/format_test.ts @@ -10,6 +10,7 @@ import { test } from "./mod.ts"; import { assertEquals } from "../testing/asserts.ts"; import { format } from "./format.ts"; +// eslint-disable-next-line max-len // eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-explicit-any function returnArguments(...args: any[]): IArguments { return arguments; @@ -385,7 +386,8 @@ test({ val.prop = "value1"; assertEquals( format(val), - 'Object {\n "prop": "value1",\n Symbol(symbol1): "value2",\n Symbol(symbol2): "value3",\n}' + 'Object {\n "prop": "value1",\n Symbol(symbol1): "value2",\n ' + + 'Symbol(symbol2): "value3",\n}' ); } }); @@ -607,7 +609,8 @@ test({ const val = { prop: { prop: { prop: "value" } } }; assertEquals( format(val), - 'Object {\n "prop": Object {\n "prop": Object {\n "prop": "value",\n },\n },\n}' + 'Object {\n "prop": Object {\n "prop": Object {\n "prop": ' + + '"value",\n },\n },\n}' ); } }); diff --git a/textproto/mod.ts b/textproto/mod.ts index 6c4e42e51..419a57b68 100644 --- a/textproto/mod.ts +++ b/textproto/mod.ts @@ -106,8 +106,10 @@ export class TextProtoReader { //let key = canonicalMIMEHeaderKey(kv.subarray(0, endKey)); let key = str(kv.subarray(0, endKey)); - // As per RFC 7230 field-name is a token, tokens consist of one or more chars. - // We could return a ProtocolError here, but better to be liberal in what we + // As per RFC 7230 field-name is a token, + // tokens consist of one or more chars. + // We could return a ProtocolError here, + // but better to be liberal in what we // accept, so if we get an empty key, skip it. if (key == "") { continue; diff --git a/textproto/reader_test.ts b/textproto/reader_test.ts index dfe918282..2b81685a2 100644 --- a/textproto/reader_test.ts +++ b/textproto/reader_test.ts @@ -52,7 +52,8 @@ test({ name: "[textproto] Reader : MIME Header", async fn(): Promise<void> { const input = - "my-key: Value 1 \r\nLong-key: Even Longer Value\r\nmy-Key: Value 2\r\n\n"; + "my-key: Value 1 \r\nLong-key: Even Longer Value\r\nmy-Key: " + + "Value 2\r\n\n"; const r = reader(input); const m = assertNotEOF(await r.readMIMEHeader()); assertEquals(m.get("My-Key"), "Value 1, Value 2"); diff --git a/ws/example_client.ts b/ws/example_client.ts index c2be9d76e..cdb482410 100644 --- a/ws/example_client.ts +++ b/ws/example_client.ts @@ -42,7 +42,8 @@ async function main(): Promise<void> { } else { await sock.send(line); } - // FIXME: Without this, sock.receive() won't resolved though it is readable... + // FIXME: Without this, + // sock.receive() won't resolved though it is readable... await new Promise((resolve): void => setTimeout(resolve, 0)); } await sock.close(1000); @@ -474,7 +474,10 @@ async function handshake( } } -/** Connect to given websocket endpoint url. Endpoint must be acceptable for URL */ +/** + * Connect to given websocket endpoint url. + * Endpoint must be acceptable for URL. + */ export async function connectWebSocket( endpoint: string, headers: Headers = new Headers() |