Skip to content

Commit 361c26f

Browse files
authored
fix no-unused-vars for variables assigned to in template but only used in script
Fixes #64
1 parent 654cc7f commit 361c26f

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/preprocess.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ export const preprocess = text => {
150150
}
151151
},
152152
});
153+
154+
block.transformed_code += `{${vars.filter(v => v.referenced_from_script).map(v => v.name)}}`;
153155
}
154156

155157
// return processed string
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
rules: {
3+
'no-unused-vars': 'error',
4+
},
5+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script>
2+
let foo = false;
3+
setInterval(() => {
4+
console.log(foo);
5+
}, 1000);
6+
</script>
7+
8+
<div on:click={() => foo = true}>foo</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)