Skip to content

Commit 45603e2

Browse files
authored
rule to accept element base for abstract element class names (#17969)
1 parent 42f49eb commit 45603e2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Umbraco.Web.UI.Client/devops/eslint/rules/enforce-element-suffix-on-element-class-name.cjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@ module.exports = {
1212
create: function (context) {
1313
return {
1414
ClassDeclaration(node) {
15+
// check if class is abstract
16+
const isAbstract = node.abstract;
17+
1518
// check if the class extends HTMLElement, LitElement, or UmbLitElement
1619
const isExtendingElement =
1720
node.superClass && ['HTMLElement', 'LitElement', 'UmbLitElement'].includes(node.superClass.name);
18-
// check if the class name ends with 'Element'
19-
const isClassNameValid = node.id.name.endsWith('Element');
21+
22+
// check if the class name ends with 'Element' or 'ElementBase'
23+
const isClassNameValid = node.id.name.endsWith('Element') || isAbstract && node.id.name.endsWith('ElementBase');
24+
2025

2126
if (isExtendingElement && !isClassNameValid) {
2227
context.report({

0 commit comments

Comments
 (0)