Build: Separate eslint logic for **/*.ts files (#19852)

* build: move typescript specific eslint rules to the `**/*ts.` pattern to avoid errors for .js files

* allow `Example` as class prefix

* allow `example-` as custom element prefix

* Removed `eslint-disable-next-line` comments

from the Example classes.

* Code formatting/tidy-up of Example classes

---------

Co-authored-by: leekelleher <leekelleher@gmail.com>
This commit is contained in:
Jacob Overgaard
2025-08-05 13:42:39 +02:00
committed by GitHub
parent 0c22d512e2
commit 71057b5f0b
13 changed files with 51 additions and 48 deletions

View File

@@ -1,3 +1,5 @@
const ALLOWED_PREFIXES = ['umb-', 'ufm-', 'test-', 'example-'];
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
@@ -23,9 +25,8 @@ module.exports = {
if (isCustomElementDecorator) {
const elementName = node.arguments[0].value;
// 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));
// check if the element name starts with an allowed prefix:
const isElementNameValid = ALLOWED_PREFIXES.some((prefix) => elementName.startsWith(prefix));
if (!isElementNameValid) {
context.report({

View File

@@ -1,3 +1,5 @@
const ALLOWED_PREFIXES = ['Umb', 'Example'];
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
@@ -11,10 +13,10 @@ module.exports = {
},
create: function (context) {
function checkClassName(node) {
if (node.id && node.id.name && !node.id.name.startsWith('Umb')) {
if (node.id && node.id.name && !ALLOWED_PREFIXES.some((prefix) => node.id.name.startsWith(prefix))) {
context.report({
node: node.id,
message: 'Class declaration should be prefixed with "Umb"',
message: `Class declaration should be prefixed with one of the following prefixes: ${ALLOWED_PREFIXES.join(', ')}`,
});
}
}