Skip to content

Type based defineProps and defineEmits issues when declaring function #2116

@thimonwentink

Description

@thimonwentink

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: 8.36.0
  • eslint-plugin-vue version: 9.10.0
  • Node version: 16.17.0
  • Operating System: MacOS

Please show your full configuration:

/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
  root: true,
  parser: 'vue-eslint-parser',
  parserOptions: {
    ecmaVersion: 2020,
    sourceType: 'module',
    parser: '@typescript-eslint/parser',
    extraFileExtensions: ['.vue'],
    project: './tsconfig.json',
  },
  plugins: [
    'vue',
    '@typescript-eslint',
  ],
  extends: [
    'eslint:recommended',
    'airbnb-base',
    'plugin:vue/vue3-recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
  ],
  rules: {
    'vue/define-emits-declaration': ['error', 'type-based'],
    'vue/define-props-declaration': ['error', 'type-based'],  
  },
};

What did you do?

<script lang="ts" setup>
defineProps<{
  modelValue: string;
  testFunction: () => false;
}>();

defineEmits<{
  (event: 'update:modelValue', value: string): void;
}>();
</script>

<template>
  <h1>ESLint issue reproduction</h1>
</template>

What did you expect to happen?
Not getting errors when running npm run lint.

What actually happened?

> eslint ./src/App.vue


/project/home/thimonwentink/workspace/src/App.vue
  2:1   error  Unexpected space between function name and paren       no-spaced-func
  4:16  error  Unexpected whitespace between function name and paren  func-call-spacing
  7:1   error  Unexpected space between function name and paren       no-spaced-func
  7:14  error  Unexpected whitespace between function name and paren  func-call-spacing

✖ 4 problems (4 errors, 0 warnings)
  3 errors and 0 warnings potentially fixable with the `--fix` option.

Repository to reproduce this issue
Click here to see CodeSandbox repo
Run npm run lint to see the issues listed above.

Issue description:
We use vue/define-emits-declaration and vue/define-props-declaration to enforce type based defineProps and defineEmits, but it conflicts with no-spaced-func and func-call-spacing when passing a function in props or emits interface.

I don't know where I have to submit this issue, but I hope you can help me.

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