From a735a51a11b471d32f301d5a84617a43d4b45ee5 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Mon, 12 Jan 2026 16:06:14 +0100 Subject: [PATCH] website refactor --- apps/website/.eslintrc.json | 14 ++++++-- .../website/eslint-rules/client-only-rules.js | 32 ++++++++++++++++--- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/apps/website/.eslintrc.json b/apps/website/.eslintrc.json index 11965d388..02c1055cf 100644 --- a/apps/website/.eslintrc.json +++ b/apps/website/.eslintrc.json @@ -34,12 +34,13 @@ ], "rules": { "gridpilot-rules/presenter-contract": "error", + "gridpilot-rules/presenter-purity": "error", "gridpilot-rules/filename-presenter-match": "error" } }, { "files": [ - "app/**/*.tsx" + "templates/**/*.tsx" ], "rules": { "gridpilot-rules/template-no-direct-mutations": "error", @@ -48,7 +49,16 @@ "gridpilot-rules/template-no-external-state": "error", "gridpilot-rules/template-no-global-objects": "error", "gridpilot-rules/template-no-mutation-props": "error", - "gridpilot-rules/template-no-unsafe-html": "error" + "gridpilot-rules/template-no-unsafe-html": "error", + "gridpilot-rules/component-no-data-manipulation": "error" + } + }, + { + "files": [ + "components/**/*.tsx" + ], + "rules": { + "gridpilot-rules/component-no-data-manipulation": "error" } }, { diff --git a/apps/website/eslint-rules/client-only-rules.js b/apps/website/eslint-rules/client-only-rules.js index d3e000659..1fe438503 100644 --- a/apps/website/eslint-rules/client-only-rules.js +++ b/apps/website/eslint-rules/client-only-rules.js @@ -68,17 +68,39 @@ module.exports = { return { Program(node) { const filename = context.getFilename(); - if (filename.includes('/app/') && + if (filename.includes('/app/') && filename.endsWith('.tsx') && !filename.endsWith('page.tsx') && !filename.endsWith('layout.tsx')) { const sourceCode = context.getSourceCode(); - const firstComment = sourceCode.getAllComments()[0]; - const hasDirective = firstComment && - firstComment.type === 'Line' && - firstComment.value.trim() === '"use client"'; + // Check for 'use client' as a string literal directive + // This can be either a comment or a string literal statement + const comments = sourceCode.getAllComments(); + const firstComment = comments[0]; + + let hasDirective = false; + + // Check if it's a comment + if (firstComment && + firstComment.type === 'Line' && + (firstComment.value.trim() === '"use client"' || + firstComment.value.trim() === 'use client')) { + hasDirective = true; + } + + // Check if it's a string literal statement (the actual Next.js way) + if (!hasDirective && node.body.length > 0) { + const firstStmt = node.body[0]; + if (firstStmt && + firstStmt.type === 'ExpressionStatement' && + firstStmt.expression.type === 'Literal' && + (firstStmt.expression.value === 'use client' || + firstStmt.expression.value === '"use client"')) { + hasDirective = true; + } + } if (!hasDirective) { context.report({