-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
[#73] Account for SpreadElement AST Nodes #76
Conversation
it('should evaluate to a correct representation of an array with spread elements', () => { | ||
const prop = extractProp('<div foo={[...this.props.params, bar]} />'); | ||
|
||
const expected = [undefined, 'bar']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there no way to represent this.props.params
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb I honestly can't think of one. The values of the array would be spread in, or no values would be spread in at all. I have to return something that can be evaluated in code. An empty array doesn't make sense, since spreading values into an array wouldn't produce an array (it would produce more values in the containing array). The best I could come up with is undefined
. I'm up for alternatives if you have them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering if maybe a special object indicating what was spread; that way a props-related rule could know that the "params" prop was used here (thinking of how this can be used in eslint-plugin-react)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb I don't think we'll need it in the eslint-plugin-jsx-a11y project. Once we encounter a spread, we can't statically analyze any further.
[jsx-eslint#73] Account for SpreadElement AST Nodes [jsx-eslint#70] Support OptionalMemberExpression AST nodes
Account for array
SpreadElement
nodes.