website refactor
This commit is contained in:
@@ -275,7 +275,16 @@ module.exports = {
|
||||
create(context) {
|
||||
return {
|
||||
FunctionDeclaration(node) {
|
||||
if (!node.id.name.startsWith('assert') &&
|
||||
// Skip if this is the main component (default export or ends with Page/Template)
|
||||
const filename = context.getFilename();
|
||||
const isMainComponent =
|
||||
(node.parent && node.parent.type === 'ExportDefaultDeclaration') ||
|
||||
(node.id && node.id.name && (node.id.name.endsWith('Page') || node.id.name.endsWith('Template') || node.id.name.endsWith('Component')));
|
||||
|
||||
if (isMainComponent) return;
|
||||
|
||||
// Only flag nested helper functions
|
||||
if (!node.id.name.startsWith('assert') &&
|
||||
!node.id.name.startsWith('invariant') &&
|
||||
!isInComment(node)) {
|
||||
context.report({
|
||||
@@ -285,9 +294,16 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
VariableDeclarator(node) {
|
||||
if (node.init &&
|
||||
// Skip if this is the main component
|
||||
const isMainComponent =
|
||||
(node.parent && node.parent.parent && node.parent.parent.type === 'ExportDefaultDeclaration') ||
|
||||
(node.id && node.id.name && (node.id.name.endsWith('Page') || node.id.name.endsWith('Template') || node.id.name.endsWith('Component')));
|
||||
|
||||
if (isMainComponent) return;
|
||||
|
||||
if (node.init &&
|
||||
(node.init.type === 'FunctionExpression' || node.init.type === 'ArrowFunctionExpression') &&
|
||||
!node.id.name.startsWith('assert') &&
|
||||
!node.id.name.startsWith('assert') &&
|
||||
!node.id.name.startsWith('invariant') &&
|
||||
!isInComment(node)) {
|
||||
context.report({
|
||||
|
||||
Reference in New Issue
Block a user