diff --git a/lib/rules/no-inner-html.js b/lib/rules/no-inner-html.js index 24b30f1..4a4330e 100644 --- a/lib/rules/no-inner-html.js +++ b/lib/rules/no-inner-html.js @@ -30,7 +30,7 @@ module.exports = { function mightBeHTMLElement(node) { const type = astUtils.getNodeTypeAsString(fullTypeChecker, node, context); - return type.match(/HTML.*Element/) || type === "any"; + return type.match(/HTML.*Element/) || type === "any" || type == "Element"; } return { diff --git a/lib/rules/no-postmessage-star-origin.js b/lib/rules/no-postmessage-star-origin.js index 5a76c0e..680e5ae 100644 --- a/lib/rules/no-postmessage-star-origin.js +++ b/lib/rules/no-postmessage-star-origin.js @@ -9,6 +9,10 @@ const astUtils = require("../ast-utils"); +function isWindowOrAny(type) { + return type === "any" || type === "Window"; +} + module.exports = { meta: { type: "suggestion", @@ -41,7 +45,12 @@ module.exports = { ); const tsType = fullTypeChecker.getTypeAtLocation(tsNode); const type = fullTypeChecker.typeToString(tsType); - if (type !== "any" && type !== "Window") { + // Remove some false positives by returning if the type does not contain Window or any + if (tsType.isUnionOrIntersection()) { + if (tsType.types.every((t) => !isWindowOrAny(fullTypeChecker.typeToString(t)))) { + return; + } + } else if (!isWindowOrAny(type)) { return; } }