File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ # vue-i18n/no-raw-text
2
+
3
+ > disallow to string literal in template or JSX
4
+
5
+ This rule warns the usage of string literal.
6
+
7
+ This rule encourage i18n in about the application needs to be localized.
8
+
9
+ ## :book : Rule Details
10
+
11
+ :-1 : Examples of ** incorrect** code for this rule:
12
+
13
+ ` template ` option:
14
+ ``` js
15
+ const MyComponent = {
16
+ // ✗ BAD
17
+ template: ' <p>hello</p>' ,
18
+ // ...
19
+ }
20
+ ```
21
+
22
+ ` template ` block of single-file components:
23
+ ``` vue
24
+ <template>
25
+ <!-- ✗ BAD -->
26
+ <p>hello</p>
27
+ </template>
28
+ ```
29
+
30
+ ` JSX ` :
31
+ ``` js
32
+ const MyComponent = {
33
+ // ✗ BAD
34
+ render : h => (< p> hello< / p> )
35
+ // ...
36
+ }
37
+ ```
38
+
39
+ :+1 : Examples of ** correct** code for this rule:
40
+
41
+ ` template ` option:
42
+ ``` js
43
+ const MyComponent = {
44
+ // ✓ GOOD
45
+ template: ' <p>{{ $(' hello' ) }}</p>' ,
46
+ // ...
47
+ }
48
+ ```
49
+
50
+ ` template ` block of single-file components:
51
+ ``` vue
52
+ <template>
53
+ <!-- ✓ GOOD -->
54
+ <p>{{ $t('hello') }}</p>
55
+ </template>
56
+ ```
57
+
58
+ ` JSX ` :
59
+ ``` js
60
+ const MyComponent = {
61
+ // ✓ GOOD
62
+ render : h => (< p> this .$t (' hello' )< / p> )
63
+ // ...
64
+ }
65
+ ```
You can’t perform that action at this time.
0 commit comments