Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue/require-valid-default-prop false-positive when using TS prop definition #1853

Closed
2 tasks done
schw4rzlicht opened this issue Apr 19, 2022 · 1 comment · Fixed by #1854
Closed
2 tasks done

vue/require-valid-default-prop false-positive when using TS prop definition #1853

schw4rzlicht opened this issue Apr 19, 2022 · 1 comment · Fixed by #1854

Comments

@schw4rzlicht
Copy link

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.5.0
  • eslint-plugin-vue version: 8.2.0
  • Node version: 14.17.0
  • Operating System: macOS, Ubuntu 20

Please show your full configuration:

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

module.exports = {
    root: true,
    extends: [
        "plugin:eslint-comments/recommended",
        "plugin:vue/vue3-strongly-recommended",
        "plugin:vue/vue3-recommended",
        "airbnb-typescript/base",
        "@vue/typescript/recommended",
        "@vue/prettier",
        "plugin:storybook/recommended",
        "plugin:markdown/recommended",
        "prettier",
    ],
    plugins: ["import"],
    parserOptions: {
        ecmaVersion: 2020,
        project: ["./tsconfig.json", "./tsconfig.vite-config.json"],
    },
    settings: {
        "import/parsers": {
            "@typescript-eslint/parser": [".ts", ".tsx"],
        },
    },
    env: {
        node: true,
        es2021: true,
        "vue/setup-compiler-macros": true,
    },
    rules: {
        "@typescript-eslint/quotes": ["error", "double", { allowTemplateLiterals: true, avoidEscape: true }],
        "max-len": ["error", 200, 4],
        "no-param-reassign": "off",
        "no-use-before-define": "off",
        "no-console": "error",
        "no-debugger": "error",
        "no-plusplus": "off",
        "@typescript-eslint/no-unused-vars": "error",
        "eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
        "vue/no-v-html": "error",
    },
    overrides: [
        {
            files: ["vite.config.ts", "tailwind.config.js"],
            rules: {
                "import/no-extraneous-dependencies": "off",
            },
        },
    ],
};

What did you do?

export interface SomePropInterface {
  someProp?: false | string;
}

withDefaults(defineProps<SomePropInterface>(), {
  someProp: false,
});

What did you expect to happen?

Assigning false to someProp as default value should be okay.

What actually happened?

ESLint: Type of the default value for 'someProp' prop must be a string.(vue/require-valid-default-prop)

Repository to reproduce this issue

I don't really think it's necessary but I will take the time to create one if really needed.

@ota-meshi
Copy link
Member

Thank you for the bug report. I started to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants