Files
gridpilot.gg/apps/website/eslint-rules/presenter-contract.js
2026-01-13 00:16:14 +01:00

51 lines
1.3 KiB
JavaScript

/**
* ESLint rule to enforce that Presenters are NOT used
*
* Presenters are deprecated and replaced with Builders.
* This rule flags any file ending with "Presenter" as an error.
*/
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Prevent use of deprecated Presenter pattern',
category: 'Best Practices',
recommended: true,
},
fixable: null,
schema: [],
messages: {
presenterDeprecated: 'Presenters are deprecated. Use Builder pattern instead. See apps/website/lib/contracts/builders/Builder.ts',
},
},
create(context) {
return {
// Check for any file ending with "Presenter"
Program(node) {
const filename = context.getFilename();
// Check if filename ends with Presenter.ts or Presenter.tsx
if (filename.endsWith('Presenter.ts') || filename.endsWith('Presenter.tsx')) {
context.report({
node,
messageId: 'presenterDeprecated',
});
}
},
// Also check class declarations ending with Presenter
ClassDeclaration(node) {
const className = node.id?.name;
if (className && className.endsWith('Presenter')) {
context.report({
node,
messageId: 'presenterDeprecated',
});
}
},
};
},
};