1.9 KiB
1.9 KiB
@hamview/packet project
This project implements low level packet parsing utilities and packet dissection.
Architecture
- Use
npmas dependency manager - Use Vitest for unit testing
Build & Commands
- Install deps:
npm install - Run tests:
npm test:ci - Run single test:
npm test:ci test/parser.test.ts
Code Style
- Spaces for indentation (2 spaces)
- Double quotes, semicolons, trailing commas
- Use descriptive variable/function names and methods
- Static functions that use strings, are called
fromString, if they use bytesfromBytes - Methods that convert to strings are called
toString, methods that convert to bytestoBytes - Functions prefer
const foo: <typespec> = (<args>) =>over barefunction foo - Don't use
anytype - Don't CamelCase abbreviations, so prefer
showSSIDovershowSsidandencodeKISSoverencodeKiss - Import convention:
- Remove unused imports
- Sort imports: external modules first, local last. Sort both modules and the imports alphabetically.
- Split multi imports over multiple lines if there are more than 3 imported with. One import statement per source module.
Testing
- Use Vitest for unit testing
- Test files:
test/*.test.ts - Per source file in
src/<name>.tsthere is a matchingtest/<name>test.ts - Tests are done for all classes and its methods and functions
- Tests are following this convention:
describe("Class.method", () => { ... }) - Tests are sorted alphabetically
- Test runners follow this convension:
it("returns <thing>", ...)andit("handles ...", ...), etc.
Git Workflow
- ALWAYS remove temporary and debug files before committing
- ALWAYS run
npm testbefore committing - NEVER use
git push --forceon the main branch - Use
git push --force-with-leasefor feature branches if needed - Use conventional commits style for git commit messages
- Use conventional commits style to describe Gitea PR titles