From 5a681a5e841d84088be604d719324a989782fec8 Mon Sep 17 00:00:00 2001 From: Michael Bullington Date: Tue, 8 Feb 2022 12:13:08 -0500 Subject: [PATCH] fix: :art: Allow for HTML elements of the structure VendorHTMLElement ESLint plugin may be more lenient than before, and highlight new issues. --- lib/class-ref-tracker.js | 2 +- lib/custom-selectors.js | 2 +- test/expose-class-on-global.js | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/class-ref-tracker.js b/lib/class-ref-tracker.js index 849256f..662e3f7 100644 --- a/lib/class-ref-tracker.js +++ b/lib/class-ref-tracker.js @@ -46,7 +46,7 @@ class ClassRefTracker { } static customElements(context) { - return new ClassRefTracker(context, superClassRef => superClassRef && /^HTML.*Element$/.test(superClassRef.name)) + return new ClassRefTracker(context, superClassRef => superClassRef && /^.*HTML.*Element$/.test(superClassRef.name)) } } diff --git a/lib/custom-selectors.js b/lib/custom-selectors.js index 5725c85..6892a89 100644 --- a/lib/custom-selectors.js +++ b/lib/custom-selectors.js @@ -1,4 +1,4 @@ -const HTMLElementClass = ':matches(ClassDeclaration, ClassExpression)[superClass.name=/HTML.*Element/]' +const HTMLElementClass = ':matches(ClassDeclaration, ClassExpression)[superClass.name=/.*HTML.*Element/]' const customElements = { _call: '[callee.object.type=Identifier][callee.object.name=customElements],' + diff --git a/test/expose-class-on-global.js b/test/expose-class-on-global.js index 232cec2..42daa55 100644 --- a/test/expose-class-on-global.js +++ b/test/expose-class-on-global.js @@ -20,6 +20,15 @@ ruleTester.run('expose-class-on-global', rule, { } ] }, + { + code: 'class FooBar extends CustomHTMLElement {}', + errors: [ + { + message: 'Custom Element has not been exported onto `window`', + type: 'ClassDeclaration' + } + ] + }, { code: 'window.customElements.define("foo-bar", FooBar)\nclass FooBar extends HTMLElement {}', errors: [