eslint-plugin-react
eslint-plugin-react copied to clipboard
Possible jsx-no-allocation-in-props rule
cc @ljharb
So... now that I know what future prospects are for jsx-no-bind
(https://github.com/yannickcr/eslint-plugin-react/issues/1633#issuecomment-402611450) I actually have doubts that it makes sense to add this new rule on its own. The code here is basically the same as jsx-no-bind
. Perhaps we could instead just update that rule to handle object creation. Thoughts?
Oh yeah, a new rule (if we go that way) would have a different name.
Removed jsx
prefix, added createElement
support and controls for arrays/objects
I don't think "allocations" is the best word to use in a memory-managed language, where allocations aren't user-observable.
Oh, for sure, this name leaves much to be desired. I guess this is more no-object-or-array-literals-in-props
but that's quite a mouthful 😐 Although not really more than no-redundant-should-component-update
😄
I see this was updated recently. Any chance it'll ship anytime soon? Would love to see this one live!
@benasher44 it hasn't been updated since 2018; those 4 force pushes are to master, not this PR.
If you'd like to help, please comment a link to an updated branch (NOT a new PR) and i can update this one :-)
@ljharb just pushed to no-allocation-in-props in benasher44/eslint-plugin-react. Only thing I'm having trouble with right now is this error running the test locally:
AssertionError [ERR_ASSERTION]: Parsers provided as strings to RuleTester must be absolute paths
I get this error running other tests locally though too, so I think I'm just missing some configuration in my local env/setup. Any idea what it might be?
Ah wait I think I figured that out. Hold please!
Sweet okay pushed again. Tests pass now!
Looks like last thing being discussed was naming. Are we good with no-object-or-array-literals-in-props
? (my branch still has previous "allocation" naming)
@ljharb just checking in — happy to do the work if more is needed!