Skip to content

Commit 1f2918a

Browse files
waynzhFloEdelmann
andauthored
Update lib/rules/define-props-destructuring.js
Co-authored-by: Flo Edelmann <[email protected]>
1 parent 72f5898 commit 1f2918a

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lib/rules/define-props-destructuring.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,29 @@ module.exports = {
4848
const hasDestructure = utils.isUsingPropsDestructure(node)
4949
const hasWithDefaults = utils.hasWithDefaults(node)
5050

51-
if (destructurePreference === 'always') {
52-
if (!hasDestructure) {
53-
context.report({
54-
node,
55-
messageId: 'preferDestructuring'
56-
})
57-
return
58-
}
59-
60-
if (hasWithDefaults) {
61-
context.report({
62-
node: node.parent.callee,
63-
messageId: 'avoidWithDefaults'
64-
})
65-
}
66-
} else {
51+
if (destructurePreference === 'never') {
6752
if (hasDestructure) {
6853
context.report({
6954
node,
7055
messageId: 'avoidDestructuring'
7156
})
7257
}
58+
return
59+
}
60+
61+
if (!hasDestructure) {
62+
context.report({
63+
node,
64+
messageId: 'preferDestructuring'
65+
})
66+
return
67+
}
68+
69+
if (hasWithDefaults) {
70+
context.report({
71+
node: node.parent.callee,
72+
messageId: 'avoidWithDefaults'
73+
})
7374
}
7475
}
7576
})

0 commit comments

Comments
 (0)