Skip to content

Commit dfe39f6

Browse files
committed
resistor-color: avoid incorrect analysis for object-literal solutions
1 parent dd91584 commit dfe39f6

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/analyzers/practice/resistor-color/ResistorColorSolution.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,23 @@ class Entry {
300300
return false
301301
}
302302

303-
return this.isOptimalHelper(argument, constant)
303+
const result = this.isOptimalHelper(argument, constant)
304+
305+
if (
306+
!constant.isOptimalArray &&
307+
!constant.isOptimalObject() &&
308+
argument &&
309+
[
310+
AST_NODE_TYPES.MemberExpression,
311+
AST_NODE_TYPES.CallExpression,
312+
AST_NODE_TYPES.ObjectExpression,
313+
].includes(argument.type)
314+
) {
315+
return true
316+
}
317+
318+
return result
319+
304320
}
305321

306322
public isOptimalHelper(func: Node, constant: Readonly<Constant>): boolean {

0 commit comments

Comments
 (0)