You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<button on:click={() => toggle()}>Click Me (Good)</button>
42
47
<button on:click={() => remove()}>Click Me (Bad)</button>
48
+
<button on:click={() => update()}>Click Me (Bad)</button>
43
49
```
44
50
45
51
</ESLintCodeBlock>
46
52
53
+
This rule only tracks and checks variables given with `bind:this={}`. In other words, it doesn't track things like function arguments given to `transition:` directives. These functions have been well tested and are often used more carefully.
54
+
55
+
<ESLintCodeBlock>
56
+
57
+
<!--eslint-skip-->
58
+
59
+
```svelte
60
+
<script>
61
+
/* eslint svelte/no-dom-manipulating: "error" */
62
+
let visible = false
63
+
64
+
function typewriter(node, { speed = 1 }) {
65
+
const valid =
66
+
node.childNodes.length === 1 &&
67
+
node.childNodes[0].nodeType === Node.TEXT_NODE
68
+
69
+
if (!valid) {
70
+
throw new Error(
71
+
`This transition only works on elements with a single text node child`,
72
+
)
73
+
}
74
+
75
+
const text = node.textContent
76
+
const duration = text.length / (speed * 0.01)
77
+
78
+
return {
79
+
duration,
80
+
tick: (t) => {
81
+
const i = Math.trunc(text.length * t)
82
+
node.textContent = text.slice(0, i) // It does not report.
83
+
},
84
+
}
85
+
}
86
+
</script>
87
+
88
+
<label>
89
+
<input type="checkbox" bind:checked={visible} />
90
+
visible
91
+
</label>
92
+
93
+
{#if visible}
94
+
<p transition:typewriter>The quick brown fox jumps over the lazy dog</p>
95
+
{/if}
96
+
```
97
+
98
+
</ESLintCodeBlock>
99
+
100
+
See also <https://svelte.jp/examples/custom-js-transitions>.
0 commit comments