website refactor

This commit is contained in:
2026-01-14 13:10:45 +01:00
parent 5451b5b0e9
commit e7887f054f
2 changed files with 51 additions and 9 deletions

View File

@@ -31,6 +31,7 @@ module.exports = {
let hasBuilderImport = false; let hasBuilderImport = false;
const builderUsages = []; const builderUsages = [];
const returnStatements = []; const returnStatements = [];
const builtVariables = new Set();
return { return {
// Check for builder imports // Check for builder imports
@@ -51,6 +52,42 @@ module.exports = {
} }
}, },
// Track variable assignments from builders
VariableDeclarator(node) {
if (node.init && node.init.type === 'CallExpression') {
const callee = node.init.callee;
if (callee.type === 'MemberExpression' &&
callee.property.type === 'Identifier' &&
callee.property.name === 'build') {
builtVariables.add(node.id.name);
}
}
},
// Track variable assignments from builders
VariableDeclarator(node) {
if (node.init && node.init.type === 'CallExpression') {
const callee = node.init.callee;
if (callee.type === 'MemberExpression' &&
callee.property.type === 'Identifier' &&
callee.property.name === 'build') {
builtVariables.add(node.id.name);
}
}
},
// Track variable assignments from builders
VariableDeclarator(node) {
if (node.init && node.init.type === 'CallExpression') {
const callee = node.init.callee;
if (callee.type === 'MemberExpression' &&
callee.property.type === 'Identifier' &&
callee.property.name === 'build') {
builtVariables.add(node.id.name);
}
}
},
// Track return statements // Track return statements
ReturnStatement(node) { ReturnStatement(node) {
if (node.argument) { if (node.argument) {
@@ -97,6 +134,10 @@ module.exports = {
// If it's an identifier, check if it's likely a DTO // If it's an identifier, check if it's likely a DTO
if (arg.type === 'Identifier') { if (arg.type === 'Identifier') {
const varName = arg.name; const varName = arg.name;
// Skip if it's a variable built from a builder
if (builtVariables.has(varName)) {
return;
}
// Common DTO patterns: result, data, dto, apiResult, etc. // Common DTO patterns: result, data, dto, apiResult, etc.
if (varName.match(/(result|data|dto|apiResult|response)/i)) { if (varName.match(/(result|data|dto|apiResult|response)/i)) {
context.report({ context.report({

View File

@@ -333,6 +333,7 @@ module.exports = {
NewExpression(node) { NewExpression(node) {
if (node.callee.type === 'Identifier' && if (node.callee.type === 'Identifier' &&
/^[A-Z]/.test(node.callee.name) && /^[A-Z]/.test(node.callee.name) &&
!node.callee.name.endsWith('PageQuery') &&
!isInComment(node)) { !isInComment(node)) {
context.report({ context.report({
node, node,