/** * ESLint rule: Components must not manipulate data */ module.exports = { meta: { type: 'problem', docs: { description: 'Forbid data manipulation in components', category: 'Components', }, messages: { message: 'Components must not manipulate data - see apps/website/lib/contracts/view-data/ViewData.ts', }, }, create(context) { return { CallExpression(node) { const filename = context.getFilename(); if (filename.includes('/components/')) { // Check for mutation methods if (node.callee.type === 'MemberExpression') { const property = node.callee.property; if (property.type === 'Identifier' && ['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse', 'assign'].includes(property.name)) { context.report({ node, messageId: 'message', }); } } } }, }; }, };