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
koddsson merged 2 commits into
mainfrom
allow-logical-expression-in-if-statement
Mar 22, 2022
Merged

Allow logical expression in if statement#43
koddsson merged 2 commits into
mainfrom
allow-logical-expression-in-if-statement

Conversation

@koddsson

Copy link
Copy Markdown
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, keithamus and theinterned 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