Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Walking through the source code of an OSS Library(ESLint))

Walking through the source code of an OSS Library(ESLint))

kkeeth

July 16, 2022
Tweet

More Decks by kkeeth

Other Decks in Programming

Transcript

  1. Walking through the source code of an OSS library(ESLint) 

    l4VNNFS+BWB4DSJQU'FTUJWBM0OMJOFz @kkeeth @kuwahara_jsri @kkeeth
  2. While looking back on a day 💁

  3. *`NBMFBEFOHJOFFSPSUFDIMFBE *WFDSFBUFEB13 QMFBTFSFWJFX me Team Member A 0,👍*`MMSFWJFXBOEGFFECBDLZPV me

  4. 5IFOVNCFSPGNFNCFSTBOE13TIBT JODSFBTFE TP*TIPVMEDPODFOUSBUFPOMZ POSFWJFXJOH OPUJNQMFNFOUJOH *WFDSFBUFEB13 QMFBTFSFWJFX me Team Member

    B, C … 0,👍*`MMSFWJFXBOEGFFECBDLZPV me
  5. 1MFBTFSBUFUIJTDBOEJEBUFTDPEF Recruitment Personnel *`NBTFSWBOUMFBEFSPGPGBDSPTTFBDI FOHJOFFSJOHHSPVQ me *`NBNFNCFSPGUIF#PBSE me

  6. me 0,👍*`MMSFWJFXBOEGFFECBDLZPV *TUPQQFEXSJUJOHNPSFBOENPSFDPEF *GZPVPOMZSFBEDPEF DBUDIJOHVQXJUIOFX UFDIOPMPHJFTTVDIBTMJCSBSJFTBOEGSBNFXPSLTUFOET UPCFTVQFS fi DJBM4Pʜ *GFFMmy

    technical skills have declined… Voice of my heart
  7. me 0,👍*`MMSFWJFXBOEGFFECBDLZPV *TUPQQFEXSJUJOHNPSFBOENPSFDPEF *GZPVPOMZSFBEDPEF DBUDIJOHVQXJUIOFX UFDIOPMPHJFTTVDIBTMJCSBSJFTBOEGSBNFXPSLTUFOET UPCFTVQFS fi DJBM4Pʜ *GFFMmy

    technical skills have declined… Voice of my heart I've got to do something ʘ(^o^)ʗ
  8. I feel like I could learn more from reading codes

    😆
  9. About me

  10. Published 📙

  11. OQNKTDPNdLLFFUI

  12. 🙇 Sorry … 🙇 This slide is written in English.

    However, I am still learning English, and there may be some inappropriate expressions. Plz feedback for me called “Masakari” about my talk!!
  13. Let’s start 😆

  14. Then, let's read the source code of ESLint!

  15. *NBHFCZIUUQTFTMJOUPSH

  16. Basically, we start from the module written in the main

    of package.json💁
  17. This is the main one. This is a so-called controller

    💁
  18. This is the module that actually does the work 💁

  19. As the name implies, it is a helper or preparation

    for testing. It includes many things 💁
  20. This one is just like the name. This is a

    collection of processes that handle source code. 💁
  21. Next, let’s look at “bin” dir.

  22. Only 3 helper functions and an executable function here💁

  23. None
  24. Next, let’s look at “lib/cli.js” fi le.

  25. None
  26. “cli.js” depends on “ESLint” module “ESLint” module depends on “CLIEngine”

    module
  27. I found out later that...

  28. There exists a dependency map💁 *NBHFCZIUUQTHJUIVCDPNFTMJOUFTMJOUCMPCNBJOEPDTTSDEFWFMPQFSHVJEFBSDIJUFDUVSFEFQFOEFODZTWH

  29. Knowledge 1: Overall design

  30. Unified format for writing each module📝

  31. Uni fi ed format for writing each module

  32. Uni fi ed format for writing each module

  33. util objects rich in methods📝

  34. w /PEFKTlVUJMzPCKFDU w MJCSVMFTVUJMTBTUVUJMT w MJCTIBSFETUSJOHVUJMT w MJCTIBSFETBTUVUJMT NFUIPET SFHHFYQBUUFSOT

     w MJCTPVSDFDPEFUPLFOTUPSFVUJMT the number of using methods
  35. Knowledge 2: Node.js’s “util” module is useful

  36. w VUJMJOTQFDU w VUJMGPSNBU w VUJMJOIFSJUT w VUJMMQSPNJTJGZ ˡ8IBUTVSQSJTFENFXBTUIJT Methods

    used by ESLint
  37. *NBHFCZIUUQTOPEFKTPSHBQJVUJMIUNM

  38. Knowledge 3: Generator functions in JavaScript

  39. Do you understand the following code?💁

  40. None
  41. None
  42. Let's take a look at some sample codes💁

  43. None
  44. None
  45. None
  46. more detail, show MDN👉

  47. An afterthought

  48. An afterthought w /PUXSJUUFOJOUZQFTDSJQU UZQFEF fi OJUJPOTBSFXSJUUFO  w "OZXBZ

    UIFEPDVNFOUBUJPOJTFYUFOTJWF w +4%PDJTXFMMEPDVNFOUFE BTJTNE w %PDVNFOUBUJPOJTVTJOH&MFWFOUZKT UZ  w 5PPMTGPS44( w %PDVNFOUBUJPOBQQJTFBTJFSUPWJFXUIBOUIFP ff i DJBMTJUF w 5IFSFBSFBMTPDPODFQUTPGMBZPVUBOEDPNQPOFOUT
  49. None
  50. None
  51. Thoughts💁

  52. Thoughts w 8FEPOUIBWFUPVOEFSTUBOEJUUPUBMZ👍 w %FTJHOJOHGBNPVTMJCSBSJFTJTBHSFBUMFBSOJOHFYQFSJFODF👍 w 8FDBOJNQSPWFNZTLJMMTGPSTVSF👍 w *GZPV fi

    OEJUEJ ff i DVMU ZPVDBOSFBEJUXJUITPNFPOFFMTF👍 w *GZPVIBWFUSPVCMF JU`THPPEUPSFBEGSPNUIFUFTUDPEF👍
  53. None