eslint-plugin-lit
eslint-plugin-lit copied to clipboard
Add rule to disallow of side-effects inside the `render` method
Potential Rule Name: no-render-side-effects
Disallows the use of "side-effects" inside the render
method.
@bennypowers shows a simple case in this tweet: https://twitter.com/PowersBenny/status/1387330749217611776
This could a bit trickier of a rule to implement but would be a good rule to have.
indeed, could be tricky to check for any side effects. could we start with a no-this-assign-in-render
or only-local-assign-in-render
or something?
indeed, could be tricky to check for any side effects. could we start with a
no-this-assign-in-render
oronly-local-assign-in-render
or something?
Yeah, I was thinking along the same lines. Perhaps, also, adding a check for conditional assignments inside the render? I'm unsure what all we would want to consider warnings in a first round pass
given the nature of the problem we might want to take a narrow approach:
local assignments in render are fine
any other assignments, be they to this
, window
, or higher-scoped variables, are forbidden.
docs link to reasoning, users can turn the rule off if they want
later iterations might add acceptable cases or ignore regexp if there's demand