# wxml/no-unexpected-string-bool

# Background

boolean in data binding

Keywords (must be enclosed in double quotes)

  • True: Boolean-type true.
  • false: Boolean-type false.
<checkbox checked="{{false}}"> </checkbox>

Note: Do not directly write checked="false". Its computing result is a string which represents a true value when converted to a Boolean value.

Wechat Document Reference (opens new window)

# Motivation

This rule enforce developer avoid using wrong boolean in wxml data binding

<!-- ✓ GOOD --> <checkbox checked="{{false}}"> </checkbox> <popup showMask /> <!-- ✗ BAD --> <checkbox checked="false"> </checkbox> <popup showMask="true" />
Now loading...

💡 tips

You can edit code via online editor, it's online REPL, try to fix eslint problem !

# Config

No special options, normal config is ok

{ "wxml/no-unexpected-string-bool": "error" }

# Version

This rule was introduced in eslint-plugin-wxml v0.2.1

# Implementation

Last Updated: 12/13/2022, 12:24:46 PM