website refactor
This commit is contained in:
@@ -159,8 +159,12 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const hasUseClient = sourceCode.getText().includes("'use client'") || sourceCode.getText().includes('"use client"');
|
||||
|
||||
return {
|
||||
CallExpression(node) {
|
||||
if (hasUseClient) return;
|
||||
if (node.callee.type === 'MemberExpression' &&
|
||||
['sort', 'filter', 'reduce'].includes(node.callee.property.name) &&
|
||||
!isInComment(node) &&
|
||||
@@ -273,8 +277,12 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const hasUseClient = sourceCode.getText().includes("'use client'") || sourceCode.getText().includes('"use client"');
|
||||
|
||||
return {
|
||||
FunctionDeclaration(node) {
|
||||
if (hasUseClient) return;
|
||||
// Skip if this is the main component (default export or ends with Page/Template)
|
||||
const filename = context.getFilename();
|
||||
const isMainComponent =
|
||||
@@ -294,6 +302,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
VariableDeclarator(node) {
|
||||
if (hasUseClient) return;
|
||||
// Skip if this is the main component
|
||||
const isMainComponent =
|
||||
(node.parent && node.parent.parent && node.parent.parent.type === 'ExportDefaultDeclaration') ||
|
||||
@@ -329,8 +338,12 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const hasUseClient = sourceCode.getText().includes("'use client'") || sourceCode.getText().includes('"use client"');
|
||||
|
||||
return {
|
||||
NewExpression(node) {
|
||||
if (hasUseClient) return;
|
||||
if (node.callee.type === 'Identifier' &&
|
||||
/^[A-Z]/.test(node.callee.name) &&
|
||||
!node.callee.name.endsWith('PageQuery') &&
|
||||
|
||||
Reference in New Issue
Block a user