diff --git a/lib/rules/enforce-style-attribute.js b/lib/rules/enforce-style-attribute.js index 9710a1315..f089a3729 100644 --- a/lib/rules/enforce-style-attribute.js +++ b/lib/rules/enforce-style-attribute.js @@ -92,9 +92,9 @@ module.exports = { return {} } - const topLevelElements = documentFragment.children.filter(isVElement) - const topLevelStyleTags = topLevelElements.filter( - (element) => element.rawName === 'style' + const topLevelStyleTags = documentFragment.children.filter( + /** @returns {element is VElement} */ + (element) => isVElement(element) && element.rawName === 'style' ) if (topLevelStyleTags.length === 0) { diff --git a/lib/rules/require-explicit-slots.js b/lib/rules/require-explicit-slots.js index aab09c494..0ae77b597 100644 --- a/lib/rules/require-explicit-slots.js +++ b/lib/rules/require-explicit-slots.js @@ -59,9 +59,10 @@ module.exports = { if (!documentFragment) { return {} } - const scripts = documentFragment.children - .filter(utils.isVElement) - .filter((element) => element.name === 'script') + const scripts = documentFragment.children.filter( + /** @returns {element is VElement} */ + (element) => utils.isVElement(element) && element.name === 'script' + ) if (scripts.every((script) => !utils.hasAttribute(script, 'lang', 'ts'))) { return {} } diff --git a/lib/utils/index.js b/lib/utils/index.js index d43541888..6773611cb 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -2643,9 +2643,10 @@ function getScriptSetupElement(context) { if (!df) { return null } - const scripts = df.children - .filter(isVElement) - .filter((e) => e.name === 'script') + const scripts = df.children.filter( + /** @returns {e is VElement} */ + (e) => isVElement(e) && e.name === 'script' + ) if (scripts.length === 2) { return scripts.find((e) => hasAttribute(e, 'setup')) || null } else { diff --git a/lib/utils/selector.js b/lib/utils/selector.js index 67960d59a..7b1f15c3f 100644 --- a/lib/utils/selector.js +++ b/lib/utils/selector.js @@ -580,9 +580,10 @@ function buildPseudoNthVElementMatcher(testIndex) { */ function buildPseudoNthOfTypeVElementMatcher(testIndex) { return (element) => { - const elements = element.parent.children - .filter(isVElement) - .filter((e) => e.rawName === element.rawName) + const elements = element.parent.children.filter( + /** @returns {e is VElement} */ + (e) => isVElement(e) && e.rawName === element.rawName + ) return testIndex(elements.indexOf(element), elements.length) } } diff --git a/lib/utils/style-variables/index.js b/lib/utils/style-variables/index.js index 66f224306..651d06ebc 100644 --- a/lib/utils/style-variables/index.js +++ b/lib/utils/style-variables/index.js @@ -47,9 +47,10 @@ function getStyleVariablesContext(context) { if (!df) { return null } - const styles = df.children - .filter(isVElement) - .filter((e) => e.name === 'style') + const styles = df.children.filter( + /** @returns {e is VElement} */ + (e) => isVElement(e) && e.name === 'style' + ) if (styles.length === 0) { return null }