diff --git a/src/rules/no-invalid-extends.ts b/src/rules/no-invalid-extends.ts index 17d9aee..d74ae03 100644 --- a/src/rules/no-invalid-extends.ts +++ b/src/rules/no-invalid-extends.ts @@ -99,6 +99,13 @@ const rule: Rule.RuleModule = { const source = context.getSourceCode(); const elementClasses = new Set(); const userAllowedSuperNames = context.options[0]?.allowedSuperNames ?? []; + const elementBaseClasses = ['HTMLElement']; + + if (Array.isArray(context.settings.wc?.elementBaseClasses)) { + elementBaseClasses.push( + ...(context.settings.wc.elementBaseClasses as string[]) + ); + } return { 'ClassExpression,ClassDeclaration': (node: ESTree.Class): void => { @@ -135,7 +142,9 @@ const rule: Rule.RuleModule = { ]); } else { allowedSuperNames = new Set(userAllowedSuperNames); - allowedSuperNames.add('HTMLElement'); + for (const baseClass of elementBaseClasses) { + allowedSuperNames.add(baseClass); + } } const formattedSuperNames = formatNames(allowedSuperNames); diff --git a/src/test/rules/no-invalid-extends_test.ts b/src/test/rules/no-invalid-extends_test.ts index 4e3f26d..3ad3495 100644 --- a/src/test/rules/no-invalid-extends_test.ts +++ b/src/test/rules/no-invalid-extends_test.ts @@ -120,6 +120,15 @@ ruleTester.run('no-invalid-extends', rule, { code: `@customElement('x-foo') class A extends SomeElement {}`, parser + }, + { + code: `class A extends SomeElement {} + customElements.define('a', A);`, + settings: { + wc: { + elementBaseClasses: ['SomeElement'] + } + } } ],