Skip to content

Commit 767cb34

Browse files
committed
📝 docs(vuepress): add no-raw-text rule spec
1 parent db060e6 commit 767cb34

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

docs/rules/no-raw-text.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
```

0 commit comments

Comments
 (0)