UFM: Code tidy-up (#19687)

* Reverted `elementName` constant

* UFM base element: simplify context check

* Adds console warning if UFM filter does not exist

* Removed unnecessary casting/typing

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Moved console warnings outside of loop

* Added "ufm-" prefix to eslint local rules

---------

Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Lee Kelleher
2025-07-08 13:21:47 +01:00
committed by GitHub
parent 118b26a8b9
commit 05010fc707
9 changed files with 30 additions and 34 deletions

View File

@@ -23,13 +23,14 @@ module.exports = {
if (isCustomElementDecorator) {
const elementName = node.arguments[0].value;
// check if the element name starts with 'umb-', or 'test-', to be allow tests to have custom elements:
const isElementNameValid = elementName.startsWith('umb-') ? true : elementName.startsWith('test-');
// check if the element name starts with 'umb-', 'ufm-', or 'test-', to be allow tests to have custom elements:
const prefixes = ['umb-', 'ufm-', 'test-'];
const isElementNameValid = prefixes.some((prefix) => elementName.startsWith(prefix));
if (!isElementNameValid) {
context.report({
node,
message: 'Custom Element name should start with "umb-".',
message: 'Custom Element name should start with "umb-" or "ufm-".',
// There is no fixer on purpose because it's not safe to automatically rename the element name.
// Renaming should be done manually with consideration of potential impacts.
});