Skip to content

Commit 5e3ac1f

Browse files
committed
chore: Add comment for the "ts-expect-error"
1 parent 325f0d7 commit 5e3ac1f

4 files changed

+20
-27
lines changed

lib/typescript-fixes.d.ts

-8
This file was deleted.

lib/util/get-package-json.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ function readPackageJson(dir) {
2222
const filePath = path.join(dir, "package.json")
2323
try {
2424
const text = fs.readFileSync(filePath, "utf8")
25-
const data = /** @type {import('type-fest').JsonValue} */ (
26-
JSON.parse(text)
27-
)
25+
const data = JSON.parse(text)
2826

2927
if (
3028
data != null &&

lib/util/merge-visitors-in-place.js

+18-15
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,26 @@ module.exports = function mergeVisitorsInPlace(visitor1, visitor2) {
1616
const handler1 = visitor1[key]
1717
const handler2 = visitor2[key]
1818

19-
if (typeof handler1 === "function") {
20-
// @ts-expect-error
21-
if (handler1._handlers) {
22-
// @ts-expect-error
23-
handler1._handlers.push(handler2)
24-
} else {
25-
const handlers = [handler1, handler2]
26-
// @ts-expect-error
27-
visitor1[key] = Object.assign(
28-
// @ts-expect-error
29-
dispatch.bind(null, handlers),
30-
{ _handlers: handlers }
31-
)
32-
}
33-
} else {
19+
if (typeof handler1 !== "function") {
3420
visitor1[key] = handler2
21+
continue
3522
}
23+
24+
if (typeof handler2 !== "function") {
25+
continue
26+
}
27+
28+
if ("_handlers" in handler1 && Array.isArray(handler1._handlers)) {
29+
handler1._handlers.push(handler2)
30+
continue
31+
}
32+
33+
const handlers = [handler1, handler2]
34+
35+
// @ts-expect-error - This is because its expecting a function that can match all {Rule.RuleListener[string]} functions!
36+
visitor1[key] = Object.assign(dispatch.bind(null, handlers), {
37+
_handlers: handlers,
38+
})
3639
}
3740

3841
return visitor1

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"skipDefaultLibCheck": false,
2121
"skipLibCheck": false
2222
},
23-
"include": ["./lib/eslint-utils.d.ts", "lib/typescript-fixes.d.ts"],
23+
"include": ["./lib/eslint-utils.d.ts"],
2424
"files": ["./lib/index.js"]
2525
}

0 commit comments

Comments
 (0)