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)

3135a28c51dfa27396bb525e9972db95?s=128

kkeeth

May 21, 2022
Tweet

More Decks by kkeeth

Other Decks in Programming

Transcript

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

    'SPOUFOE&OHJOFFS-5 #FFS#BTI @kkeeth @kuwahara_jsri @kkeeth
  2. Who am I const my_info = { Name: ‘Kuwahara KEETH

    Kiyohito’, Company: ‘Yumemi Inc’, Position: ‘Servant Leader/Board’, Skills: ‘Riot.js/Next.js/Chit-chat’, }
  3. Published

  4. OQNKTDPNdLLFFUI

  5. 🙇 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!!
  6. Let’s start 😆

  7. one day in development 💁

  8. *NDPODFSOFEBCPVUUIFCFIBWJPS PGUIJTEFQFOEFOUMJCSBSZ🤔 *TOUUIBUBIVSEMFUPCFHJOXJUI  $BOZPVSFBMMZSFBEJU me my “inner voice” -FUTSFBEUIFDPEFPGUIJTMJCSBSZ

    me
  9. :FT CVU*EPOUVOEFSTUBOEXIBU UIJTMJCSBSZJTEPJOHBOE .BZCFZPVEPOUIBWFUIFUJNF  *TUIBUFTTFOUJBMMZXIBUZPVXBOUUP TPMWF me my “inner

    voice” *UEFQFOETPOUIFUIJOH CVU JOUFSJNTVQQPSUDBOCFBMJBCJMJUZ MBUFSPO me
  10. #VUFWFOJGZPVVOEFSTUBOEUIF TPVSDFDPEF XIBUEPZPVEPXJUI JU my “inner voice” *GJUTBCVH JUTCFTUUPDSFBUFBO JTTVFPS13

    me 8IFOEPZPVUIJOLUIBUXJMMCF SFTPMWFE %PZPVUIJOLJUXJMMCF EPOFPOUJNF my “inner voice”
  11. *GOPU UIFXPSTUUIBUDBOIBQQFOJT UIBUXFGPSLUIFSFQPTJUPSZBOE MPBEUIFDIBOHFT 8IPJTHPJOHUPNBJOUBJOJU 
 8IBUTUIFDPTU me my “inner

    voice” )NNN*HVFTTTP0LBZ MFUT KVTUBTTVNFUIBUTUIFEFTJHOJUT TVQQPTFEUPCF😅 me
  12. *GOPU UIFXPSTUUIBUDBOIBQQFOJT UIBUXFGPSLUIFSFQPTJUPSZBOE MPBEUIFDIBOHFT 8IPJTHPJOHUPNBJOUBJOJU 
 8IBUTUIFDPTU me my “inner

    voice” )NNN*HVFTTTP0LBZ MFUT KVTUBTTVNFUIBUTUIFEFTJHOJUT TVQQPTFEUPCF😅 me none of your business ʘ(^o^)ʗ
  13. I feel like I could learn more from reading codes

    😆
  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. Next, let’s look at “bin” dir.

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

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

  21. None
  22. “cli.js” depends on “ESLint” module “ESLint” module depends on “CLIEngine”

    module
  23. I found out later that...

  24. There exists a dependency map💁 *NBHFCZIUUQTHJUIVCDPNFTMJOUFTMJOUCMPCNBJOEPDTTSDEFWFMPQFSHVJEFBSDIJUFDUVSFEFQFOEFODZTWH

  25. Knowledge 1: Overall design

  26. Unified format for writing each module📝

  27. Uni fi ed format for writing each module

  28. Uni fi ed format for writing each module

  29. util objects rich in methods📝

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

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

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

    used by ESLint
  33. *NBHFCZIUUQTOPEFKTPSHBQJVUJMIUNM

  34. Knowledge 3: Generator functions in JavaScript

  35. Do you understand the following code?💁

  36. None
  37. Let's take a look at some sample codes💁

  38. None
  39. None
  40. None
  41. more detail, show MDN👉

  42. An afterthought

  43. 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
  44. None
  45. None
  46. Thoughts💁

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

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