-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Allow this
in property and call descendants in render
assignments
#213
Allow this
in property and call descendants in render
assignments
#213
Conversation
ThisExpression
on render left-hand side
ThisExpression
on render left-hand sideThisExpression
property descendants on render left-hand side
ThisExpression
property descendants on render left-hand sideThisExpression
property descendants on render left-hand side
ThisExpression
property descendants on render left-hand sidethis
in property and call descendants in render
assignments
Are you trying to catch these two cases? this.foo.bar = 123;
fn(this).bar = 123; I feel like the pattern will be too specific right now. It'll probably be easier to maintain if we keep the same pattern but update the rule logic Also, both of these mean you're mutating something in your render method, which is what this rule is meant to prevent Could you give a real world example of why someone might need this? |
From our recent lock file update to get these changes (which because of the better Lit element detection in the latest release is now finally applying these rules to some of our elements): This failed: render() {
const secondaryPanelStyles = {};
if (this._isResizable()) {
secondaryPanelStyles[this._isMobile ? 'height' : 'width'] = `${size}px`;
}
} And had to become: render() {
const secondaryPanelStyles = {};
if (this._isResizable()) {
const dimension = this._isMobile ? 'height' : 'width';
secondaryPanelStyles[dimension] = `${size}px`;
}
} So no mutation of anything on "this" in the render. |
@dlockhart laid out our real world example of the
This mutates something but it doesn't mutate I'm not terribly familiar with eslint plugins but I can take a stab at converting my selector changes to rule logic, though I would think it's pretty stable as it seems like these are the only two ways you can get a |
b3b8f93
to
7d80d74
Compare
Closing in favor of #214 |
A
ThisExpression
that is the descendant of a property or call within an assignment should not triggerassignmentFound