How Webpack, ESLint, TypeScript, Babel, and others can generate code for you in a very clever way 💥🥳
I've been doing crazy experiments and teaching it on my Youtube channel and I will release an ESLint Clone next week 🫢
It's been pretty fun to work on this kind of thing 🤯
Recreating technologies and tools that we've been using forever can help you not only understand but troubleshoot problems that those tools throw at us.
I've already recreated:
- Node.js project from Scratch (Libuv V8 C )
- UglifyJS: minifying code and generating source maps using Abstract Syntax Tree
- Implemented Web Sockets with no libraries (binary data and crazy stuff)
- And more to come!
Now is the time to recreate ESLint from Scratch 🔥
For my ESLint version, I wanted to not only check for missing semicolons or replace double quotes with single quotes.
I wanted to inform the user where to use "const" or "let" declarations and replace "var" with either "const" or "let" declarations 👀
This is not a simple task because a "const" cannot be reassigned like:
const test = { name: 'test' }
test = { name: 'aaa' }
However, you can change its value like:
test.name = 'aaa'
That's how the game turned out interesting 💥
I used a tool to parse the JavaScript string code into a tree object that returns all changes and stages the language does to interpret a JavaScript code.
I had to make sure that a variable that was not reassigned and/or had its value changed would be replaced by "const" and reassignments turn into "let" declarations
Yes, my friend! Analyzing the whole JavaScript syntax to make those decisions 😜
I've spent a least 2 days working on this to finally make it work and next week you'd check it out on my youtube channel 👽
If you wanna go further, I've used the same principles to minify code and reverse engineer it to generate source maps while recreating UglifyJS 👻
Give it a shot and watch it before I release the ESLint Clone there 🔥
🔗
bit.ly/creating-your-own-ugl…
How about you, what'd you wish I recreate/reimplement from scratch on my channel?
#nodejs #eslint #advancedjavascript #js #webdev #websecrets #100daysofcode @geteslint #uglifyjs