Thank you for considering contributing to the data-structures library! This document provides guidelines and steps for contributing.
Please read and follow our Code of Conduct to maintain a respectful and inclusive environment.
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/data-structures.git
- Install dependencies(currently we do not hav):
deno cache
- Create a new branch:
Branch naming convention:
- feat/your-feature-name: For feature branches
- fix/your-fix-name: For bugfix and hotfix branches
- release/release-name: For releasing features
git checkout -b feat/your-feature-name
-
Make your changes following our coding standards
-
Write/update tests for your changes
-
Run tests:
deno test
-
Update documentation:
- Update JSDoc comments
- Update relevant markdown files
- Update examples if needed
-
Test the linting, formatting and JSDOCs in case anything missed:
deno task verify
- Commit your changes:
git commit -m "feat: add your feature description"
Follow Conventional Commits
- Update the README.md with details of changes if needed
- Ensure all tests pass and coverage is maintained
- Update all relevant documentation
- Submit a pull request
- feat: Add new feature
- fix: Fix bug
- docs: Update documentation
- test: Add/update tests
- refactor: Code refactoring
- perf: Performance improvements
- Use TypeScript strict mode
- Provide type definitions for all parameters and return values
- Use generics where appropriate
- Follow functional programming principles where possible
- Use JSDoc for all public methods
- Include examples in documentation
- Document time complexities
- Keep documentation up to date
- Write unit tests for all new features
- Maintain test coverage above 85%
- Include edge cases in tests
- Use descriptive test names
Here's an example of a good pull request:
/**
* Reverses the linked list in-place
* Time complexity: O(n)
* Space complexity: O(1)
*/
reverse(): void {
if (this.size <= 1) return;
let prev = null;
let current = this.head;
this.tail = current;
while (current) {
const next = current.next;
current.next = prev;
prev = current;
current = next;
}
this.head = prev;
}
// Tests
Deno.test("LinkedList - reverse", () => {
const list = new LinkedList<number>();
list.append(1);
list.append(2);
list.append(3);
list.reverse();
assertEquals(list.toArray(), [3, 2, 1]);
assertEquals(list.head?.value, 3);
assertEquals(list.tail?.value, 1);
});