Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Computed properties & instance methods not recognized as already bound (@typescript-eslint/unbound-method false positive) #2925

Open
@heyakyra

Description

Checklist

  • [🗸] I have tried restarting my IDE and the issue persists.
  • [🗸] I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 9.34.0
  • eslint-plugin-vue version: 10.4.0
  • Vue version: 3.5.20
  • Node version: 22.x
  • Operating System: GNU+Linux (Fedora Silverblue 42)

eslint.config.js:

import {
 defineConfigWithVueTs,
 vueTsConfigs,
} from "@vue/eslint-config-typescript";
import { globalIgnores } from "eslint/config";
import prettierConfig from "@vue/eslint-config-prettier";
import standard from "@vue/eslint-config-standard-with-typescript";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import vueParser from "vue-eslint-parser";
import js from "@eslint/js";
import pluginVue from "eslint-plugin-vue";
import storybook from "eslint-plugin-storybook";
export default defineConfigWithVueTs(
 globalIgnores([
 "node_modules",
 "dist/",
 "components/*/dist/",
 "**/index.d.ts",
 ]),
 js.configs.recommended,
 standard,
 storybook.configs["flat/recommended"],
 vueTsConfigs.recommendedTypeChecked,
 pluginVue.configs["flat/recommended"],
 prettierConfig,
 {
 name: "our-project/base",
 files: ["**/*.{js,jsx,ts,tsx,vue}"],
 languageOptions: {
 globals: {
 ...globals.node,
 ...globals.browser,
 },
 sourceType: "module",
 ecmaVersion: "latest",
 parser: vueParser,
 parserOptions: {
 parser: tsParser,
 projectService: true,
 sourceType: "module",
 tsconfigRootDir: import.meta.dirname,
 },
 },
 rules: {
 [...]
 }
 }
);

What did you do?
Occurs when assigning to a variable or passing as a parameter to another function

 computed: {
 alwaysBound(): string {
 return "Always bound!";
 },
 },
 methods: {
 // Computed properties trigger the error
 getAlwaysBound(): string {
 const alwaysBound = this.alwaysBound; // <-- ERROR!
 return alwaysBound; 
 },
 // As do instance methods
 logAlwaysBound(): string {
 const alwaysBound = this.getAlwaysBound(); // <-- ERROR!
 console.log(this.getAlwaysBound()); // <-- ERROR!
 },

What did you expect to happen?
Vue instance methods and computed properties to be understood as already bound.

What actually happened?

Hitting this for all uses of computed properties and methods, which are all automatically bound by Vue already. Using https://github.com/vuejs/eslint-config-typescript and https://github.com/vuejs/vue-eslint-parser/ (let me know if this ticket belongs with one of those instead)

error Avoid referencing unbound methods which may cause unintentional scoping of `this`. 
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead @typescript-eslint/unbound-method

Repository to reproduce this issue

TBD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /