Skip to content

Commit d852f51

Browse files
committed
[react][rule links] condense lines
1 parent 2c06d87 commit d852f51

File tree

1 file changed

+14
-36
lines changed

1 file changed

+14
-36
lines changed

react/README.md

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727

2828
## Class vs `React.createClass` vs stateless
2929

30-
- If you have internal state and/or refs, prefer `class extends React.Component` over `React.createClass` unless you have a very good reason to use mixins.
31-
32-
eslint rules: [`react/prefer-es6-class`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md).
30+
- If you have internal state and/or refs, prefer `class extends React.Component` over `React.createClass` unless you have a very good reason to use mixins. [`react/prefer-es6-class`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md)
3331

3432
```javascript
3533
// bad
@@ -48,9 +46,9 @@
4846
}
4947
}
5048
```
51-
49+
5250
And if you don't have state or refs, prefer functions over classes:
53-
51+
5452
```javascript
5553
5654
// bad
@@ -59,7 +57,7 @@
5957
return <div>{this.props.hello}</div>;
6058
}
6159
}
62-
60+
6361
// good
6462
function Listing({ hello }) {
6563
return <div>{hello}</div>;
@@ -70,9 +68,7 @@
7068
7169
- **Extensions**: Use `.jsx` extension for React components.
7270
- **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.jsx`.
73-
- **Reference Naming**: Use PascalCase for React components and camelCase for their instances.
74-
75-
eslint rules: [`react/jsx-pascal-case`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md).
71+
- **Reference Naming**: Use PascalCase for React components and camelCase for their instances. [`react/jsx-pascal-case`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md)
7672
7773
```javascript
7874
// bad
@@ -119,9 +115,7 @@
119115
120116
## Alignment
121117
122-
- Follow these alignment styles for JSX syntax
123-
124-
eslint rules: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md).
118+
- Follow these alignment styles for JSX syntax. [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md)
125119
126120
```javascript
127121
// bad
@@ -148,13 +142,11 @@
148142
149143
## Quotes
150144
151-
- Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS.
145+
- Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS. [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes)
152146
153147
> Why? JSX attributes [can't contain escaped quotes](http://eslint.org/docs/rules/jsx-quotes), so double quotes make conjunctions like `"don't"` easier to type.
154148
> Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention.
155149

156-
eslint rules: [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes).
157-
158150
```javascript
159151
// bad
160152
<Foo bar='bar' />
@@ -206,9 +198,7 @@
206198
/>
207199
```
208200

209-
- Omit the value of the prop when it is explicitly `true`.
210-
211-
eslint rules: [`react/jsx-boolean-value`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md).
201+
- Omit the value of the prop when it is explicitly `true`. [`react/jsx-boolean-value`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md)
212202

213203
```javascript
214204
// bad
@@ -224,9 +214,7 @@
224214

225215
## Parentheses
226216

227-
- Wrap JSX tags in parentheses when they span more than one line.
228-
229-
eslint rules: [`react/wrap-multilines`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md).
217+
- Wrap JSX tags in parentheses when they span more than one line. [`react/wrap-multilines`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md)
230218

231219
```javascript
232220
// bad
@@ -254,9 +242,7 @@
254242

255243
## Tags
256244

257-
- Always self-close tags that have no children.
258-
259-
eslint rules: [`react/self-closing-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md).
245+
- Always self-close tags that have no children. [`react/self-closing-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md)
260246

261247
```javascript
262248
// bad
@@ -266,9 +252,7 @@
266252
<Foo className="stuff" />
267253
```
268254

269-
- If your component has multi-line properties, close its tag on a new line.
270-
271-
eslint rules: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md).
255+
- If your component has multi-line properties, close its tag on a new line. [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md)
272256

273257
```javascript
274258
// bad
@@ -285,12 +269,10 @@
285269

286270
## Methods
287271

288-
- Bind event handlers for the render method in the constructor.
272+
- Bind event handlers for the render method in the constructor. [`react/jsx-no-bind`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md)
289273

290274
> Why? A bind call in the render path creates a brand new function on every single render.
291275

292-
eslint rules: [`react/jsx-no-bind`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md).
293-
294276
```javascript
295277
// bad
296278
class extends React.Component {
@@ -393,7 +375,7 @@
393375
export default Link;
394376
```
395377

396-
- Ordering for `React.createClass`:
378+
- Ordering for `React.createClass`: [`react/sort-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md)
397379

398380
1. `displayName`
399381
1. `propTypes`
@@ -417,16 +399,12 @@
417399
1. *Optional render methods* like `renderNavigation()` or `renderProfilePicture()`
418400
1. `render`
419401

420-
eslint rules: [`react/sort-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md).
421-
422402
## `isMounted`
423403

424-
- Do not use `isMounted`.
404+
- Do not use `isMounted`. [`react/no-is-mounted`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md)
425405

426406
> Why? [`isMounted` is an anti-pattern][anti-pattern], is not available when using ES6 classes, and is on its way to being officially deprecated.
427407

428408
[anti-pattern]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
429409

430-
eslint rules: [`react/no-is-mounted`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md).
431-
432410
**[⬆ back to top](#table-of-contents)**

0 commit comments

Comments
 (0)