Skip to content

Commit 08aace5

Browse files
authored
fix: false positives for read property in svelte/no-dom-manipulating (#383)
1 parent 830807c commit 08aace5

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

.changeset/grumpy-gifts-repeat.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-svelte": patch
3+
---
4+
5+
fix: false positives for read property in `svelte/no-dom-manipulating`

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)