Skip to content

Commit 8735407

Browse files
authored
Merge pull request #19 from Node-Study-Guide/prettier
Adding prettierrc with some initial rules
2 parents 5ec49e7 + 8c48445 commit 8735407

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true
6+
}

_data/topics.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"title": "Buffer and Streams",
4-
"url": "/buffer-and-streams/"
3+
"title": "Buffers and Streams",
4+
"url": "/buffers-and-streams/"
55
},
66
{
77
"title": "Control flow",

events/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ When the EventEmitter object emits an event, all of the functions attached to th
1717
This example creates an event listener for `foo` events, and an event emitter to fire these events.
1818

1919
```javascript
20-
const { EventEmitter } = require("events");
20+
const { EventEmitter } = require('events');
2121

2222
// create a listener function. These can be arrow functions, but will
2323
// loose `this` refering to the EventEmitter object
2424
const foo = function foo() {
25-
console.log("foo executed.", this);
25+
console.log('foo executed.', this);
2626
};
2727

2828
// create an emitter and bind some events to it
2929
const eventEmitter = new EventEmitter();
3030

3131
// Bind the connection event with the listner1 function
32-
eventEmitter.on("foo", foo);
32+
eventEmitter.on('foo', foo);
3333

3434
// fire the event
35-
eventEmitter.emit("foo");
35+
eventEmitter.emit('foo');
3636
```
3737

3838
## Passing parameters

js/main.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
window.addEventListener("DOMContentLoaded", event => {
1+
window.addEventListener('DOMContentLoaded', event => {
22
if (window.localStorage) {
33
window.topicsCompleted = getTopicsFromLocalStorage();
44
updateUI();
@@ -22,7 +22,7 @@ function checkForCompletedButtons() {
2222
}
2323

2424
function getButtons() {
25-
return document.querySelectorAll(".completed-button");
25+
return document.querySelectorAll('.completed-button');
2626
}
2727

2828
function toggleCompletedTopic(topic) {
@@ -40,17 +40,17 @@ function isCompleted(topic) {
4040
}
4141

4242
function markButtonAsCompleted(button) {
43-
button.classList.add("completed");
44-
button.innerText = "Completed!";
43+
button.classList.add('completed');
44+
button.innerText = 'Completed!';
4545
}
4646

4747
function markButtonAsNotCompleted(button) {
48-
button.classList.remove("completed");
49-
button.innerText = "Mark as completed";
48+
button.classList.remove('completed');
49+
button.innerText = 'Mark as completed';
5050
}
5151

5252
function getTopicsFromLocalStorage() {
53-
return JSON.parse(window.localStorage.getItem("topicsCompleted"));
53+
return JSON.parse(window.localStorage.getItem('topicsCompleted'));
5454
}
5555

5656
function addCompletedTopic(topic) {
@@ -64,7 +64,7 @@ function addCompletedTopic(topic) {
6464

6565
function save(topics) {
6666
window.topicsCompleted = topics;
67-
window.localStorage.setItem("topicsCompleted", JSON.stringify(topics));
67+
window.localStorage.setItem('topicsCompleted', JSON.stringify(topics));
6868
}
6969

7070
function removeCompletedTopic(topic) {
@@ -73,16 +73,16 @@ function removeCompletedTopic(topic) {
7373
}
7474

7575
function getSidebarItems() {
76-
return document.querySelectorAll(".topics li");
76+
return document.querySelectorAll('.topics li');
7777
}
7878

7979
function checkSideBar() {
8080
[...getSidebarItems()].forEach(item => {
8181
const topic = item.dataset.topic;
8282
if (isCompleted(topic)) {
83-
item.classList.add("completed");
83+
item.classList.add('completed');
8484
} else {
85-
item.classList.remove("completed");
85+
item.classList.remove('completed');
8686
}
8787
});
8888
}

styleguide/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ A paragraph (from the Greek paragraphos, “to write beside” or “written bes
114114

115115
```javascript
116116
function whereTo() {
117-
const foo = "bar";
117+
const foo = 'bar';
118118
for (let i = 0; i < 10; i++) {
119119
console.log(foo);
120120
}

0 commit comments

Comments
 (0)