Skip to content

Commit 18c0369

Browse files
committed
Added docs for no-literals rule
1 parent 21075b4 commit 18c0369

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Finally, enable all of the rules that you would like to use.
8484
* [no-danger](docs/rules/no-danger.md): Prevent usage of dangerous JSX properties
8585
* [no-did-mount-set-state](docs/rules/no-did-mount-set-state.md): Prevent usage of setState in componentDidMount
8686
* [no-did-update-set-state](docs/rules/no-did-update-set-state.md): Prevent usage of setState in componentDidUpdate
87+
* [no-literals](docs/rules/no-literals.md): Prevent usage of unwrapped JSX strings
8788
* [no-multi-comp](docs/rules/no-multi-comp.md): Prevent multiple component definition per file
8889
* [no-unknown-property](docs/rules/no-unknown-property.md): Prevent usage of unknown DOM property
8990
* [prop-types](docs/rules/prop-types.md): Prevent missing props validation in a React component definition

docs/rules/no-literals.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Prevent usage of unwrapped JSX strings (no-literals)
2+
3+
In JSX when using a literal string you can wrap it in a JXS container `{'TEXT'}`.
4+
This rules requies that you wrap all literal strings.
5+
Prevents any odd artifacts of highlighters if you unwrapped string contains a enclsoing character like `'` in contractions and enforces consistency.
6+
7+
## Rule Details
8+
9+
The following patterns are considered warnings:
10+
11+
```javascript
12+
var Hello = <div>test</div>;
13+
```
14+
15+
The following patterns are not considered:
16+
17+
```javascript
18+
var Hello = <div>{'test'}</div>;
19+
```
20+
21+
## When Not To Use It
22+
23+
If you do not want to enforce any style JSX literals, then you can disable this rule.

0 commit comments

Comments
 (0)