integration tests
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
*
|
||||
* View Data Builders in lib/builders/view-data/ must:
|
||||
* 1. Be classes named *ViewDataBuilder
|
||||
* 2. Implement the ViewDataBuilder<TInput, TOutput> interface
|
||||
* 3. Have a static build() method
|
||||
* 2. Have a static build() method
|
||||
*
|
||||
* Note: 'implements' is deprecated in favor of 'satisfies' checked in view-data-builder-contract.js
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
@@ -19,7 +20,6 @@ module.exports = {
|
||||
schema: [],
|
||||
messages: {
|
||||
notAClass: 'View Data Builders must be classes named *ViewDataBuilder',
|
||||
missingImplements: 'View Data Builders must implement ViewDataBuilder<TInput, TOutput> interface',
|
||||
missingBuildMethod: 'View Data Builders must have a static build() method',
|
||||
},
|
||||
},
|
||||
@@ -30,7 +30,6 @@ module.exports = {
|
||||
|
||||
if (!isInViewDataBuilders) return {};
|
||||
|
||||
let hasImplements = false;
|
||||
let hasBuildMethod = false;
|
||||
|
||||
return {
|
||||
@@ -45,24 +44,6 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
// Check if class implements ViewDataBuilder interface
|
||||
if (node.implements && node.implements.length > 0) {
|
||||
for (const impl of node.implements) {
|
||||
// Handle GenericTypeAnnotation for ViewDataBuilder<TInput, TOutput>
|
||||
if (impl.expression.type === 'TSInstantiationExpression') {
|
||||
const expr = impl.expression.expression;
|
||||
if (expr.type === 'Identifier' && expr.name === 'ViewDataBuilder') {
|
||||
hasImplements = true;
|
||||
}
|
||||
} else if (impl.expression.type === 'Identifier') {
|
||||
// Handle simple ViewDataBuilder (without generics)
|
||||
if (impl.expression.name === 'ViewDataBuilder') {
|
||||
hasImplements = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for static build method
|
||||
const buildMethod = node.body.body.find(member =>
|
||||
member.type === 'MethodDefinition' &&
|
||||
@@ -77,13 +58,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
'Program:exit'() {
|
||||
if (!hasImplements) {
|
||||
context.report({
|
||||
node: context.getSourceCode().ast,
|
||||
messageId: 'missingImplements',
|
||||
});
|
||||
}
|
||||
|
||||
if (!hasBuildMethod) {
|
||||
context.report({
|
||||
node: context.getSourceCode().ast,
|
||||
|
||||
Reference in New Issue
Block a user