Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/util/Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ class Components {
* Find a component in the list using its node
*
* @param {ASTNode} node The AST node being searched.
* @returns {Object} Component object, undefined if the component is not found
* @returns {Object} Component object, undefined if the component is not found or has confidence value of 0.
*/
get(node) {
const id = getId(node);
return this._list[id];
if (this._list[id] && this._list[id].confidence >= 1) {
return this._list[id];
}
return null;
}

/**
Expand Down
31 changes: 31 additions & 0 deletions tests/lib/rules/destructuring-assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,37 @@ ruleTester.run('destructuring-assignment', rule, {
}
};`,
options: ['always']
}, {
code: [
'const div = styled.div`',
' & .button {',
' border-radius: ${props => props.borderRadius}px;',
' }',
'`'
].join('\n')
}, {
code: `
export default (context: $Context) => ({
foo: context.bar
});
`,
parser: 'babel-eslint'
}, {
code: `
class Foo {
bar(context) {
return context.baz;
}
}
`
}, {
code: `
class Foo {
bar(props) {
return props.baz;
}
}
`
}],

invalid: [{
Expand Down