Skip to content
New issue

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

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

Already on GitHub? # to your account

False positives for computed classes #282

Open
Nagell opened this issue May 15, 2023 · 3 comments
Open

False positives for computed classes #282

Nagell opened this issue May 15, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Nagell
Copy link

Nagell commented May 15, 2023

As we use Storybook its quite helpful to set up classes based on params of a component, but this one gives me false positives for all of the class variants:

<script setup lang="ts">
    import { computed } from 'vue'

    // ...

    const variantClasses = computed(() => {
        switch (props.variant) {
        case 'primary':
            return 'oh-btn-primary'
        case 'secondary':
            return 'oh-btn-secondary'
        case 'tertiary-blue':
            return 'oh-btn-tertiary-blue'
        case 'tertiary-gray':
            return 'oh-btn-tertiary-gray'
        default:
            return ''
        }
    })
</script>

<template>
    <button class="oh-btn" :class="[variantClasses]">
        <slot />
    </button>
</template>

<style lang="scss" scoped>
@import "../../assets/styles/main.scss";

.oh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease-in-out;

    &-primary {
        /* The selector `.oh-btn-primary` is unused */
    }

    &-secondary {
        /* The selector `.oh-btn-secondary` is unused */
    }
    /*...*/
</style>

Is it a bug or is there something I've missed in the config?

@ota-meshi
Copy link
Member

Thank you for posting this report.
It looks like a bug to me.

@ota-meshi ota-meshi added the bug Something isn't working label May 16, 2023
@neillrobson
Copy link

Hi! Would it be helpful for me to try my hand at a PR for this issue?

It is causing a decent amount of inconvenience for some folks on my team, and I'd love to help in any way possible to find a resolution.

@neillrobson
Copy link

As I was working on a PR, I realized that my issue is slightly different (although it results in the same undesired result). I created a new issue here for tracking.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants