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

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

Open
mrleblanc101 opened this issue Mar 3, 2025 · 1 comment
Open

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

mrleblanc101 opened this issue Mar 3, 2025 · 1 comment

Comments

@mrleblanc101
Copy link

mrleblanc101 commented Mar 3, 2025

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

@mrleblanc101
Copy link
Author

mrleblanc101 commented Mar 3, 2025

If there was a way to extends the default allowlist without overwriting it, maybe this wouldn't be needed.
Maybe it possible currently, but I'm not sure how.

'vue/no-bare-strings-in-template': [
    'error',
    {
        allowlist: [ ...allowlist, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
        attributes: {
            '/.+/': [
                'title',
                'description',
                'label',
                'help',
                'tooltip',
                'placeholder',
                'errors',
                'content',
                'confirmButtonLabel',
                'cancelButtonLabel',
            ],
        },
        directives: ['v-text'],
    },
],

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

No branches or pull requests

1 participant