summaryrefslogtreecommitdiff
path: root/fs/path
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2019-10-06 01:02:34 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-10-05 12:02:34 -0400
commit96fe2d10a4da0521b7cd72d90fd42121f9311978 (patch)
treecb4d5ecafa55a3a522cf0ad9d742fb6a1e1f2283 /fs/path
parent2f90225c89926932a34eb40758e2af0d1742e1f8 (diff)
Update eslint and @typescript-eslint (denoland/deno_std#621)
Original: https://github.com/denoland/deno_std/commit/c3fe858f98565edbe8faeb3cf2e5b873304f4f6e
Diffstat (limited to 'fs/path')
-rw-r--r--fs/path/parse_format_test.ts6
-rw-r--r--fs/path/posix.ts19
-rw-r--r--fs/path/win32.ts19
-rw-r--r--fs/path/zero_length_strings_test.ts6
4 files changed, 28 insertions, 22 deletions
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), "");