j0sephh123 / code-transform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Goal

Learn how to traverse and transform AST.

Tools

Exercises

Certainly. Given your interest in improving as a developer, working with Abstract Syntax Trees (AST) could offer valuable insights into language parsing and code manipulation.

Exercise: Create a Code Linter for Detecting Unused Variables

project - libs/demo/src/unusedVars

Objective:

Develop a basic code linter that analyzes a JavaScript source file to identify and report any unused variables.

Requirements:

  1. Parse the JavaScript source code into an Abstract Syntax Tree.
  2. Traverse the AST to identify variable declarations.
  3. Track references to each declared variable.
  4. Identify variables that are declared but not used.
  5. Generate a report listing the unused variables along with their line numbers.

About


Languages

Language:TypeScript 95.1%Language:HTML 2.1%Language:JavaScript 1.7%Language:CSS 1.0%