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

Variable usage checking for css variable injection #335

Closed
caxerx opened this issue Jul 27, 2021 · 6 comments
Closed

Variable usage checking for css variable injection #335

caxerx opened this issue Jul 27, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@caxerx
Copy link

caxerx commented Jul 27, 2021

The variable used as css variable inject (vuejs/rfcs#231) will not considered as an used variable and produce a 'declared but its value is never read' error.

Example:

<script setup lang="ts">
const containerHeight = "500px";
</script>

<style scoped>
.container {
  height: v-bind(containerHeight);
}
</style>

The variable containerHeight will cause a error since it only used in the style tag.

@johnsoncodehk johnsoncodehk added the enhancement New feature or request label Jul 27, 2021
@glen-84
Copy link

glen-84 commented Aug 21, 2021

@johnsoncodehk,

Is this supposed to handle string paths?

image

@johnsoncodehk
Copy link
Member

@glen-84 No, I keep string paths as a way to escape diagnosis.

@glen-84
Copy link

glen-84 commented Aug 21, 2021

But then how can I get the variable to show as used?

@johnsoncodehk
Copy link
Member

Use v-bind(xxx) instead of v-bind("xxx").

@glen-84
Copy link

glen-84 commented Aug 21, 2021

https://v3.vuejs.org/api/sfc-style.html#state-driven-dynamic-css

The syntax works with <script setup>, and supports JavaScript expressions (must be wrapped in quotes)

@johnsoncodehk
Copy link
Member

@glen-84 Thanks to point this out! Will follow up this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants