question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: no bare strings in template

See original GitHub issue

Please describe what the rule should do: Projects which use localization (e.g. vue-i18n) should not allow the use of bare strings (hardcoded strings) in templates. They should force the use the mustache syntax or directives.

This proposal is based on the Ember template linter, which includes such a rule already: https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-bare-strings.md

What category of rule is this? (place an “X” next to just one item)

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

Provide 2-3 code examples that this rule will warn about: Invalid template content

<h1>Foo baa</h1>

Valid template content

<h1>{{ $t('myTranslationKey') }}</h1>
<h1>{{ aComputedValue }}</h1>
<h1 v-t="'foo.bar'"></h1>
<h1><span>{{ aComputedValue }}</span></h1>

Why should this rule be included? It allows to test templates for hardcoded text which most likely will lead to issues in localized projects.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisvfritzcommented, Jul 31, 2018

Ah, I see. Then we may want to disable string literals for directives, with a whitelist of some directives, like v-t and the user could add their own as well. Otherwise, we open up a big hole with v-text, v-html, and directives defined by other libraries, like v-tooltip. For example:

<p v-text="'hello'"/>
<button v-tooltip="'Hard-coded button tooltip content'">

We probably don’t want those to be considered valid, right?

0reactions
nilesh9836commented, Jun 23, 2022

can anybody help me with how to use this rule in my package.json

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue/no-bare-strings-in-template
Rule Details #. This rule disallows the use of bare strings in <template> . In order to be able to internationalize your application,...
Read more >
CoffeeScript
Like JavaScript and many other languages, CoffeeScript supports strings as delimited by ... coffee --bare --no-header --compile app.coffee && npm run flow.
Read more >
Template structure and syntax - Azure Resource Manager
Describes the structure and properties of Azure Resource Manager templates (ARM templates) using declarative JSON syntax.
Read more >
Web Player
We offer a few different ways to embed our players. ... {{! template-lint-disable no-bare-strings }} https://www.art19.com/shows/SLUG. Example:
Read more >
Message templates | Apigee X
Compute a hash value and return the string representation of that hash as a hexadecimal number. Syntax. Function, Description. md5Hex(string), Computes an MD5 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found