Skip to content

Commit c0fda3f

Browse files
committed
Make Components.get ignore components with confidence = 0
Resolves #1637
1 parent 05d781b commit c0fda3f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/util/Components.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@ class Components {
7575
* Find a component in the list using its node
7676
*
7777
* @param {ASTNode} node The AST node being searched.
78-
* @returns {Object} Component object, undefined if the component is not found
78+
* @returns {Object} Component object, undefined if the component is not found or has confidence value of 0.
7979
*/
8080
get(node) {
8181
const id = getId(node);
82-
return this._list[id];
82+
if (this._list[id] && this._list[id].confidence >= 1) {
83+
return this._list[id];
84+
}
85+
return null;
8386
}
8487

8588
/**

tests/lib/rules/destructuring-assignment.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ ruleTester.run('destructuring-assignment', rule, {
134134
}
135135
};`,
136136
options: ['always']
137+
}, {
138+
code: [
139+
'const div = styled.div`',
140+
' & .button {',
141+
' border-radius: ${props => props.borderRadius}px;',
142+
' }',
143+
'`'
144+
].join('\n')
137145
}],
138146

139147
invalid: [{

0 commit comments

Comments
 (0)