Skip to content

vue/require-render-return false positive for switch-case on enum without default #2100

Open
@Maxim-Mazurok

Description

@Maxim-Mazurok

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.4.10
  • eslint-plugin-vue version: 8.7.1
  • Node version: 18.13.0
  • Operating System: Windows 10

Please show your full configuration:

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

module.exports = {
  root: true,
  plugins: ["vitest"],
  extends: [
    "plugin:vue/vue3-essential",
    "eslint:recommended",
    "plugin:jest-formatting/recommended",
    "@vue/eslint-config-typescript/recommended",
    "@vue/eslint-config-prettier",
  ],
  env: {
    "vue/setup-compiler-macros": false,
  },
  rules: {
    eqeqeq: ["warn", "always"],

    // https://github.com/veritem/eslint-plugin-vitest
    // "vitest/expect-expect": "warn", // TODO: enable after https://github.com/veritem/eslint-plugin-vitest/issues/20 is actually fixed
    // "vitest/max-nested-describe": "warn", // TODO: enable after https://github.com/veritem/eslint-plugin-vitest/issues/23 is fixed
    // "vitest/lower-case-title": "warn", // I don't like that it converts all my describe blocks with camelCase method names...

    "vitest/no-conditional-tests": "warn",
    "vitest/no-focused-tests": "warn",
    "vitest/no-identical-title": "warn",
    "vitest/no-skipped-tests": "warn",
    "require-await": "warn",
  },
  overrides: [
    {
      files: ["cypress/integration/**.spec.{js,ts,jsx,tsx}"],
      extends: ["plugin:cypress/recommended"],
    },
  ],
};

What did you do?

import { defineComponent, type PropType } from "vue";

enum DialogType {
  First,
  Second,
}

export default defineComponent({
  name: "Dialog",
  props: {
    dialogType: {
      type: Number as PropType<DialogType>,
      required: true,
    },
  },
  render() {
    switch (this.dialogType) {
      case DialogType.First:
        return <h1>First</h1>;
      case DialogType.Second:
        return <h1>Second</h1>;
    }
  },
});

What did you expect to happen?
No error because in my switch-case I've exhausted all the enum options, so no default should be needed.

What actually happened?

  16:3  error  Expected to return a value in render function        vue/require-render-return

Repository to reproduce this issue

https://github.com/Maxim-Mazurok/eslint-plugin-vue-2100-repro

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions