Skip to content

Audit optimizations & Man page update#24

Merged
btopro merged 7 commits intohaxtheweb:mainfrom
zdodson21:main
Apr 3, 2026
Merged

Audit optimizations & Man page update#24
btopro merged 7 commits intohaxtheweb:mainfrom
zdodson21:main

Conversation

@zdodson21
Copy link
Copy Markdown
Contributor

It seems I make an appearance in this community every half year or so at this point and I needed a break from learning Android development for a brief moment. Here's some code optimizations to the audit.js and a small man page update.

Note: I didn't really test anything for noticeable speed improvements. Pretty much all optimizations make code easier to edit (such as for future updates to DDD), improving developer happiness and removing some public facing evidence of myself ever contributing what I now view as garbage code. Now it can hide in the commit history where it belongs. There are actual runtime optimizations though that should make things run faster if run on a large scale.

Manual Page

  • Now includes description for --force flag

auditFile()

  • Switched all property arrays to Sets, reducing search run time from O(n) to O(1)

helpAuditFontFamily()

  • This function will now check for the appropriate font family DDD variable using an array of key-value pair objects instead of if-else statements. This makes the following tasks easier:
    • Creating new DDD variables in the future
    • Expanding the list of font families that fall under a DDD variable.

helpAuditColors()

  • This function now uses an object instead of a multi-hundred line switch-case statement. CSS color is inputted, object is checked for that color index, if exists it will return the corresponding DDD variable, and will return the original “No available suggestions...” statement if no value corresponding to the index is found.
  • This format also makes it much more bearable to read through the list of values, and will make it easier to add to as well should the W3C add any new CSS color values in the future.

Other

  • Removed a pointless if-else statement from the dddignoreInterpreter() function. I honestly have no idea why I put it there a year ago. Seriously, it makes no sense why I wrote it that way:
let list = []

...

if (list.length !== 0) {
	return list;
} else { // Just return list? No need for an empty array if list is empty already lol.
	return [];
}
  • Fixed some issues I found in some branch statements. Mainly just a typo of & instead of && and switching some || to &&.

Before submitting this PR, I made sure I:

  • Followed the coding conventions
  • Added/updated tests for changes
  • Verified accessibility (Lighthouse score, Screen-Reader)
  • Updated documentation where necessary
  • Checked cross-browser compatibility

Ways to test

  1. Build and install locally using npm run local command.
  2. Run hax audit command on a web component, everything should work the same.

Console Output Screenshot

image

@zdodson21 zdodson21 requested a review from btopro as a code owner April 3, 2026 13:08
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

All contributors have signed the CLA. Thank you!
Posted by the CLA Assistant Lite bot.

@zdodson21
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@btopro btopro merged commit b7553bf into haxtheweb:main Apr 3, 2026
3 of 4 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2026
@btopro
Copy link
Copy Markdown
Member

btopro commented Apr 3, 2026

Thank you for your biannual commits. We use this tool in class and students often connect the dots of how to improve their projects to confirm to DDD as a result of this tool 🔥

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants