/**
 * ESLint rule: Presenter filename must match class name
 */

module.exports = {
  meta: {
    type: 'problem',
    docs: {
      description: 'Enforce presenter filename matches class name',
      category: 'Filename',
    },
    messages: {
      message: 'Presenter filename must match class name (e.g., FooPresenter.ts contains class FooPresenter) - see apps/website/lib/contracts/presenters/Presenter.ts',
    },
  },
  create(context) {
    return {
      ClassDeclaration(node) {
        const filename = context.getFilename();
        if (filename.includes('/lib/presenters/') && filename.endsWith('.ts')) {
          const expectedClassName = filename.split('/').pop().replace('.ts', '');
          const actualClassName = node.id?.name;
          
          if (actualClassName && actualClassName !== expectedClassName) {
            context.report({
              node,
              messageId: 'message',
            });
          }
        }
      },
    };
  },
};