website refactor

This commit is contained in:
2026-01-12 16:06:14 +01:00
parent 7c54cba445
commit a735a51a11
2 changed files with 39 additions and 7 deletions

View File

@@ -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"
}
},
{

View File

@@ -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({