Skip to content

vue-sfc ​

A Vue component the checker can't see into: a <script> without lang="ts", or a component without <script setup> written with the Options API (data(), methods). A defineComponent({ setup() { ... } }) is plain code the rules can follow, and isn't reported.

Why: without lang="ts" there are no types, so nothing the rules rely on is checked. In the Options API, state lives in data(), methods in methods and everything is reached through this: an object Vue puts together at runtime. The rules follow variables and functions, so in such a component they see almost nothing. <script setup lang="ts"> is plain code they can follow. Guide: Vue.

✕ Rejectedvue-sfc
vue
<script lang="ts">
export default {
  data() {
    return { count: 0 };
  },
  methods: {
    increment(): void {
      this.count++;
    },
  },
};
</script>

<template>
  <button @click="increment">{{ count }}</button>
</template>
✓ Accepted0 diagnostics
vue
<script setup lang="ts">
import { ref } from "vue";

const count = ref(0);
</script>

<template>
  <button @click="count++">{{ count }}</button>
</template>

A <script lang="ts"> next to <script setup> is fine, for example for types the module exports. Remember that it runs once for every instance together: state there is shared (no-mutable-global applies to it).

It also reports a @safe-ts legacy marker that marks nothing. A component is legacy when the marker is in the first lines of either <script> block (<script> or <script setup>), or in an HTML comment outside the blocks (<!-- @safe-ts legacy --> at the top of the file); a marker further down a script, or inside the template, is reported instead of being ignored.

What the rule can't see: a template in another language (<template lang="pug">) is not read at all, and is not reported either.

MIT OR Apache-2.0 · Docs by Gemini 4 Neon Extra