Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Components.get ignore components with confidence = 0 #1907

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/util/Components.js
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
8 changes: 8 additions & 0 deletions tests/lib/rules/destructuring-assignment.js
Expand Up @@ -134,6 +134,14 @@ ruleTester.run('destructuring-assignment', rule, {
}
};`,
options: ['always']
}, {
code: [
'const div = styled.div`',
' & .button {',
' border-radius: ${props => props.borderRadius}px;',
' }',
'`'
].join('\n')
}],

invalid: [{
Expand Down