Skip to content

Your code looks like this?

let r=fetchData(tId), d=JSON.parse(r), aB=d.bal, tT=d.type;
let tA=parseFloat(d.amt), lD=getDate(), uN=getUser(), ref=genRef(tId,lD);
let pS=paymentStatus(aB), lT=transType(tT), meta=getMetadata(tId);
if(tT==="debit") { aB-=tA; } else if(tT==="credit") { aB+=tA; }
updateHistory(tId, aB, lD, ref); applyLog(uN, tId, ref, lD);
checkAlerts(aB, pS); notifyUserIfThreshold(uN, pS, aB);
sendNotify(uN, pS, tA); logAudit(tId, uN, lT, ref);
handleEndOfTransaction(tId, lT, pS, ref);

Make it look like this!

         import πŸ‘ˆ from 'left-pad'
         import 🎭 from 'is-even'

               let βœ‹ = '1'
            let πŸ”₯ = +πŸ‘ˆ(βœ‹++, βœ‹)
       let 🌈 = πŸ”₯++ + ++βœ‹ + +🎭(++πŸ”₯)
            let 🌯 = 🌈 + πŸ”₯ * πŸ–οΈ

// 12% of the people can't solve this! πŸ˜‚
       console.log(πŸ‘ˆ(βœ‹, 🌯, 🌈) + 1)

Preview provided solely for illustrative purposes, should not be considered as a binding or contractual representation. Fonts not included. Please note that using emojis as variable names is not technically supported in Javascript and most programming languages. Performed by trained professionals only. Do not try this at home. Always prioritize safe coding practices.


20+ rules, including…

align

make your code elegant

      let foo
for (const bar in this)
yield true
let foo
for (const bar in this)
  yield true
        let foo
for (const bar in this)
       yield true

justify2

make your code eleganter

function           fib(num)           {
if     (num     <     1)    return    0
else   if   (num   ===   1)   return  1
else return fib(num - 1) + fib(num - 2)
}
function fib(num) {
  if (num < 1) return 0
  else if (num === 1) return 1
  else return fib(num - 1) + fib(num - 2)
}
function           fib(num)           {
if     (num     <     1)    return    0
else   if   (num   ===   1)   return  1
else return fib(num - 1) + fib(num - 2)
}

justify

make your code understandable

// for i from 1 to 101 (excluded)
for (var i = 1; i < 101; i++) {
    // if divisible by 15, print FizzFizz
    if (i % 15 == 0) console.log("FizzBuzz");
    // else, if divisible by 3, print Fizz
    else if (i % 3 == 0) console.log("Fizz");
    // else, if divisible by 5, print Buzz
    else if (i % 5 == 0) console.log("Buzz");
    // else, print the number i
    else console.log(i);
// end of for loop
}
for (var i = 1; i < 101; i++) {

    if (i % 15 == 0) console.log("FizzBuzz");

    else if (i % 3 == 0) console.log("Fizz");

    else if (i % 5 == 0) console.log("Buzz");

    else console.log(i);

}
// for i from 1 to 101 (excluded)
for (var i = 1; i < 101; i++) {
    // if divisible by 15, print FizzFizz
    if (i % 15 == 0) console.log("FizzBuzz");
    // else, if divisible by 3, print Fizz
    else if (i % 3 == 0) console.log("Fizz");
    // else, if divisible by 5, print Buzz
    else if (i % 5 == 0) console.log("Buzz");
    // else, print the number i
    else console.log(i);
// end of for loop
}

By

Azat S.

Azat S.

Author of eslint-plugin-perfectionist, which this project is forked from

Released under the MIT License