Eslint naming conventions (#19880)

* build(eslint): replace local rules with naming conventions

* revert relative js extension imports

* remove unused local rule

* build(eslint): uses recommended setup for import plugin

* chore(eslint): conver const to function to follow naming conventions

* chore: removes old file

* build(eslint): allows Ufm as prefix

* build(eslint): allows 'name' and 'extensions' as exports (umbraco-package.ts)

* build(eslint): typescript rules should ignore storybook

* chore(eslint): ignores eslint for vite definitions

* build(eslint): allows UPPER_CASE for properties

* build(eslint): ignores umbraco-package.ts files (unconventional exports)

* chore(storybook): fixes property editor stylesheet picker

* build(eslint): allows Manifest as prefix on interfaces

* build(eslint): allows underscore on protected members

* build(eslint): allows Meta as prefix on interfaces

* build(eslint): allows PascalCase for public members

* build(eslint): disables enforcement of booleans with verbs for now as it is too harsh

* chore(eslint): add private modifiers as required

* deprecates invalid constant name to replace with Umb prefix

* renames MediaValueType to comply with naming conventions

* chore(eslint): disable naming conventions for local router-slot package

* chore(eslint): follow naming conventions

* chore(eslint): disable naming conventions for property editor interfaces

* chore(eslint): follow naming conventions

* chore(storybook): fix story

* chore(eslint): follow naming conventions

* build(eslint): allows `_host` as public variable

* chore(eslint): follow naming conventions

* build(eslint): allows double leading underscore on public members

* build(eslint): matches #private and public modifiers

* build(eslint): ignores language files

* chore(eslint): ignores umbraco package file

* chore(eslint): follow naming conventions

* storybook lang

* chore(eslint): follow naming conventions

* chore(eslint): follow naming conventions

* chore(eslint): make _manager a little more open

* chore(eslint): some properties should be protected

* Update src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-image-cropper/image-cropper.element.ts

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

* Update src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-image-cropper/image-cropper.element.ts

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

* Update src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-image-cropper/image-cropper.element.ts

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

* proxy type for UrlParametersRecord

* _items deprecated property

* bring back ConditionTypes type

* bring back _items for trash bulk action

* ignorer deprecated proxies

* keep settingsDataContentTypeKey for satefy

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
Co-authored-by: Niels Lyngsø <nsl@umbraco.dk>
This commit is contained in:
Jacob Overgaard
2025-08-08 10:52:14 +02:00
committed by GitHub
parent b3d5744d34
commit 2def046ea3
268 changed files with 1055 additions and 982 deletions

View File

@@ -1,31 +0,0 @@
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Ensures the use of the `import type` operator from the `src/core/models/index.ts` file.',
category: 'Best Practices',
recommended: true,
},
fixable: 'code',
schema: [],
},
create: function (context) {
return {
ImportDeclaration: function (node) {
if (
node.source.parent.importKind !== 'type' &&
(node.source.value.endsWith('/models') || node.source.value === 'router-slot/model')
) {
const sourceCode = context.getSourceCode();
const nodeSource = sourceCode.getText(node);
context.report({
node,
message: 'Use `import type` instead of `import`.',
fix: (fixer) => fixer.replaceText(node, nodeSource.replace('import', 'import type')),
});
}
},
};
},
};

View File

@@ -1,43 +0,0 @@
const ALLOWED_PREFIXES = ['umb-', 'ufm-', 'test-', 'example-'];
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Enforce Custom Element names to start with "umb-".',
category: 'Naming',
recommended: true,
},
schema: [],
},
create: function (context) {
return {
CallExpression(node) {
// check if the expression is @customElement decorator
const isCustomElementDecorator =
node.callee.type === 'Identifier' &&
node.callee.name === 'customElement' &&
node.arguments.length === 1 &&
node.arguments[0].type === 'Literal' &&
typeof node.arguments[0].value === 'string';
if (isCustomElementDecorator) {
const elementName = node.arguments[0].value;
// check if the element name starts with an allowed prefix:
const isElementNameValid = ALLOWED_PREFIXES.some((prefix) => elementName.startsWith(prefix));
if (!isElementNameValid) {
context.report({
node,
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.
});
}
}
},
};
},
};

View File

@@ -1,54 +0,0 @@
/** @type {import('eslint').Rule.RuleModule}*/
module.exports = {
meta: {
type: 'problem',
docs: {
description:
'Ensure all exported string constants should be in uppercase with words separated by underscores and prefixed with UMB_',
},
schema: [
{
type: 'object',
properties: {
excludedFileNames: {
type: 'array',
items: {
type: 'string',
},
},
},
additionalProperties: false,
},
],
},
create: function (context) {
const excludedFileNames = context.options[0]?.excludedFileNames || [];
return {
ExportNamedDeclaration(node) {
const fileName = context.filename;
if (excludedFileNames.some((excludedFileName) => fileName.includes(excludedFileName))) {
// Skip the rule check for files in the excluded list
return;
}
if (node.declaration && node.declaration.type === 'VariableDeclaration') {
const declaration = node.declaration.declarations[0];
const { id, init } = declaration;
if (id && id.type === 'Identifier' && init && init.type === 'Literal' && typeof init.value === 'string') {
const isValidName = /^[A-Z]+(_[A-Z]+)*$/.test(id.name);
if (!isValidName || !id.name.startsWith('UMB_')) {
context.report({
node: id,
message:
'Exported string constant should be in uppercase with words separated by underscores and prefixed with UMB_',
});
}
}
}
},
};
},
};

View File

@@ -1,28 +0,0 @@
const ALLOWED_PREFIXES = ['Umb', 'Example'];
/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Ensure that all class declarations are prefixed with "Umb"',
category: 'Best Practices',
recommended: true,
},
schema: [],
},
create: function (context) {
function checkClassName(node) {
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 one of the following prefixes: ${ALLOWED_PREFIXES.join(', ')}`,
});
}
}
return {
ClassDeclaration: checkClassName,
};
},
};