You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[template-builtin-component-arguments](docs/rules/template-builtin-component-arguments.md)| disallow setting certain attributes on builtin components ||||
198
-
|[template-no-action-modifiers](docs/rules/template-no-action-modifiers.md)| disallow usage of {{action}} modifiers ||||
199
-
|[template-no-arguments-for-html-elements](docs/rules/template-no-arguments-for-html-elements.md)| disallow @arguments on HTML elements ||||
200
-
|[template-no-array-prototype-extensions](docs/rules/template-no-array-prototype-extensions.md)| disallow usage of Ember Array prototype extensions ||||
201
-
|[template-no-block-params-for-html-elements](docs/rules/template-no-block-params-for-html-elements.md)| disallow block params on HTML elements ||||
202
-
|[template-no-capital-arguments](docs/rules/template-no-capital-arguments.md)| disallow capital arguments (use lowercase @arg instead of @Arg) ||||
203
-
|[template-no-chained-this](docs/rules/template-no-chained-this.md)| disallow redundant `this.this` in templates || 🔧 ||
204
-
|[template-no-debugger](docs/rules/template-no-debugger.md)| disallow {{debugger}} in templates ||||
205
-
|[template-no-element-event-actions](docs/rules/template-no-element-event-actions.md)| disallow element event actions (use {{on}} modifier instead) ||||
206
-
|[template-no-inline-event-handlers](docs/rules/template-no-inline-event-handlers.md)| disallow DOM event handler attributes ||||
|[template-builtin-component-arguments](docs/rules/template-builtin-component-arguments.md)| disallow setting certain attributes on builtin components ||||
198
+
|[template-no-action-modifiers](docs/rules/template-no-action-modifiers.md)| disallow usage of {{action}} modifiers ||||
199
+
|[template-no-arguments-for-html-elements](docs/rules/template-no-arguments-for-html-elements.md)| disallow @arguments on HTML elements ||||
200
+
|[template-no-array-prototype-extensions](docs/rules/template-no-array-prototype-extensions.md)| disallow usage of Ember Array prototype extensions ||||
201
+
|[template-no-bare-strings](docs/rules/template-no-bare-strings.md)| disallow bare strings in templates (require translation/localization) ||||
202
+
|[template-no-block-params-for-html-elements](docs/rules/template-no-block-params-for-html-elements.md)| disallow block params on HTML elements ||||
203
+
|[template-no-capital-arguments](docs/rules/template-no-capital-arguments.md)| disallow capital arguments (use lowercase @arg instead of @Arg) ||||
204
+
|[template-no-chained-this](docs/rules/template-no-chained-this.md)| disallow redundant `this.this` in templates || 🔧 ||
205
+
|[template-no-debugger](docs/rules/template-no-debugger.md)| disallow {{debugger}} in templates ||||
206
+
|[template-no-element-event-actions](docs/rules/template-no-element-event-actions.md)| disallow element event actions (use {{on}} modifier instead) ||||
207
+
|[template-no-inline-event-handlers](docs/rules/template-no-inline-event-handlers.md)| disallow DOM event handler attributes ||||
Disallows bare strings in templates to encourage internationalization.
6
+
7
+
Bare strings in templates make internationalization (i18n) difficult. This rule encourages using translation helpers or properties to enable easy localization of your application.
8
+
9
+
## Rule Details
10
+
11
+
This rule disallows text content in templates that isn't wrapped in a translation helper or passed as a property.
12
+
13
+
The following are allowed:
14
+
15
+
- Whitespace-only strings
16
+
- Strings containing only numbers and punctuation
17
+
- Strings in an allowlist (configurable)
18
+
19
+
## Examples
20
+
21
+
Examples of **incorrect** code for this rule:
22
+
23
+
```gjs
24
+
<template>
25
+
<div>Hello World</div>
26
+
</template>
27
+
```
28
+
29
+
```gjs
30
+
<template>
31
+
<button>Click me</button>
32
+
</template>
33
+
```
34
+
35
+
```gjs
36
+
<template>
37
+
<h1>Welcome to our app</h1>
38
+
</template>
39
+
```
40
+
41
+
Examples of **correct** code for this rule:
42
+
43
+
```gjs
44
+
<template>
45
+
<div>{{t "hello.world"}}</div>
46
+
</template>
47
+
```
48
+
49
+
```gjs
50
+
<template>
51
+
<button>{{@buttonText}}</button>
52
+
</template>
53
+
```
54
+
55
+
```gjs
56
+
<template>
57
+
<div>123</div>
58
+
</template>
59
+
```
60
+
61
+
```gjs
62
+
<template>
63
+
<div> </div>
64
+
</template>
65
+
```
66
+
67
+
## Configuration
68
+
69
+
### `allowlist`
70
+
71
+
An array of strings that are allowed to appear as bare strings:
72
+
73
+
```js
74
+
module.exports= {
75
+
rules: {
76
+
'ember/template-no-bare-strings': [
77
+
'error',
78
+
{
79
+
allowlist: ['Welcome', 'Home', 'About'],
80
+
},
81
+
],
82
+
},
83
+
};
84
+
```
85
+
86
+
### `globalAttributes`
87
+
88
+
An array of attribute names where bare strings will be checked globally on all elements (defaults to `["title", "aria-label", "aria-placeholder", "aria-roledescription", "aria-valuetext"]`):
89
+
90
+
```js
91
+
module.exports= {
92
+
rules: {
93
+
'ember/template-no-bare-strings': [
94
+
'error',
95
+
{
96
+
globalAttributes: [
97
+
'title',
98
+
'aria-label',
99
+
'aria-placeholder',
100
+
'aria-roledescription',
101
+
'aria-valuetext',
102
+
],
103
+
},
104
+
],
105
+
},
106
+
};
107
+
```
108
+
109
+
### `elementAttributes`
110
+
111
+
An object mapping element names to arrays of attribute names to check for bare strings (defaults to `{ input: ["placeholder"], img: ["alt"] }`). The built-in Ember components `Input` and `Textarea` also check `placeholder` and `@placeholder`:
112
+
113
+
```js
114
+
module.exports= {
115
+
rules: {
116
+
'ember/template-no-bare-strings': [
117
+
'error',
118
+
{
119
+
elementAttributes: {
120
+
input: ['placeholder'],
121
+
img: ['alt'],
122
+
},
123
+
},
124
+
],
125
+
},
126
+
};
127
+
```
128
+
129
+
### `ignoredElements`
130
+
131
+
An array of element names whose text content is ignored (defaults to `["pre", "script", "style", "textarea"]`):
0 commit comments