Files
gridpilot.gg/apps/website/eslint-rules/test-rule-debug.js
2026-01-13 02:38:49 +01:00

63 lines
1.5 KiB
JavaScript

/**
* Debug test for page-query-must-use-builders rule
*/
const rule = require('./page-query-must-use-builders.js');
// Simulate the AST traversal with logging
const mockContext = {
getSourceCode: () => ({ ast: {} }),
report: (data) => {
console.log('✓ REPORT TRIGGERED:', data.messageId);
}
};
const visitor = rule.create(mockContext);
console.log('=== Starting Debug Test ===\n');
// 1. ClassDeclaration
console.log('1. ClassDeclaration: AdminDashboardPageQuery');
visitor.ClassDeclaration({
id: { name: 'AdminDashboardPageQuery' }
});
// 2. MethodDefinition (execute)
console.log('2. MethodDefinition: execute()');
visitor.MethodDefinition({
key: { type: 'Identifier', name: 'execute' },
parent: { type: 'ClassBody' }
});
// 3. VariableDeclarator
console.log('3. VariableDeclarator: const apiDto = ...');
visitor.VariableDeclarator({
init: { type: 'CallExpression' }
});
// 4. ReturnStatement
console.log('4. ReturnStatement: return Result.ok(apiDto)');
visitor.ReturnStatement({
argument: {
type: 'CallExpression',
callee: {
type: 'MemberExpression',
object: { type: 'Identifier', name: 'Result' },
property: { type: 'Identifier', name: 'ok' }
},
arguments: [{ type: 'Identifier', name: 'apiDto' }]
}
});
// 5. MethodDefinition:exit
console.log('5. MethodDefinition:exit');
visitor['MethodDefinition:exit']({
key: { type: 'Identifier', name: 'execute' }
});
// 6. Program:exit
console.log('6. Program:exit');
visitor['Program:exit']();
console.log('\n=== Test Complete ===');