Skip to content

Commit 4fbe625

Browse files
ESLint fixes
1 parent 2446445 commit 4fbe625

14 files changed

+23
-29
lines changed

karma.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// https://jstools.dev/karma-config/
44

55
"use strict";
6+
67
const { karmaConfig } = require("@jsdevtools/karma-config");
78
const { host } = require("@jsdevtools/host-environment");
89

src/constructor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export { constructor as Ono };
99
/**
1010
* Creates an `Ono` instance for a specifc error type.
1111
*/
12-
// tslint:disable-next-line: variable-name
12+
// eslint-disable-next-line @typescript-eslint/naming-convention
1313
function Ono<T extends ErrorLike>(ErrorConstructor: ErrorLikeConstructor<T>, options?: OnoOptions) {
1414
options = normalizeOptions(options);
1515

src/extend-error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export function extendError<T extends ErrorLike, E extends ErrorLike, P extends
2727
onoError.toJSON = toJSON;
2828

2929
// On Node.js, add support for the `util.inspect()` method
30+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
3031
if (addInspectMethod) {
3132
addInspectMethod(onoError);
3233
}
@@ -69,7 +70,6 @@ function mergeErrors(newError: ErrorLike, originalError: ErrorPOJO) {
6970

7071
// HACK: We have to cast the errors to `any` so we can use symbol indexers.
7172
// see https://github.com/Microsoft/TypeScript/issues/1863
72-
// tslint:disable: no-any no-unsafe-any
7373
let _newError = newError as any;
7474
let _originalError = originalError as any;
7575

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
/* eslint-env commonjs */
12
import { ono } from "./singleton";
23

34
export { Ono } from "./constructor";
45
export * from "./types";
56
export { ono };
67

7-
// tslint:disable-next-line: no-default-export
88
export default ono;
99

1010
// CommonJS default export hack
1111
if (typeof module === "object" && typeof module.exports === "object") {
12-
module.exports = Object.assign(module.exports.default, module.exports); // tslint:disable-line: no-unsafe-any
12+
module.exports = Object.assign(module.exports.default, module.exports);
1313
}

src/isomorphic.node.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const format = util.format;
1919
* @see https://nodejs.org/api/util.html#util_util_inspect_custom
2020
*/
2121
export function addInspectMethod<T>(newError: OnoError<T>): void {
22-
// @ts-ignore
22+
// @ts-expect-error - TypeScript doesn't support symbol indexers
2323
newError[inspectMethod] = inspect;
2424
}
2525

@@ -31,7 +31,6 @@ export function addInspectMethod<T>(newError: OnoError<T>): void {
3131
function inspect<T>(this: OnoError<T>): ErrorPOJO & T {
3232
// HACK: We have to cast the objects to `any` so we can use symbol indexers.
3333
// see https://github.com/Microsoft/TypeScript/issues/1863
34-
// tslint:disable: no-any no-unsafe-any
3534
let pojo: any = {};
3635
let error = this as any;
3736

@@ -42,8 +41,8 @@ function inspect<T>(this: OnoError<T>): ErrorPOJO & T {
4241

4342
// Don't include the `inspect()` method on the output object,
4443
// otherwise it will cause `util.inspect()` to go into an infinite loop
45-
delete pojo[inspectMethod]; // tslint:disable-line: no-dynamic-delete
44+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
45+
delete pojo[inspectMethod];
4646

47-
// tslint:enable: no-any no-unsafe-any
4847
return pojo as ErrorPOJO & T;
4948
}

src/stack.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable: no-unbound-method
21
import { ErrorLike } from "./types";
32

43
const newline = /\r?\n/;
@@ -50,7 +49,7 @@ export function joinStacks(newError: ErrorLike, originalError?: ErrorLike): stri
5049
return newStack + "\n\n" + originalStack;
5150
}
5251
else {
53-
return newStack || originalStack;
52+
return newStack || originalStack;
5453
}
5554
}
5655

src/to-json.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const objectPrototype = Object.getPrototypeOf({});
1111
export function toJSON<E extends ErrorLike>(this: E): ErrorPOJO & E {
1212
// HACK: We have to cast the objects to `any` so we can use symbol indexers.
1313
// see https://github.com/Microsoft/TypeScript/issues/1863
14-
// tslint:disable: no-any no-unsafe-any
1514
let pojo: any = {};
1615
let error = this as any;
1716

@@ -26,7 +25,6 @@ export function toJSON<E extends ErrorLike>(this: E): ErrorPOJO & E {
2625
}
2726
}
2827

29-
// tslint:enable: no-any no-unsafe-any
3028
return pojo as ErrorPOJO & E;
3129
}
3230

src/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ export interface OnoConstructor {
6060
* @param originalError - The original error. This error's stack trace will be added to the error's stack trace.
6161
* @param props - An object whose properties will be added to the error
6262
*/
63-
extend<T extends ErrorLike, E extends ErrorLike, P extends object>(error: T, originalError?: E, props?: P)
64-
: T & E & P & OnoError<T & E & P>;
63+
extend<T extends ErrorLike, E extends ErrorLike, P extends object>(error: T, originalError?: E, props?: P): T & E & P & OnoError<T & E & P>;
6564
}
6665

6766
/**
@@ -107,8 +106,7 @@ export interface Ono<T extends ErrorLike> {
107106
* @param message - The new error message, possibly including argument placeholders
108107
* @param params - Optional arguments to replace the corresponding placeholders in the message
109108
*/
110-
<E extends ErrorLike, P extends object>(error: E, props: P, message: string, ...params: unknown[])
111-
: T & E & P & OnoError<T & E & P>;
109+
<E extends ErrorLike, P extends object>(error: E, props: P, message: string, ...params: unknown[]): T & E & P & OnoError<T & E & P>;
112110

113111
/**
114112
* Creates an error with a formatted message.

test/specs/format.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ describe("Error message formatter", () => {
7979
// A simple formatter that replaces $0, $1, $2, etc. with the corresponding param
8080
function myCustomFormatter (message) {
8181
let params = Array.prototype.slice.call(arguments, 1);
82-
return params.reduce(function (msg, param, index) {
83-
return msg.replace("$" + index, param);
84-
}, message);
82+
return params.reduce((msg, param, index) => msg.replace("$" + index, param), message);
8583
}
8684

8785
let myCustomOno = new Ono(SyntaxError, { format: myCustomFormatter });

test/specs/options.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ describe("Ono options", () => {
215215
// A simple formatter that replaces $0, $1, $2, etc. with the corresponding param
216216
function myCustomFormatter (message) {
217217
let params = Array.prototype.slice.call(arguments, 1);
218-
return params.reduce(function (msg, param, index) {
219-
return msg.replace("$" + index, param);
220-
}, message);
218+
return params.reduce((msg, param, index) => msg.replace("$" + index, param), message);
221219
}
222220

223221
let myCustomOno = new Ono(SyntaxError, {

0 commit comments

Comments
 (0)