eslint-plugin-react icon indicating copy to clipboard operation
eslint-plugin-react copied to clipboard

Possible jsx-no-allocation-in-props rule

Open alexzherdev opened this issue 6 years ago • 11 comments

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?

alexzherdev avatar Jul 19 '18 03:07 alexzherdev

Oh yeah, a new rule (if we go that way) would have a different name.

alexzherdev avatar Jul 20 '18 02:07 alexzherdev

Removed jsx prefix, added createElement support and controls for arrays/objects

alexzherdev avatar Jul 22 '18 03:07 alexzherdev

I don't think "allocations" is the best word to use in a memory-managed language, where allocations aren't user-observable.

ljharb avatar Jul 22 '18 05:07 ljharb

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 😄

alexzherdev avatar Jul 22 '18 05:07 alexzherdev

I see this was updated recently. Any chance it'll ship anytime soon? Would love to see this one live!

benasher44 avatar Jan 27 '23 04:01 benasher44

@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 avatar Jan 27 '23 05:01 ljharb

@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?

benasher44 avatar Mar 05 '23 17:03 benasher44

Ah wait I think I figured that out. Hold please!

benasher44 avatar Mar 05 '23 17:03 benasher44

Sweet okay pushed again. Tests pass now!

benasher44 avatar Mar 05 '23 17:03 benasher44

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)

benasher44 avatar Mar 05 '23 17:03 benasher44

@ljharb just checking in — happy to do the work if more is needed!

benasher44 avatar Mar 15 '23 14:03 benasher44