Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(scripts): overhaul #1262

Closed
wants to merge 3 commits into from
Closed

refactor(scripts): overhaul #1262

wants to merge 3 commits into from

Conversation

uncenter
Copy link
Member

@uncenter uncenter commented Sep 4, 2024

Often feels like an uphill battle trying to wrangle our scripts here. This PR aims to refactor and reorganize the scripts side of the codebase to a more understandable, readable point.

Goals/thoughts:

  • Prefer importing * as xyz instead of specific functions if said functions are vague - examples of this include @std/path and @std/yaml.
  • Prefer await over .then. Often the code here gets mangled into super nested and chained tangles "on a single line", .then is a big part of this issue.
  • Sort imports semantically. This might be more opinionated but I have found that putting constants and type imports at the top of the file, with a line of separation between those and the more use(d, ful) functions is helpful when reading through to parse what is being imported.
  • Root level functions should use the function keyword declaration syntax rather than the arrow function syntax. I find this makes code more readable as you can more easily locate functions and distinguish them from actual variables/constants.
  • WETT should be one of the larger principles at work here: write everything three times. If we are repeating code 3+ times, abstract it into a function to make updates to that logic easier across the whole catalog of scripts!
  • As part of the last one, I've moved the utilities into a new utils/ folder, rather than the previous clump in utils.ts.

@uncenter uncenter mentioned this pull request Oct 5, 2024
22 tasks
@uncenter uncenter closed this Oct 24, 2024
@uncenter uncenter deleted the refactor/scripts-overhaul branch October 27, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant