website refactor
This commit is contained in:
@@ -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"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user