Skip to content
This repository was archived by the owner on Sep 18, 2023. It is now read-only.

Allow logical expression in if statement #43

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

koddsson
Copy link
Contributor

Consider these two code-snippets:

if (window && !window.customElements.get("foo-bar")) { window.customElements.define("foo-bar", class extends HTMLElement {}) }
if (window && window.customElements.get("foo-bar")) { window.customElements.define("foo-bar", class extends HTMLElement {}) }

In both cases, the if statement has the type LogicalExpression, which we weren't checking for in our lint rule. Additionally, in the former snippet, the customElements.get call is a UnaryExpression and gets handled by our existing code. Still, the parent is just a LogicalExpression in the second snippet. So we make sure to not register the element if its parent is a LogicalExpression.

@koddsson koddsson requested review from a team, theinterned and keithamus March 21, 2022 12:02
@koddsson koddsson merged commit 1da2c6c into main Mar 22, 2022
@koddsson koddsson deleted the allow-logical-expression-in-if-statement branch March 22, 2022 08:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants