diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/copy.ts | 8 | ||||
-rw-r--r-- | fs/glob.ts | 2 | ||||
-rw-r--r-- | fs/globrex.ts | 8 | ||||
-rw-r--r-- | fs/globrex_test.ts | 4 | ||||
-rw-r--r-- | fs/path/parse_format_test.ts | 6 | ||||
-rw-r--r-- | fs/path/posix.ts | 19 | ||||
-rw-r--r-- | fs/path/win32.ts | 19 | ||||
-rw-r--r-- | fs/path/zero_length_strings_test.ts | 6 | ||||
-rw-r--r-- | fs/walk.ts | 6 |
9 files changed, 41 insertions, 37 deletions
diff --git a/fs/copy.ts b/fs/copy.ts index c3c97d1ba..616fba975 100644 --- a/fs/copy.ts +++ b/fs/copy.ts @@ -21,11 +21,9 @@ async function ensureValidCopy( src: string, dest: string, options: CopyOptions, - isCopyFolder: boolean = false + isCopyFolder = false ): Promise<Deno.FileInfo> { - let destStat: Deno.FileInfo | null; - - destStat = await Deno.lstat(dest).catch( + const destStat: Deno.FileInfo | null = await Deno.lstat(dest).catch( (): Promise<null> => Promise.resolve(null) ); @@ -47,7 +45,7 @@ function ensureValidCopySync( src: string, dest: string, options: CopyOptions, - isCopyFolder: boolean = false + isCopyFolder = false ): Deno.FileInfo { let destStat: Deno.FileInfo | null; diff --git a/fs/glob.ts b/fs/glob.ts index d9e6560c1..86d83b4f8 100644 --- a/fs/glob.ts +++ b/fs/glob.ts @@ -112,7 +112,7 @@ export function joinGlobs( if (globs.length === 0) return "."; let joined: string | undefined; for (const glob of globs) { - let path = glob; + const path = glob; if (path.length > 0) { if (!joined) joined = path; else joined += `${SEP}${path}`; diff --git a/fs/globrex.ts b/fs/globrex.ts index 03d69fc8b..5bf0e16a0 100644 --- a/fs/globrex.ts +++ b/fs/globrex.ts @@ -127,7 +127,7 @@ export function globrex( if (c === ")") { if (ext.length) { add(c); - let type: string | undefined = ext.pop(); + const type: string | undefined = ext.pop(); if (type === "@") { add("{1}"); } else if (type === "!") { @@ -264,19 +264,19 @@ export function globrex( } // Move over all consecutive "*"'s. // Also store the previous and next characters - let prevChar = glob[i - 1]; + const prevChar = glob[i - 1]; let starCount = 1; while (glob[i + 1] === "*") { starCount++; i++; } - let nextChar = glob[i + 1]; + const nextChar = glob[i + 1]; if (!globstar) { // globstar is disabled, so treat any number of "*" as one add(".*"); } else { // globstar is enabled, so determine if this is a globstar segment - let isGlobstar = + const isGlobstar = starCount > 1 && // multiple "*"'s // from the start of the segment [SEP_RAW, "/", undefined].includes(prevChar) && diff --git a/fs/globrex_test.ts b/fs/globrex_test.ts index 6d421611f..31607216d 100644 --- a/fs/globrex_test.ts +++ b/fs/globrex_test.ts @@ -19,14 +19,14 @@ function match( opts = strWin; strWin = ""; } - let res = globrex(glob, opts); + const res = globrex(glob, opts); return res.regex.test(isWin && strWin ? strWin : strUnix); } test({ name: "globrex: standard", fn(): void { - let res = globrex("*.js"); + const res = globrex("*.js"); 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"); diff --git a/fs/path/parse_format_test.ts b/fs/path/parse_format_test.ts index 8829891da..db83c3354 100644 --- a/fs/path/parse_format_test.ts +++ b/fs/path/parse_format_test.ts @@ -1,5 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ +/* eslint-disable @typescript-eslint/no-explicit-any */ +// TODO(kt3k): fix any types in this file import { test } from "../../testing/mod.ts"; import { assertEquals } from "../../testing/asserts.ts"; @@ -80,7 +82,7 @@ const unixSpecialCaseFormatTests = [ ]; function checkParseFormat(path: any, paths: any): void { - paths.forEach(function(p: Record<string, unknown>[]) { + paths.forEach(function(p: Array<Record<string, unknown>>) { const element = p[0]; const output = path.parse(element); assertEquals(typeof output.root, "string"); @@ -96,7 +98,7 @@ function checkParseFormat(path: any, paths: any): void { } function checkSpecialCaseParseFormat(path: any, testCases: any): void { - testCases.forEach(function(testCase: Record<string, unknown>[]) { + testCases.forEach(function(testCase: Array<Record<string, unknown>>) { const element = testCase[0]; const expect = testCase[1]; const output = path.parse(element); diff --git a/fs/path/posix.ts b/fs/path/posix.ts index 4fe0f64c0..4377fd542 100644 --- a/fs/path/posix.ts +++ b/fs/path/posix.ts @@ -83,7 +83,7 @@ export function join(...paths: string[]): string { if (paths.length === 0) return "."; let joined: string | undefined; for (let i = 0, len = paths.length; i < len; ++i) { - let path = paths[i]; + const path = paths[i]; assertPath(path); if (path.length > 0) { if (!joined) joined = path; @@ -107,11 +107,11 @@ export function relative(from: string, to: string): string { // Trim any leading backslashes let fromStart = 1; - let fromEnd = from.length; + const fromEnd = from.length; for (; fromStart < fromEnd; ++fromStart) { if (from.charCodeAt(fromStart) !== CHAR_FORWARD_SLASH) break; } - let fromLen = fromEnd - fromStart; + const fromLen = fromEnd - fromStart; // Trim any leading backslashes let toStart = 1; @@ -119,10 +119,10 @@ export function relative(from: string, to: string): string { for (; toStart < toEnd; ++toStart) { if (to.charCodeAt(toStart) !== CHAR_FORWARD_SLASH) break; } - let toLen = toEnd - toStart; + const toLen = toEnd - toStart; // Compare paths to find the longest common path from root - let length = fromLen < toLen ? fromLen : toLen; + const length = fromLen < toLen ? fromLen : toLen; let lastCommonSep = -1; let i = 0; for (; i <= length; ++i) { @@ -150,8 +150,8 @@ export function relative(from: string, to: string): string { } break; } - let fromCode = from.charCodeAt(fromStart + i); - let toCode = to.charCodeAt(toStart + i); + const fromCode = from.charCodeAt(fromStart + i); + const toCode = to.charCodeAt(toStart + i); if (fromCode !== toCode) break; else if (fromCode === CHAR_FORWARD_SLASH) lastCommonSep = i; } @@ -328,6 +328,7 @@ export function extname(path: string): string { } export function format(pathObject: FormatInputPathObject): string { + /* eslint-disable max-len */ if (pathObject === null || typeof pathObject !== "object") { throw new TypeError( `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}` @@ -339,9 +340,9 @@ export function format(pathObject: FormatInputPathObject): string { export function parse(path: string): ParsedPath { assertPath(path); - let ret: ParsedPath = { root: "", dir: "", base: "", ext: "", name: "" }; + const ret: ParsedPath = { root: "", dir: "", base: "", ext: "", name: "" }; if (path.length === 0) return ret; - let isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH; + const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH; let start: number; if (isAbsolute) { ret.root = "/"; diff --git a/fs/path/win32.ts b/fs/path/win32.ts index d42cc4885..79e04ea6e 100644 --- a/fs/path/win32.ts +++ b/fs/path/win32.ts @@ -304,7 +304,7 @@ export function join(...paths: string[]): string { let joined: string | undefined; let firstPart: string; for (let i = 0; i < pathsCount; ++i) { - let path = paths[i]; + const path = paths[i]; assertPath(path); if (path.length > 0) { if (joined === undefined) joined = firstPart = path; @@ -369,8 +369,8 @@ export function relative(from: string, to: string): string { if (from === to) return ""; - let fromOrig = resolve(from); - let toOrig = resolve(to); + const fromOrig = resolve(from); + const toOrig = resolve(to); if (fromOrig === toOrig) return ""; @@ -389,7 +389,7 @@ export function relative(from: string, to: string): string { for (; fromEnd - 1 > fromStart; --fromEnd) { if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH) break; } - let fromLen = fromEnd - fromStart; + const fromLen = fromEnd - fromStart; // Trim any leading backslashes let toStart = 0; @@ -401,10 +401,10 @@ export function relative(from: string, to: string): string { for (; toEnd - 1 > toStart; --toEnd) { if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH) break; } - let toLen = toEnd - toStart; + const toLen = toEnd - toStart; // Compare paths to find the longest common path from root - let length = fromLen < toLen ? fromLen : toLen; + const length = fromLen < toLen ? fromLen : toLen; let lastCommonSep = -1; let i = 0; for (; i <= length; ++i) { @@ -433,8 +433,8 @@ export function relative(from: string, to: string): string { } break; } - let fromCode = from.charCodeAt(fromStart + i); - let toCode = to.charCodeAt(toStart + i); + const fromCode = from.charCodeAt(fromStart + i); + const toCode = to.charCodeAt(toStart + i); if (fromCode !== toCode) break; else if (fromCode === CHAR_BACKWARD_SLASH) lastCommonSep = i; } @@ -737,6 +737,7 @@ export function extname(path: string): string { } export function format(pathObject: FormatInputPathObject): string { + /* eslint-disable max-len */ if (pathObject === null || typeof pathObject !== "object") { throw new TypeError( `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}` @@ -748,7 +749,7 @@ export function format(pathObject: FormatInputPathObject): string { export function parse(path: string): ParsedPath { assertPath(path); - let ret: ParsedPath = { root: "", dir: "", base: "", ext: "", name: "" }; + const ret: ParsedPath = { root: "", dir: "", base: "", ext: "", name: "" }; const len = path.length; if (len === 0) return ret; diff --git a/fs/path/zero_length_strings_test.ts b/fs/path/zero_length_strings_test.ts index 20405563c..744e97735 100644 --- a/fs/path/zero_length_strings_test.ts +++ b/fs/path/zero_length_strings_test.ts @@ -27,7 +27,8 @@ test(function normalizeZeroLength() { }); test(function isAbsoluteZeroLength() { - // Since '' is not a valid path in any of the common environments, return false + // Since '' is not a valid path in any of the common environments, + // return false assertEquals(path.posix.isAbsolute(""), false); if (path.win32) assertEquals(path.win32.isAbsolute(""), false); }); @@ -40,7 +41,8 @@ test(function resolveZeroLength() { }); test(function relativeZeroLength() { - // relative, internally calls resolve. So, '' is actually the current directory + // relative, internally calls resolve. So, '' is actually the current + // directory assertEquals(path.relative("", pwd), ""); assertEquals(path.relative(pwd, ""), ""); assertEquals(path.relative(pwd, pwd), ""); diff --git a/fs/walk.ts b/fs/walk.ts index 583b4dd55..4808598af 100644 --- a/fs/walk.ts +++ b/fs/walk.ts @@ -22,7 +22,7 @@ function patternTest(patterns: RegExp[], path: string): boolean { // consistent results. // See: https://stackoverflow.com/a/1520853 return patterns.some((pattern): boolean => { - let r = pattern.test(path); + const r = pattern.test(path); pattern.lastIndex = 0; return r; }); @@ -100,7 +100,7 @@ export async function* walk( options.onError(err); } } - for (let info of ls) { + for (const info of ls) { if (info.isSymlink()) { if (options.followSymlinks) { // TODO(ry) Re-enable followSymlinks. @@ -154,7 +154,7 @@ export function* walkSync( options.onError(err); } } - for (let info of ls) { + for (const info of ls) { if (info.isSymlink()) { if (options.followSymlinks) { unimplemented(); |