Skip to content

Commit

Permalink
chore: Add comment for the "ts-expect-error"
Browse files Browse the repository at this point in the history
  • Loading branch information
scagood committed Apr 7, 2024
1 parent 45009d3 commit 5ea136a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
8 changes: 0 additions & 8 deletions lib/typescript-fixes.d.ts

This file was deleted.

4 changes: 1 addition & 3 deletions lib/util/get-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ function readPackageJson(dir) {
const filePath = path.join(dir, "package.json")
try {
const text = fs.readFileSync(filePath, "utf8")
const data = /** @type {import('type-fest').JsonValue} */ (
JSON.parse(text)
)
const data = JSON.parse(text)

if (
data != null &&
Expand Down
33 changes: 18 additions & 15 deletions lib/util/merge-visitors-in-place.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@ module.exports = function mergeVisitorsInPlace(visitor1, visitor2) {
const handler1 = visitor1[key]
const handler2 = visitor2[key]

if (typeof handler1 === "function") {
// @ts-expect-error
if (handler1._handlers) {
// @ts-expect-error
handler1._handlers.push(handler2)
} else {
const handlers = [handler1, handler2]
// @ts-expect-error
visitor1[key] = Object.assign(
// @ts-expect-error
dispatch.bind(null, handlers),
{ _handlers: handlers }
)
}
} else {
if (typeof handler1 !== "function") {
visitor1[key] = handler2
continue
}

if (typeof handler2 !== "function") {
continue
}

if ("_handlers" in handler1 && Array.isArray(handler1._handlers)) {
handler1._handlers.push(handler2)
continue
}

const handlers = [handler1, handler2]

// @ts-expect-error - This is because its expecting a function that can match all {Rule.RuleListener[string]} functions!
visitor1[key] = Object.assign(dispatch.bind(null, handlers), {
_handlers: handlers,
})
}

return visitor1
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"skipDefaultLibCheck": false,
"skipLibCheck": false
},
"include": ["./lib/eslint-utils.d.ts", "lib/typescript-fixes.d.ts"],
"include": ["./lib/eslint-utils.d.ts"],
"files": ["./lib/index.js"]
}

0 comments on commit 5ea136a

Please sign in to comment.