Skip to content

Commit 523f77b

Browse files
ESLint fixes
1 parent 30dcf59 commit 523f77b

19 files changed

+108
-111
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"node": ">=10"
5353
},
5454
"devDependencies": {
55-
"@jsdevtools/eslint-config": "^1.0.3",
55+
"@jsdevtools/eslint-config": "^1.0.4",
5656
"@jsdevtools/version-bump-prompt": "^6.0.5",
5757
"@types/chai": "^4.2.11",
5858
"@types/mocha": "^8.0.0",

src/async/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable: promise-function-async
21
import * as fs from "fs";
32
import { DirectoryReader } from "../directory-reader";
43
import { Callback, Options, Stats } from "../types-public";

src/call.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Callback } from "./types-public";
44
* A function that accepts an input value and returns an output value via a callback.
55
* @internal
66
*/
7-
export type Fn<I, O> = (input: I, callback: Callback<O>) => void;
7+
export type Fn<TInput, TOutput> = (input: TInput, callback: Callback<TOutput>) => void;
88

99

1010
/**
@@ -16,15 +16,15 @@ export type Fn<I, O> = (input: I, callback: Callback<O>) => void;
1616
*
1717
* @internal
1818
*/
19-
export function safeCall<I, O>(fn: Fn<I, O>, input: I, callback: Callback<O>): void {
19+
export function safeCall<TInput, TOutput>(fn: Fn<TInput, TOutput>, input: TInput, callback: Callback<TOutput>): void {
2020
// Replace the callback function with a wrapper that ensures it will only be called once
2121
callback = callOnce(callback);
2222

2323
try {
24-
fn.call(undefined, input, callback);
24+
fn(input, callback);
2525
}
2626
catch (err) {
27-
callback(err as Error, undefined as unknown as O);
27+
callback(err as Error, undefined as unknown as TOutput);
2828
}
2929
}
3030

src/directory-reader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export class DirectoryReader {
140140
this.pending === 0 && // The stuff we're currently reading
141141
this.queue.length === 0) { // The stuff we haven't read yet
142142
// There's no more stuff!
143-
this.stream.push(null); // tslint:disable-line: no-null-keyword
143+
this.stream.push(null);
144144
}
145145
}
146146

@@ -295,7 +295,7 @@ export class DirectoryReader {
295295
else if (recurseFn) {
296296
try {
297297
// Run the user-specified recursion criteria
298-
return !!recurseFn.call(undefined, stats);
298+
return !!recurseFn(stats);
299299
}
300300
catch (err) {
301301
// An error occurred in the user's code.
@@ -323,7 +323,7 @@ export class DirectoryReader {
323323
if (filterFn) {
324324
try {
325325
// Run the user-specified filter function
326-
return !!filterFn.call(undefined, stats);
326+
return !!filterFn(stats);
327327
}
328328
catch (err) {
329329
// An error occurred in the user's code.

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable: no-default-export no-unsafe-any
21
import { readdirAsync } from "./async";
32
import { readdirIterator } from "./iterator";
43
import { readdirStream } from "./stream";
@@ -20,15 +19,16 @@ readdir.async = readdirAsync;
2019
readdir.stream = readdirStream;
2120
readdir.iterator = readdirIterator;
2221

23-
export { readdir };
24-
export default readdir;
25-
export * from "./types-public";
26-
export { readdirSync } from "./sync";
2722
export { readdirAsync } from "./async";
2823
export { readdirIterator } from "./iterator";
2924
export { readdirStream } from "./stream";
25+
export { readdirSync } from "./sync";
26+
export * from "./types-public";
27+
export { readdir };
28+
export default readdir;
3029

3130
// CommonJS default export hack
31+
/* eslint-env commonjs */
3232
if (typeof module === "object" && typeof module.exports === "object") {
3333
module.exports = Object.assign(module.exports.default, module.exports);
3434
}

src/iterator/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ export function readdirIterator<T>(dir: string, options?: Options): AsyncIterabl
5252
return this;
5353
},
5454

55-
// tslint:disable-next-line: promise-function-async
5655
next() {
5756
let pendingRead = pending<IteratorResult<T>>();
5857
pendingReads.push(pendingRead);
5958

60-
// tslint:disable-next-line: no-floating-promises
59+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
6160
Promise.resolve().then(fulfillPendingReads);
6261

6362
return pendingRead.promise;

src/iterator/pending.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function pending<T>(): Pending<T> {
1313
return {
1414
promise,
1515
resolve(result) {
16-
// tslint:disable-next-line: no-floating-promises
16+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
1717
Promise.resolve(result).then(resolve);
1818
},
1919
reject(reason: Error) {

src/normalize-options.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export interface NormalizedOptions {
2929
*
3030
* @internal
3131
*/
32-
// tslint:disable-next-line: cyclomatic-complexity
3332
export function normalizeOptions(options: Options | undefined, facade: Facade, emit: boolean): NormalizedOptions {
3433
if (options === null || options === undefined) {
3534
options = {};

test/specs/basePath.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("options.basePath", () => {
1313
it: 'should return relative paths if basePath === "" (empty string)',
1414
args: ["test/dir", { basePath: "" }],
1515
assert (error, data) {
16-
expect(error).to.be.null;
16+
expect(error).to.equal(null);
1717
expect(data).to.have.same.members(dir.shallow.data);
1818
},
1919
streamAssert (errors, data, files, dirs, symlinks) {
@@ -28,7 +28,7 @@ describe("options.basePath", () => {
2828
it: 'should return relative paths if basePath === "."',
2929
args: ["test/dir", { basePath: "." }],
3030
assert (error, data) {
31-
expect(error).to.be.null;
31+
expect(error).to.equal(null);
3232
assertPathsMatch(data, dir.shallow.data, ".");
3333
},
3434
streamAssert (errors, data, files, dirs, symlinks) {
@@ -43,7 +43,7 @@ describe("options.basePath", () => {
4343
it: "should return absolute paths if basePath === absolute path",
4444
args: ["test/dir", { basePath: testDirAbsPath }],
4545
assert (error, data) {
46-
expect(error).to.be.null;
46+
expect(error).to.equal(null);
4747
assertPathsMatch(data, dir.shallow.data, testDirAbsPath);
4848
},
4949
streamAssert (errors, data, files, dirs, symlinks) {
@@ -58,7 +58,7 @@ describe("options.basePath", () => {
5858
it: "should return relative paths to process.cwd() if basePath === path",
5959
args: ["test/dir", { basePath: "test/dir" }],
6060
assert (error, data) {
61-
expect(error).to.be.null;
61+
expect(error).to.equal(null);
6262
assertPathsMatch(data, dir.shallow.data, "test/dir");
6363
},
6464
streamAssert (errors, data, files, dirs, symlinks) {

test/specs/deep.spec.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("options.deep", () => {
1111
it: "should return all deep contents",
1212
args: ["test/dir", { deep: true }],
1313
assert (error, data) {
14-
expect(error).to.be.null;
14+
expect(error).to.equal(null);
1515
expect(data).to.have.same.members(dir.deep.data);
1616
},
1717
streamAssert (errors, data, files, dirs, symlinks) {
@@ -26,7 +26,7 @@ describe("options.deep", () => {
2626
it: "should only return top-level contents if deep === false",
2727
args: ["test/dir", { deep: false }],
2828
assert (error, data) {
29-
expect(error).to.be.null;
29+
expect(error).to.equal(null);
3030
expect(data).to.have.same.members(dir.shallow.data);
3131
},
3232
streamAssert (errors, data, files, dirs, symlinks) {
@@ -41,7 +41,7 @@ describe("options.deep", () => {
4141
it: "should only return top-level contents if deep === 0",
4242
args: ["test/dir", { deep: 0 }],
4343
assert (error, data) {
44-
expect(error).to.be.null;
44+
expect(error).to.equal(null);
4545
expect(data).to.have.same.members(dir.shallow.data);
4646
},
4747
streamAssert (errors, data, files, dirs, symlinks) {
@@ -56,7 +56,7 @@ describe("options.deep", () => {
5656
it: "should return 1-level deep contents",
5757
args: ["test/dir", { deep: 1 }],
5858
assert (error, data) {
59-
expect(error).to.be.null;
59+
expect(error).to.equal(null);
6060
expect(data).to.have.same.members(dir.deep.oneLevel.data);
6161
},
6262
streamAssert (errors, data, files, dirs, symlinks) {
@@ -71,7 +71,7 @@ describe("options.deep", () => {
7171
it: "should return all deep contents if deep is a number greater than the number of dirs",
7272
args: ["test/dir", { deep: 25 }],
7373
assert (error, data) {
74-
expect(error).to.be.null;
74+
expect(error).to.equal(null);
7575
expect(data).to.have.same.members(dir.deep.data);
7676
},
7777
streamAssert (errors, data, files, dirs, symlinks) {
@@ -86,7 +86,7 @@ describe("options.deep", () => {
8686
it: "should return all deep contents if deep === Infinity",
8787
args: ["test/dir", { deep: Infinity }],
8888
assert (error, data) {
89-
expect(error).to.be.null;
89+
expect(error).to.equal(null);
9090
expect(data).to.have.same.members(dir.deep.data);
9191
},
9292
streamAssert (errors, data, files, dirs, symlinks) {
@@ -103,7 +103,7 @@ describe("options.deep", () => {
103103
deep: /^((?!\-symlink).)*$/,
104104
}],
105105
assert (error, data) {
106-
expect(error).to.be.null;
106+
expect(error).to.equal(null);
107107
expect(data).to.have.same.members(this.omitSymlinkDirs(dir.deep.data));
108108
},
109109
streamAssert (errors, data, files, dirs, symlinks) {
@@ -127,7 +127,7 @@ describe("options.deep", () => {
127127
deep: "subdir",
128128
}],
129129
assert (error, data) {
130-
expect(error).to.be.null;
130+
expect(error).to.equal(null);
131131
expect(data).to.have.same.members(this.shallowPlusSubdir("data"));
132132
},
133133
streamAssert (errors, data, files, dirs, symlinks) {
@@ -155,7 +155,7 @@ describe("options.deep", () => {
155155
},
156156
}],
157157
assert (error, data) {
158-
expect(error).to.be.null;
158+
expect(error).to.equal(null);
159159
expect(data).to.have.same.members(this.omitSubdir(dir.deep.data));
160160
},
161161
streamAssert (errors, data, files, dirs, symlinks) {
@@ -181,7 +181,7 @@ describe("options.deep", () => {
181181
},
182182
}],
183183
assert (error, data) {
184-
expect(error).to.be.null;
184+
expect(error).to.equal(null);
185185
expect(data).to.have.same.members(this.omitSubdir(dir.deep.data));
186186
},
187187
streamAssert (errors, data, files, dirs, symlinks) {
@@ -207,7 +207,7 @@ describe("options.deep", () => {
207207
},
208208
}],
209209
assert (error, data) {
210-
expect(error).to.be.null;
210+
expect(error).to.equal(null);
211211
expect(data).to.have.same.members(dir.deep.data);
212212
},
213213
streamAssert (errors, data, files, dirs, symlinks) {
@@ -226,7 +226,7 @@ describe("options.deep", () => {
226226
},
227227
}],
228228
assert (error, data) {
229-
expect(error).to.be.null;
229+
expect(error).to.equal(null);
230230
expect(data).to.have.same.members(dir.shallow.data);
231231
},
232232
streamAssert (errors, data, files, dirs, symlinks) {
@@ -251,7 +251,7 @@ describe("options.deep", () => {
251251
// The sync & async APIs abort after the first error and don't return any data
252252
expect(error).to.be.an.instanceOf(Error);
253253
expect(error.message).to.equal("Boooooom!");
254-
expect(data).to.be.undefined;
254+
expect(data).to.equal(undefined);
255255
},
256256
streamAssert (errors, data, files, dirs, symlinks) {
257257
// The streaming API emits errors and data separately

test/specs/default.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ describe("default behavior", () => {
1313
args: ["test/dir"],
1414
assert (error, data) {
1515
let fsResults = fs.readdirSync("test/dir");
16-
expect(error).to.be.null;
16+
expect(error).to.equal(null);
1717
expect(data).to.have.same.members(fsResults);
1818
},
1919
},
2020
{
2121
it: "should return an empty array for an empty dir",
2222
args: ["test/dir/empty"],
2323
assert (error, data) {
24-
expect(error).to.be.null;
24+
expect(error).to.equal(null);
2525
expect(data).to.be.an("array").with.lengthOf(0);
2626
},
2727
streamAssert (errors, data, files, dirs, symlinks) {
@@ -36,7 +36,7 @@ describe("default behavior", () => {
3636
it: "should return all top-level contents",
3737
args: ["test/dir"],
3838
assert (error, data) {
39-
expect(error).to.be.null;
39+
expect(error).to.equal(null);
4040
expect(data).to.have.same.members(dir.shallow.data);
4141
},
4242
streamAssert (errors, data, files, dirs, symlinks) {
@@ -51,7 +51,7 @@ describe("default behavior", () => {
5151
it: "should return the same results if the path is absolute",
5252
args: [path.resolve("test/dir")],
5353
assert (error, data) {
54-
expect(error).to.be.null;
54+
expect(error).to.equal(null);
5555
expect(data).to.have.same.members(dir.shallow.data);
5656
},
5757
streamAssert (errors, data, files, dirs, symlinks) {
@@ -66,7 +66,7 @@ describe("default behavior", () => {
6666
it: "should return all top-level contents of a directory symlink",
6767
args: ["test/dir/subdir-symlink"],
6868
assert (error, data) {
69-
expect(error).to.be.null;
69+
expect(error).to.equal(null);
7070
expect(data).to.have.same.members(dir.subdir.shallow.data);
7171
},
7272
streamAssert (errors, data, files, dirs, symlinks) {
@@ -81,7 +81,7 @@ describe("default behavior", () => {
8181
it: "should return relative paths",
8282
args: ["test/dir"],
8383
assert (error, data) {
84-
expect(error).to.be.null;
84+
expect(error).to.equal(null);
8585
for (let item of data) {
8686
expect(item).not.to.contain("/");
8787
expect(item).not.to.contain("\\");

0 commit comments

Comments
 (0)