Skip to content

Commit 278af51

Browse files
committed
got prettier working, so lets pretty
1 parent 68e3b7c commit 278af51

34 files changed

+5878
-3790
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Diff for: .prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
tabWidth: 2
22
semi: false
3-
singleQuote: true
3+
singleQuote: true
4+
printWidth: 100

Diff for: 1-rendering/src/exercise.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@
1313
// - Hint: you'll need an `updateThePage` function that calls `render`,
1414
// and then you'll need to call it in the event handlers of the form controls
1515
////////////////////////////////////////////////////////////////////////////////
16-
import "./index.css";
17-
import React from "react";
18-
import ReactDOM from "react-dom";
19-
import sortBy from "sort-by";
16+
import './index.css'
17+
import React from 'react'
18+
import ReactDOM from 'react-dom'
19+
import sortBy from 'sort-by'
2020

2121
const DATA = {
22-
title: "Menu",
22+
title: 'Menu',
2323
items: [
24-
{ id: 1, name: "tacos", type: "mexican" },
25-
{ id: 2, name: "burrito", type: "mexican" },
26-
{ id: 3, name: "tostada", type: "mexican" },
27-
{ id: 4, name: "mushy peas", type: "english" },
28-
{ id: 5, name: "fish and chips", type: "english" },
29-
{ id: 6, name: "black pudding", type: "english" }
24+
{ id: 1, name: 'tacos', type: 'mexican' },
25+
{ id: 2, name: 'burrito', type: 'mexican' },
26+
{ id: 3, name: 'tostada', type: 'mexican' },
27+
{ id: 4, name: 'mushy peas', type: 'english' },
28+
{ id: 5, name: 'fish and chips', type: 'english' },
29+
{ id: 6, name: 'black pudding', type: 'english' }
3030
]
31-
};
31+
}
3232

3333
const element = (
3434
// put your code here!
3535
<div>Make it happen</div>
36-
);
36+
)
3737

38-
ReactDOM.render(element, document.getElementById("root"));
38+
ReactDOM.render(element, document.getElementById('root'))

Diff for: 1-rendering/src/lecture.js

+15-24
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom";
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
33

44
let tacos = [
5-
{ name: "Carnitas", stars: 5 },
6-
{ name: "Pollo", stars: 3 },
7-
{ name: "Carne Asada", stars: 4 },
8-
{ name: "Al Carbon", stars: 3 },
9-
{ name: "Mole", stars: 5 }
10-
];
5+
{ name: 'Carnitas', stars: 5 },
6+
{ name: 'Pollo', stars: 3 },
7+
{ name: 'Carne Asada', stars: 4 },
8+
{ name: 'Al Carbon', stars: 3 },
9+
{ name: 'Mole', stars: 5 }
10+
]
1111

1212
ReactDOM.render(
1313
<div>
@@ -16,24 +16,15 @@ ReactDOM.render(
1616
{tacos
1717
.sort((a, b) => b.stars - a.stars)
1818
.map(taco => (
19-
<li style={{ margin: "10px" }}>
20-
<button
21-
onClick={() =>
22-
alert(taco.name + " is my favorite!")
23-
}
24-
>
19+
<li style={{ margin: '10px' }}>
20+
<button onClick={() => alert(taco.name + ' is my favorite!')}>
2521
+1
26-
</button>{" "}
27-
{Array.from({ length: taco.stars }).map(
28-
() => "★"
29-
)}
30-
{Array.from({ length: 5 - taco.stars }).map(
31-
() => "☆"
32-
)}{" "}
33-
{taco.name}
22+
</button>{' '}
23+
{Array.from({ length: taco.stars }).map(() => '★')}
24+
{Array.from({ length: 5 - taco.stars }).map(() => '☆')} {taco.name}
3425
</li>
3526
))}
3627
</ul>
3728
</div>,
38-
document.getElementById("root")
39-
);
29+
document.getElementById('root')
30+
)

Diff for: 1-rendering/src/solution.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,36 @@
1313
// - Hint: you'll need an `updateThePage` function that calls `render`,
1414
// and then you'll need to call it in the event handlers of the form controls
1515
////////////////////////////////////////////////////////////////////////////////
16-
import "./index.css";
17-
import React from "react";
18-
import ReactDOM from "react-dom";
19-
import sortBy from "sort-by";
16+
import './index.css'
17+
import React from 'react'
18+
import ReactDOM from 'react-dom'
19+
import sortBy from 'sort-by'
2020

2121
const DATA = {
22-
title: "Menu",
22+
title: 'Menu',
2323
items: [
24-
{ id: 1, name: "tacos", type: "mexican" },
25-
{ id: 2, name: "burrito", type: "mexican" },
26-
{ id: 3, name: "tostada", type: "mexican" },
27-
{ id: 4, name: "mushy peas", type: "english" },
28-
{ id: 5, name: "fish and chips", type: "english" },
29-
{ id: 6, name: "black pudding", type: "english" }
24+
{ id: 1, name: 'tacos', type: 'mexican' },
25+
{ id: 2, name: 'burrito', type: 'mexican' },
26+
{ id: 3, name: 'tostada', type: 'mexican' },
27+
{ id: 4, name: 'mushy peas', type: 'english' },
28+
{ id: 5, name: 'fish and chips', type: 'english' },
29+
{ id: 6, name: 'black pudding', type: 'english' }
3030
]
31-
};
31+
}
3232

3333
const element = (
3434
// put your code here!
3535
<div>
3636
<h1>{DATA.title}</h1>
3737
<ul>
3838
{DATA.items
39-
.filter(item => item.type === "mexican")
40-
.sort(sortBy("name"))
41-
.map(item => <li key={item.id}>{item.name}</li>)}
39+
.filter(item => item.type === 'mexican')
40+
.sort(sortBy('name'))
41+
.map(item => (
42+
<li key={item.id}>{item.name}</li>
43+
))}
4244
</ul>
4345
</div>
44-
);
46+
)
4547

46-
ReactDOM.render(element, document.getElementById("root"));
48+
ReactDOM.render(element, document.getElementById('root'))

Diff for: 2-composition/src/exercise.js

+15-30
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,30 @@
77
// mexican food and one for english food
88
// 4. Pass in a custom "name" to each Menu
99
////////////////////////////////////////////////////////
10-
import "./index.css";
11-
import React from "react";
12-
import ReactDOM from "react-dom";
13-
import sortBy from "sort-by";
10+
import './index.css'
11+
import React from 'react'
12+
import ReactDOM from 'react-dom'
13+
import sortBy from 'sort-by'
1414

15-
let items = [
16-
{ id: 1, name: "tacos", type: "mexican", price: 6 },
17-
{ id: 2, name: "burrito", type: "mexican", price: 9 },
18-
{ id: 3, name: "tostada", type: "mexican", price: 8 },
19-
{
20-
id: 4,
21-
name: "mushy peas",
22-
type: "english",
23-
price: 3
24-
},
25-
{
26-
id: 5,
27-
name: "fish and chips",
28-
type: "english",
29-
price: 12
30-
},
31-
{
32-
id: 6,
33-
name: "black pudding",
34-
type: "english",
35-
price: 12
36-
}
37-
];
15+
const items = [
16+
{ id: 1, name: 'tacos', type: 'mexican', price: 6 },
17+
{ id: 2, name: 'burrito', type: 'mexican', price: 9 },
18+
{ id: 3, name: 'tostada', type: 'mexican', price: 8 },
19+
{ id: 4, name: 'mushy peas', type: 'english', price: 3 },
20+
{ id: 5, name: 'fish and chips', type: 'english', price: 12 },
21+
{ id: 6, name: 'black pudding', type: 'english', price: 12 }
22+
]
3823

3924
ReactDOM.render(
4025
<div>
4126
<h1>Menu</h1>
4227
<ul>
43-
{items.sort(sortBy("name")).map(item => (
28+
{items.sort(sortBy('name')).map(item => (
4429
<li key={item.id}>
4530
{item.name} - <small>${item.price}</small>
4631
</li>
4732
))}
4833
</ul>
4934
</div>,
50-
document.getElementById("root")
51-
);
35+
document.getElementById('root')
36+
)

Diff for: 2-composition/src/lecture.js

+35-48
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React from "react";
2-
import ReactDOM from "react-dom";
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
33

4-
let tacos = [
5-
{ name: "Carnitas", stars: 5 },
6-
{ name: "Pollo", stars: 3 },
7-
{ name: "Carne Asada", stars: 4 },
8-
{ name: "Al Carbon", stars: 3 },
9-
{ name: "Mole", stars: 5 }
10-
];
4+
const tacos = [
5+
{ name: 'Carnitas', stars: 5 },
6+
{ name: 'Pollo', stars: 3 },
7+
{ name: 'Carne Asada', stars: 4 },
8+
{ name: 'Al Carbon', stars: 3 },
9+
{ name: 'Mole', stars: 5 }
10+
]
1111

1212
ReactDOM.render(
1313
<div>
@@ -16,70 +16,57 @@ ReactDOM.render(
1616
{tacos
1717
.sort((a, b) => b.stars - a.stars)
1818
.map((taco, i) => (
19-
<li key={i} style={{ margin: "10px" }}>
20-
<button
21-
onClick={() =>
22-
alert(taco.name + " is my favorite!")
23-
}
24-
>
19+
<li key={i} style={{ margin: '10px' }}>
20+
<button onClick={() => alert(taco.name + ' is my favorite!')}>
2521
+1
26-
</button>{" "}
27-
{Array.from({ length: taco.stars }).map(
28-
() => "★"
29-
)}
30-
{Array.from({ length: 5 - taco.stars }).map(
31-
() => "☆"
32-
)}{" "}
33-
{taco.name}
22+
</button>{' '}
23+
{Array.from({ length: taco.stars }).map(() => '★')}
24+
{Array.from({ length: 5 - taco.stars }).map(() => '☆')} {taco.name}
3425
</li>
3526
))}
3627
</ul>
3728
</div>,
38-
document.getElementById("root")
39-
);
29+
document.getElementById('root')
30+
)
4031

41-
// import React from "react";
42-
// import ReactDOM from "react-dom";
32+
// import React from 'react'
33+
// import ReactDOM from 'react-dom'
4334

4435
// let tacos = [
45-
// { name: "Carnitas", stars: 5 },
46-
// { name: "Pollo", stars: 3 },
47-
// { name: "Carne Asada", stars: 4 },
48-
// { name: "Al Carbon", stars: 3 },
49-
// { name: "Mole", stars: 5 }
50-
// ];
36+
// { name: 'Carnitas', stars: 5 },
37+
// { name: 'Pollo', stars: 3 },
38+
// { name: 'Carne Asada', stars: 4 },
39+
// { name: 'Al Carbon', stars: 3 },
40+
// { name: 'Mole', stars: 5 }
41+
// ]
5142

5243
// let Stars = ({ stars, total = 5 }) => (
5344
// <span>
54-
// {Array.from({ length: stars }).map(() => "★")}
45+
// {Array.from({ length: stars }).map(() => '★')}
5546
// {Array.from({
5647
// length: total - stars
57-
// }).map(() => "☆")}
48+
// }).map(() => '☆')}
5849
// </span>
59-
// );
50+
// )
6051

6152
// let Taco = ({ taco }) => (
62-
// <li style={{ margin: "10px" }}>
63-
// <button
64-
// onClick={() =>
65-
// alert(taco.name + " is my favorite!")
66-
// }
67-
// >
68-
// +1
69-
// </button>{" "}
53+
// <li style={{ margin: '10px' }}>
54+
// <button onClick={() => alert(taco.name + ' is my favorite!')}>+1</button>{' '}
7055
// <Stars stars={taco.stars} /> {taco.name}
7156
// </li>
72-
// );
57+
// )
7358

7459
// let App = () => (
7560
// <div>
7661
// <h1>Welcome to React!</h1>
7762
// <ul>
7863
// {tacos
7964
// .sort((a, b) => b.stars - a.stars)
80-
// .map(taco => <Taco taco={taco} />)}
65+
// .map(taco => (
66+
// <Taco taco={taco} />
67+
// ))}
8168
// </ul>
8269
// </div>
83-
// );
70+
// )
8471

85-
// ReactDOM.render(<App />, document.getElementById("root"));
72+
// ReactDOM.render(<App />, document.getElementById('root'))

0 commit comments

Comments
 (0)