Unused variables are not reported

In VSCode, unused variables in the top-level of the setup function are not reported.

but in function,it will

it is a bug?

Hello,

I’ve moved your post to the section dedicated to reporting false-positives and false-negatives:

Could you please share code snippets in text format? Screenshots are difficult to work with.

Thank you!

<template>

  <div class=""></div>

</template>

<script setup lang="ts">

let res = 123;

const result = await Promise.resolve(() => {

  return 123;

});

function test() {

  let aaa = 123;

  return 123;

}

</script>

<style></style>

Here is the complete code, thank you for your work.

Hello @shanyi-front,

is this in a file with .html extension?

.vue extension

Hi @shanyi-front,

indeed, this is a bug. Seems the root scope of the script body is not properly handled in that rule. I created a ticket to fix it.

Thanks for reporting!
Victor