Skip to content

linters/eslint-rules/require-component-suffix

ESLint rule: require-component-suffix

Reports an error when a class that extends Component (from Obsidian, directly or transitively) does not have a name ending with Component (or ComponentBase for abstract base classes).

Classes whose inheritance chain includes any of the Obsidian framework classes that extend Component (e.g. Plugin, View, MarkdownRenderChild, Menu, HoverPopover, QueryController) are excluded because they follow Obsidian’s own naming conventions.

The rule uses the TypeScript type checker to walk the full inheritance chain, so it works regardless of how many intermediate classes sit between the user’s class and Component.

Variable Description
MESSAGE_ID_ABSTRACT_NEEDS_BASE Message ID reported when an abstract class extends Component but its name does not end with ComponentBase.
MESSAGE_ID_BASE_NOT_ABSTRACT Message ID reported when a class name ends with ComponentBase but the class is not abstract.
MESSAGE_ID_MISSING_SUFFIX Message ID reported when a class extends Component but its name does not end with Component.
requireComponentSuffix ESLint rule requiring classes that extend Component to be named with a Component suffix, and abstract ones with a ComponentBase suffix.