ai-deslop 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -100,8 +100,11 @@ function canonicalDeclaration(node) {
|
|
|
100
100
|
for (const [index, parameter] of (node.typeParameters?.params ?? []).entries()) {
|
|
101
101
|
parameters.set(parameter.name.name, `$${index}`);
|
|
102
102
|
}
|
|
103
|
-
if (node.type === "TSTypeAliasDeclaration")
|
|
104
|
-
|
|
103
|
+
if (node.type === "TSTypeAliasDeclaration") {
|
|
104
|
+
if (node.typeAnnotation.type !== "TSTypeLiteral")
|
|
105
|
+
return null;
|
|
106
|
+
return canonicalMembers(node.typeAnnotation.members, parameters);
|
|
107
|
+
}
|
|
105
108
|
if (node.extends.length > 0)
|
|
106
109
|
return null;
|
|
107
110
|
return canonicalMembers(node.body.body, parameters);
|
|
@@ -126,10 +129,18 @@ export const noDuplicateTypesRule = defineRule({
|
|
|
126
129
|
context.report({ node, messageId: "duplicate", data: { message: options.message ?? "This type is structurally identical to an existing declaration.", firstName: first.name, firstFile: first.filename } });
|
|
127
130
|
};
|
|
128
131
|
const inspect = (node) => {
|
|
132
|
+
let properties;
|
|
133
|
+
if (node.type === "TSTypeAliasDeclaration") {
|
|
134
|
+
if (node.typeAnnotation.type !== "TSTypeLiteral")
|
|
135
|
+
return;
|
|
136
|
+
properties = node.typeAnnotation.members.length;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
properties = node.body.body.length;
|
|
140
|
+
}
|
|
129
141
|
const fingerprint = canonicalDeclaration(node);
|
|
130
142
|
if (fingerprint === null)
|
|
131
143
|
return;
|
|
132
|
-
const properties = node.type === "TSTypeAliasDeclaration" && node.typeAnnotation.type === "TSTypeLiteral" ? node.typeAnnotation.members.length : node.type === "TSInterfaceDeclaration" ? node.body.body.length : Infinity;
|
|
133
144
|
if (properties < (options.minProperties ?? 2))
|
|
134
145
|
return;
|
|
135
146
|
report(node, fingerprint);
|