Skip to content

vue/no-bare-strings-in-template allow numbers #2695

Closed
@mrleblanc101

Description

@mrleblanc101

What rule do you want to change?
vue/no-bare-strings-in-template

Does this change cause the rule to produce more or fewer warnings?
Fewer

How will the change be implemented? (New option, new default behavior, etc.)?
Either add an option to allow numbers:

{
  "vue/no-bare-strings-in-template": ["error", {
+   "allowNumbers": true,
    "allowlist": [
      "(", ")", ",", ".", "&", "+", "-", "=", "*", "/", "#", "%", "!", "?", ":", "[", "]", "{", "}", "<", ">", "\u00b7", "\u2022", "\u2010", "\u2013", "\u2014", "\u2212", "|"
    ],
    "attributes": {
      "/.+/": ["title", "aria-label", "aria-placeholder", "aria-roledescription", "aria-valuetext"],
      "input": ["placeholder"],
      "img": ["alt"]
    },
    "directives": ["v-text"]
  }]
}

or add all number to the default allowList:

{
  "vue/no-bare-strings-in-template": ["error", {
    "allowlist": [
      "(", ")", ",", ".", "&", "+", "-", "=", "*", "/", "#", "%", "!", "?", ":", "[", "]", "{", "}", "<", ">", "\u00b7", "\u2022", "\u2010", "\u2013", "\u2014", "\u2212", "|", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
    ],
    "attributes": {
      "/.+/": ["title", "aria-label", "aria-placeholder", "aria-roledescription", "aria-valuetext"],
      "input": ["placeholder"],
      "img": ["alt"]
    },
    "directives": ["v-text"]
  }]
}

Please provide some example code that this change will affect:

<div>1</div>

What does the rule currently do for this code?

Unexpected non-translated string used.

What will the rule do after it's changed?
No error, number don't need to be "translated" (unless they are formatted, which is not alwats needed)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions