diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..0a72520 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "trailingComma": "es5", + "tabWidth": 2, + "semi": true, + "singleQuote": true +} diff --git a/_data/topics.json b/_data/topics.json index adba5c4..d0a6713 100644 --- a/_data/topics.json +++ b/_data/topics.json @@ -1,7 +1,7 @@ [ { - "title": "Buffer and Streams", - "url": "/buffer-and-streams/" + "title": "Buffers and Streams", + "url": "/buffers-and-streams/" }, { "title": "Control flow", diff --git a/events/index.md b/events/index.md index f8a1de2..156891e 100644 --- a/events/index.md +++ b/events/index.md @@ -17,22 +17,22 @@ When the EventEmitter object emits an event, all of the functions attached to th This example creates an event listener for `foo` events, and an event emitter to fire these events. ```javascript -const { EventEmitter } = require("events"); +const { EventEmitter } = require('events'); // create a listener function. These can be arrow functions, but will // loose `this` refering to the EventEmitter object const foo = function foo() { - console.log("foo executed.", this); + console.log('foo executed.', this); }; // create an emitter and bind some events to it const eventEmitter = new EventEmitter(); // Bind the connection event with the listner1 function -eventEmitter.on("foo", foo); +eventEmitter.on('foo', foo); // fire the event -eventEmitter.emit("foo"); +eventEmitter.emit('foo'); ``` ## Passing parameters diff --git a/js/main.js b/js/main.js index 547c4d7..401d2b1 100644 --- a/js/main.js +++ b/js/main.js @@ -1,4 +1,4 @@ -window.addEventListener("DOMContentLoaded", event => { +window.addEventListener('DOMContentLoaded', event => { if (window.localStorage) { window.topicsCompleted = getTopicsFromLocalStorage(); updateUI(); @@ -22,7 +22,7 @@ function checkForCompletedButtons() { } function getButtons() { - return document.querySelectorAll(".completed-button"); + return document.querySelectorAll('.completed-button'); } function toggleCompletedTopic(topic) { @@ -40,17 +40,17 @@ function isCompleted(topic) { } function markButtonAsCompleted(button) { - button.classList.add("completed"); - button.innerText = "Completed!"; + button.classList.add('completed'); + button.innerText = 'Completed!'; } function markButtonAsNotCompleted(button) { - button.classList.remove("completed"); - button.innerText = "Mark as completed"; + button.classList.remove('completed'); + button.innerText = 'Mark as completed'; } function getTopicsFromLocalStorage() { - return JSON.parse(window.localStorage.getItem("topicsCompleted")); + return JSON.parse(window.localStorage.getItem('topicsCompleted')); } function addCompletedTopic(topic) { @@ -64,7 +64,7 @@ function addCompletedTopic(topic) { function save(topics) { window.topicsCompleted = topics; - window.localStorage.setItem("topicsCompleted", JSON.stringify(topics)); + window.localStorage.setItem('topicsCompleted', JSON.stringify(topics)); } function removeCompletedTopic(topic) { @@ -73,16 +73,16 @@ function removeCompletedTopic(topic) { } function getSidebarItems() { - return document.querySelectorAll(".topics li"); + return document.querySelectorAll('.topics li'); } function checkSideBar() { [...getSidebarItems()].forEach(item => { const topic = item.dataset.topic; if (isCompleted(topic)) { - item.classList.add("completed"); + item.classList.add('completed'); } else { - item.classList.remove("completed"); + item.classList.remove('completed'); } }); } diff --git a/styleguide/index.md b/styleguide/index.md index df6ea73..3ff1ce8 100644 --- a/styleguide/index.md +++ b/styleguide/index.md @@ -114,7 +114,7 @@ A paragraph (from the Greek paragraphos, “to write beside” or “written bes ```javascript function whereTo() { - const foo = "bar"; + const foo = 'bar'; for (let i = 0; i < 10; i++) { console.log(foo); }