rohitdhas / shittier

Shittier is an unconventional code formatting tool

Home Page:https://www.npmjs.com/package/shittier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hoisting causing function case modification to fail

rohitdhas opened this issue · comments

In JavaScript, functions are hoisted, which means that even if a function is declared at the bottom of the file, it can still be accessed at the top. This hoisting behavior is causing an issue in Shittier, specifically when we search for function declarations to modify their case and make corresponding modifications wherever the function is called throughout the code.

The problem arises due to hoisting, as users can call the function even before it's defined explicitly in the code. As a result, the case modification process fails, and it breaks the code execution.

Expected Behavior:
The case modification process in Shittier should handle hoisting correctly, ensuring that the function's case is modified consistently throughout the codebase, regardless of whether the function is called before or after its declaration.

Steps to Reproduce:

  1. Declare a function at the bottom of the file in Shittier.
  2. Call the function before its declaration in the code.

Observed Behavior:
The function's case is not modified when it is called before its explicit declaration, leading to unexpected behavior and code execution errors.
image

Expected Behavior:
The function's case should be modified consistently throughout the codebase, regardless of the function's hoisting behavior.