Skip to content

Commit

Permalink
Account for nested member expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzherdev committed Jul 20, 2018
1 parent 25e1976 commit fda7ea3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/jsx-props-no-multi-spaces.js
Expand Up @@ -33,7 +33,7 @@ module.exports = {
case 'JSXIdentifier':
return propNode.name;
case 'JSXMemberExpression':
return `${propNode.object.name}.${propNode.property.name}`;
return `${getPropName(propNode.object)}.${propNode.property.name}`;
default:
return propNode.name.name;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/jsx-props-no-multi-spaces.js
Expand Up @@ -60,6 +60,8 @@ ruleTester.run('jsx-props-no-multi-spaces', rule, {
].join('\n')
}, {
code: '<Foo.Bar baz="quux" />'
}, {
code: '<Foobar.Foo.Bar.Baz.Qux.Quux.Quuz.Corge.Grault.Garply.Waldo.Fred.Plugh xyzzy="thud" />'
}],

invalid: [{
Expand Down Expand Up @@ -114,5 +116,11 @@ ruleTester.run('jsx-props-no-multi-spaces', rule, {
errors: [
{message: 'Expected only one space between "Foo.Bar" and "baz"'}
]
}, {
code: '<Foobar.Foo.Bar.Baz.Qux.Quux.Quuz.Corge.Grault.Garply.Waldo.Fred.Plugh xyzzy="thud" />',
output: '<Foobar.Foo.Bar.Baz.Qux.Quux.Quuz.Corge.Grault.Garply.Waldo.Fred.Plugh xyzzy="thud" />',
errors: [
{message: 'Expected only one space between "Foobar.Foo.Bar.Baz.Qux.Quux.Quuz.Corge.Grault.Garply.Waldo.Fred.Plugh" and "xyzzy"'}
]
}]
});

0 comments on commit fda7ea3

Please sign in to comment.