Skip to content

Commit f0f3753

Browse files
committed
Changed trailing-commas to es5, moved example config to separate rc file
1 parent a03aa6c commit f0f3753

12 files changed

+56
-33
lines changed

.prettierrc.examples

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"bracketSpacing": false,
3+
"jsxBracketSameLine": true,
4+
"parser": "flow",
5+
"printWidth": 40,
6+
"singleQuote": true,
7+
"trailingComma": "es5"
8+
}

examples/components-and-props/composing-components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ function App() {
1414

1515
ReactDOM.render(
1616
<App />,
17-
document.getElementById('root'),
17+
document.getElementById('root')
1818
);

examples/components-and-props/extracting-components-continued.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ function Comment(props) {
3939

4040
const comment = {
4141
date: new Date(),
42-
text: 'I hope you enjoy learning React!',
42+
text:
43+
'I hope you enjoy learning React!',
4344
author: {
4445
name: 'Hello Kitty',
4546
avatarUrl:
@@ -52,5 +53,5 @@ ReactDOM.render(
5253
text={comment.text}
5354
author={comment.author}
5455
/>,
55-
document.getElementById('root'),
56+
document.getElementById('root')
5657
);

examples/components-and-props/extracting-components.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function Comment(props) {
2727

2828
const comment = {
2929
date: new Date(),
30-
text: 'I hope you enjoy learning React!',
30+
text:
31+
'I hope you enjoy learning React!',
3132
author: {
3233
name: 'Hello Kitty',
3334
avatarUrl:
@@ -40,5 +41,5 @@ ReactDOM.render(
4041
text={comment.text}
4142
author={comment.author}
4243
/>,
43-
document.getElementById('root'),
44+
document.getElementById('root')
4445
);

examples/components-and-props/rendering-a-component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ function Welcome(props) {
55
const element = <Welcome name="Sara" />;
66
ReactDOM.render(
77
element,
8-
document.getElementById('root'),
8+
document.getElementById('root')
99
);

examples/es5-syntax-example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const element = <h1>Hello, world!</h1>;
22
const container = document.getElementById(
3-
'root',
3+
'root'
44
);
55
ReactDOM.render(element, container);

examples/hello-world.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ReactDOM.render(
22
<h1>Hello, world!</h1>,
3-
document.getElementById('root'),
3+
document.getElementById('root')
44
);

examples/introducing-jsx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ const element = (
1515

1616
ReactDOM.render(
1717
element,
18-
document.getElementById('root'),
18+
document.getElementById('root')
1919
);

examples/reconciliation/index-used-as-key.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ class ToDoList extends React.Component {
3333
sortByEarliest() {
3434
const sortedList = this.state.list.sort(
3535
(a, b) => {
36-
return a.createdAt - b.createdAt;
37-
},
36+
return (
37+
a.createdAt - b.createdAt
38+
);
39+
}
3840
);
3941
this.setState({
4042
list: [...sortedList],
@@ -44,8 +46,10 @@ class ToDoList extends React.Component {
4446
sortByLatest() {
4547
const sortedList = this.state.list.sort(
4648
(a, b) => {
47-
return b.createdAt - a.createdAt;
48-
},
49+
return (
50+
b.createdAt - a.createdAt
51+
);
52+
}
4953
);
5054
this.setState({
5155
list: [...sortedList],
@@ -87,25 +91,25 @@ class ToDoList extends React.Component {
8791
<br />
8892
<button
8993
onClick={this.addToStart.bind(
90-
this,
94+
this
9195
)}>
9296
Add New to Start
9397
</button>
9498
<button
9599
onClick={this.addToEnd.bind(
96-
this,
100+
this
97101
)}>
98102
Add New to End
99103
</button>
100104
<button
101105
onClick={this.sortByEarliest.bind(
102-
this,
106+
this
103107
)}>
104108
Sort by Earliest
105109
</button>
106110
<button
107111
onClick={this.sortByLatest.bind(
108-
this,
112+
this
109113
)}>
110114
Sort by Latest
111115
</button>
@@ -117,8 +121,11 @@ class ToDoList extends React.Component {
117121
</tr>
118122
{this.state.list.map(
119123
(todo, index) => (
120-
<ToDo key={index} {...todo} />
121-
),
124+
<ToDo
125+
key={index}
126+
{...todo}
127+
/>
128+
)
122129
)}
123130
</table>
124131
</div>
@@ -128,5 +135,5 @@ class ToDoList extends React.Component {
128135

129136
ReactDOM.render(
130137
<ToDoList />,
131-
document.getElementById('root'),
138+
document.getElementById('root')
132139
);

examples/reconciliation/no-index-used-as-key.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ class ToDoList extends React.Component {
3333
sortByEarliest() {
3434
const sortedList = this.state.list.sort(
3535
(a, b) => {
36-
return a.createdAt - b.createdAt;
37-
},
36+
return (
37+
a.createdAt - b.createdAt
38+
);
39+
}
3840
);
3941
this.setState({
4042
list: [...sortedList],
@@ -44,8 +46,10 @@ class ToDoList extends React.Component {
4446
sortByLatest() {
4547
const sortedList = this.state.list.sort(
4648
(a, b) => {
47-
return b.createdAt - a.createdAt;
48-
},
49+
return (
50+
b.createdAt - a.createdAt
51+
);
52+
}
4953
);
5054
this.setState({
5155
list: [...sortedList],
@@ -87,25 +91,25 @@ class ToDoList extends React.Component {
8791
<br />
8892
<button
8993
onClick={this.addToStart.bind(
90-
this,
94+
this
9195
)}>
9296
Add New to Start
9397
</button>
9498
<button
9599
onClick={this.addToEnd.bind(
96-
this,
100+
this
97101
)}>
98102
Add New to End
99103
</button>
100104
<button
101105
onClick={this.sortByEarliest.bind(
102-
this,
106+
this
103107
)}>
104108
Sort by Earliest
105109
</button>
106110
<button
107111
onClick={this.sortByLatest.bind(
108-
this,
112+
this
109113
)}>
110114
Sort by Latest
111115
</button>
@@ -121,7 +125,7 @@ class ToDoList extends React.Component {
121125
key={todo.id}
122126
{...todo}
123127
/>
124-
),
128+
)
125129
)}
126130
</table>
127131
</div>
@@ -131,5 +135,5 @@ class ToDoList extends React.Component {
131135

132136
ReactDOM.render(
133137
<ToDoList />,
134-
document.getElementById('root'),
138+
document.getElementById('root')
135139
);

0 commit comments

Comments
 (0)