Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

509
Views
Getting an ESLint no-unused-vars error for all data defined in an vue3 SFC file (using the composition API & TS) which has an imported template file

I have a number of .vue SFC files that are using the <script setup> syntax.

Here's a simplified example of what I mean:

Person.vue

<script setup lang="ts">
import { ref } from "vue";
const person = ref(0);
</script>
<template src="./Person.html"></template>

Person.html

{{ person }}

In those files, I'm defining the data and then, rather than having the template HTML in the file itself, I'm using a src import (as per the official documentation) to have the HTML in a separate file.

Whilst the code works well, the issue is that I keep getting ESLint errors similar to:

ESLint: 'person' is assigned a value but never used.(@typescript-eslint/no-unused-vars)

This issue is solved completely if I instead put the HTML directly into the .vue file:

Person.vue

<script setup lang="ts">
import { ref } from "vue";
const person = ref(0);
</script>
<template>
  {{ person }}
</template>

Is there any way of having ESLint parse the imported template and determine that "person" is indeed a used var?

For reference, here's my .eslintrc.cjs file:

require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
  root: true,
  extends: [
    "plugin:vue/vue3-recommended",
    "eslint:recommended",
    "@vue/eslint-config-typescript/recommended",
    "@vue/eslint-config-prettier",
  ],
  parser: "vue-eslint-parser",
  overrides: [
    {
      files: ["cypress/integration/**.spec.{js,ts,jsx,tsx}"],
      extends: ["plugin:cypress/recommended"],
    },
  ],
};

Any help will be greatly appreciated!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!