add eslint to to ensure umb prefix on classes
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
"local-rules/enforce-element-suffix-on-element-class-name": "error",
|
||||
"local-rules/prefer-umbraco-cms-imports": "error",
|
||||
"local-rules/no-external-imports": "error",
|
||||
"local-rules/umb-class-prefix": "error",
|
||||
"@typescript-eslint/no-non-null-assertion": "off"
|
||||
},
|
||||
"settings": {
|
||||
|
||||
@@ -205,4 +205,31 @@ module.exports = {
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/** @type {import('eslint').Rule.RuleModule} */
|
||||
'umb-class-prefix': {
|
||||
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 && !node.id.name.startsWith('Umb')) {
|
||||
context.report({
|
||||
node: node.id,
|
||||
message: 'Class declaration should be prefixed with "Umb"',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ClassDeclaration: checkClassName,
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user