From 3aef49d8e3178120837d475356eba05749466dd6 Mon Sep 17 00:00:00 2001 From: Clemens Peters Date: Wed, 8 May 2019 00:26:11 +0530 Subject: [PATCH] CS fixes using /Users/clemens/Downloads/code-this-not-that-js/async-await.js:33:7: Parsing error: Identifier 'sumRandomAsyncNums' has already been declared /Users/clemens/Downloads/code-this-not-that-js/console-log.js:5:1: Expected an assignment or function call and instead saw an expression. /Users/clemens/Downloads/code-this-not-that-js/console-log.js:11:1: Expected an assignment or function call and instead saw an expression. /Users/clemens/Downloads/code-this-not-that-js/destructuring.js:19:10: Parsing error: Identifier 'feed' has already been declared /Users/clemens/Downloads/code-this-not-that-js/loops.js:28:7: Parsing error: Identifier 'total' has already been declared /Users/clemens/Downloads/code-this-not-that-js/rest-params.js:9:10: Parsing error: Identifier 'totalHitPoints' has already been declared /Users/clemens/Downloads/code-this-not-that-js/spread-syntax.js:20:7: Parsing error: Identifier 'lvl0' has already been declared /Users/clemens/Downloads/code-this-not-that-js/template-literals.js:8:1: Expected an assignment or function call and instead saw an expression. /Users/clemens/Downloads/code-this-not-that-js/template-literals.js:12:1: Expected an assignment or function call and instead saw an expression. see: https://standardjs.com/. --- console-log.js | 25 ++++++++++--------------- template-literals.js | 24 +++++++++++------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/console-log.js b/console-log.js index 3ccac24..9f5d6f1 100644 --- a/console-log.js +++ b/console-log.js @@ -1,32 +1,28 @@ -const foo = { name: 'tom', age: 30, nervous: false }; -const bar = { name: 'dick', age: 40, nervous: false }; -const baz = { name: 'harry', age: 50, nervous: true }; - +const foo = { name: 'tom', age: 30, nervous: false } +const bar = { name: 'dick', age: 40, nervous: false } +const baz = { name: 'harry', age: 50, nervous: true } 'Bad Code 💩' -console.log(foo); -console.log(bar); -console.log(baz); - - +console.log(foo) +console.log(bar) +console.log(baz) 'Good Code ✅' // Computed Property Names -console.log('%c My Friends', 'color: orange; font-weight: bold;' ) -console.log({ foo, bar, baz }); +console.log('%c My Friends', 'color: orange; font-weight: bold;') +console.log({ foo, bar, baz }) // Console.table(...) console.table([foo, bar, baz]) - // // Console.time console.time('looper') -let i = 0; -while (i < 1000000) { i ++ } +let i = 0 +while (i < 1000000) { i++ } console.timeEnd('looper') @@ -36,4 +32,3 @@ const deleteMe = () => console.trace('bye bye database') deleteMe() deleteMe() - diff --git a/template-literals.js b/template-literals.js index ab0802d..2d470be 100644 --- a/template-literals.js +++ b/template-literals.js @@ -1,27 +1,25 @@ const horse = { - name: 'Topher 🐴', - size: 'large', - skills: ['jousting', 'racing'], - age: 7 + name: 'Topher 🐴', + size: 'large', + skills: ['jousting', 'racing'], + age: 7 } 'Bad String Code 💩' - + let bio = horse.name + ' is a ' + horse.size + ' horse skilled in ' + horse.skills.join(' & ') 'Good String Code ✅' -const { name, size, skills } = horse; +const { name, size, skills } = horse bio = `${name} is a ${size} horse skilled in ${skills.join(' & ')}` -console.log(bio); +console.log(bio) // Advanced Tag Example -function horseAge(str, age) { - - const ageStr = age > 5 ? 'old' : 'young'; - return `${str[0]}${ageStr} at ${age} years`; +function horseAge (str, age) { + const ageStr = age > 5 ? 'old' : 'young' + return `${str[0]}${ageStr} at ${age} years` } -const bio2 = horseAge`This horse is ${horse.age}`; +const bio2 = horseAge`This horse is ${horse.age}` console.log(bio2) -