Skip to content

Commit 0ea8000

Browse files
committed
Fix failing tests
1 parent 844d483 commit 0ea8000

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

lib/rules/button-has-type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ module.exports = {
151151

152152
const props = node.arguments[1].properties;
153153
const typeProp = props.find(
154-
(prop) => prop.type === 'Property' && prop.key && prop.key.type === 'PrivateIdentifier' && prop.key.name === 'type'
154+
(prop) => prop.type === 'Property' && prop.key && prop.key.type === 'Identifier' && prop.key.name === 'type'
155155
);
156156

157157
if (typeProp.type !== 'Property') {

lib/rules/no-access-state-in-setstate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module.exports = {
102102

103103
MemberExpression(node) {
104104
if (
105-
node.property.type === 'PrivateIdentifier'
105+
node.property.type === 'Identifier'
106106
&& node.property.name === 'state'
107107
&& node.object.type === 'ThisExpression'
108108
&& isClassComponent()
@@ -188,7 +188,7 @@ module.exports = {
188188
ObjectPattern(node) {
189189
const isDerivedFromThis = (node.parent.type === 'ForStatement' || node.parent.type === 'VariableDeclarator') && node.parent.init && node.parent.init.type === 'ThisExpression';
190190
node.properties.forEach((property) => {
191-
if (property.type === 'Property' && (property.key.type === 'PrivateIdentifier' || property.key.type === 'Identifier') && property.key.name === 'state' && isDerivedFromThis) {
191+
if (property.type === 'Property' && property.key.type === 'Identifier' && property.key.name === 'state' && isDerivedFromThis) {
192192
vars.push({
193193
node: property.key,
194194
scope: context.getScope(),

lib/rules/no-children-prop.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ module.exports = {
8989

9090
const props = node.arguments[1].properties;
9191
const childrenProp = props.find(
92-
(prop) => prop.type === 'Property' && (prop.key.type === 'PrivateIdentifier' || prop.key.type === 'Identifier') && prop.key.name === 'children'
92+
(prop) => prop.type === 'Property' && prop.key.type === 'Identifier' && prop.key.name === 'children'
9393
);
9494

95-
if (childrenProp.type === 'Property') {
95+
if (childrenProp && childrenProp.type === 'Property') {
9696
if (childrenProp.value && !isFunction(childrenProp.value)) {
9797
report(context, messages.passChildrenAsArgs, 'passChildrenAsArgs', {
9898
node,

lib/rules/sort-default-props.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ module.exports = {
164164
},
165165

166166
MemberExpression(node) {
167-
if (!isDefaultPropsDeclaration(node) || node.parent.type !== 'BinaryExpression') {
167+
if (
168+
!isDefaultPropsDeclaration(node)
169+
|| (node.parent.type !== 'BinaryExpression' && node.parent.type !== 'AssignmentExpression' && node.parent.type !== 'LogicalExpression' && node.parent.type !== 'AssignmentPattern')) {
168170
return;
169171
}
170172

lib/rules/style-prop-object.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@ module.exports = {
9292
}
9393
}
9494
if (node.arguments[1].type === 'ObjectExpression') {
95-
const style = node.arguments[1].properties.find((property) => property.type === 'Property' && property.key.type === 'Identifier' && property.key.name === 'style' && !property.computed);
96-
if (style.type !== 'Property') {
97-
return;
98-
}
99-
if (style) {
95+
const style = node.arguments[1].properties.find(
96+
(property) => property.type === 'Property' && property.key.type === 'Identifier' && property.key.name === 'style' && !property.computed
97+
);
98+
if (style && style.type === 'Property') {
10099
if (style.value.type === 'Identifier') {
101100
checkIdentifiers(style.value);
102101
} else if (isNonNullaryLiteral(style.value)) {

0 commit comments

Comments
 (0)