Skip to content

Proposal: no bare strings in template #491

Closed
@patric-eberle

Description

@patric-eberle

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions