Skip to content

Rule Proposal: Analog for strict-boolean-expressions typescript-eslint rule #2143

@basil-gor

Description

@basil-gor

Please describe what the rule should do:

There are very useful rule strict-boolean-expressions in typescript-eslint.
If there are no possible ways to use it in vue templates, maybe we can implement a vue analog for this rule?

What category should the rule belong to?

[x] Enforces code style (layout)
[ ] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

Just for example for string expression:

// Will be incorrect ❌
<div
  v-if="someEmptyString"
/>

// Will be correct ✅
<div
   v-if="someEmptyString !== ''"
/>

Additional context

Activity

changed the title [-]Analog for `strict-boolean-expressions` typescript-eslint rule[/-] [+]Rule Proposal: Analog for `strict-boolean-expressions` typescript-eslint rule[/+] on May 5, 2023
juliusfriedman

juliusfriedman commented on Jul 27, 2025

@juliusfriedman

Have been wondering if the fact @typescript-eslint/strict-boolean-expressions is only working inside <script> tags and not templates is a bug.

It comes as a surprise to me that v-if parsing and if parsing are not handled the same, I would think they are the same syntax nodes in AST and that this rule would work out of the box.

waynzh

waynzh commented on Aug 8, 2025

@waynzh
Member

if the fact @typescript-eslint/strict-boolean-expressions is only working inside <script> tags

Exactly. Since the Node types in the <template> are different, similar functionality needs to be implemented to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @FloEdelmann@juliusfriedman@basil-gor@waynzh

        Issue actions

          Rule Proposal: Analog for `strict-boolean-expressions` typescript-eslint rule · Issue #2143 · vuejs/eslint-plugin-vue