Skip to content

Commit 296add9

Browse files
committed
fix: false positives for read property in svelte/no-dom-manipulating
1 parent 830807c commit 296add9

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/rules/no-dom-manipulating.ts

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export default createRule("no-dom-manipulating", {
7878
if (parent.left !== target || !DOM_MANIPULATING_PROPERTIES.has(name)) {
7979
return
8080
}
81+
} else {
82+
return
8183
}
8284
context.report({
8385
node: member,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script>
2+
let divElement
3+
let height = ""
4+
5+
$: if (divElement) height = `${divElement.clientHeight}px`
6+
</script>
7+
8+
<div bind:this={divElement} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script>
2+
let divElement
3+
let foo = ""
4+
5+
$: if (divElement) foo = `${divElement.data.foo}`
6+
</script>
7+
8+
<div bind:this={divElement} data-foo="Foo" />

0 commit comments

Comments
 (0)