|
1 | | -# Contributing to @hamdymohamedak/openfetch |
| 1 | +# Contributing on GitHub |
2 | 2 |
|
3 | | -Thank you for taking the time to improve this project. The following guidelines keep reviews predictable and the package stable across runtimes. |
| 3 | +This document describes how to participate in **@hamdymohamedak/openfetch** through GitHub: issues, discussions, and pull requests. |
4 | 4 |
|
5 | | -## Ground rules |
| 5 | +## What we look for in changes |
| 6 | + |
| 7 | +These rules keep reviews predictable and the library safe across runtimes: |
6 | 8 |
|
7 | 9 | 1. **Stay on `fetch`.** Do not add XMLHttpRequest, alternate fetch shims as required dependencies, or polyfills that assume a browser. |
8 | 10 | 2. **Avoid browser-only globals.** Do not reference `window`, `document`, `localStorage`, `sessionStorage`, `WebSocket`, or `EventSource` in library code. |
9 | 11 | 3. **Keep the public API small.** Prefer new behavior as optional middleware or clearly documented config rather than breaking existing callers. |
10 | | -4. **TypeScript source of truth.** All implementation lives under `src/`; `dist/` is compiled output from `npm run build`. |
11 | | - |
12 | | -## How to contribute |
| 12 | +4. **TypeScript source of truth.** Implementation lives under `src/`; `dist/` is build output from `npm run build`. |
13 | 13 |
|
14 | | -### Reporting issues |
| 14 | +## Reporting issues |
15 | 15 |
|
16 | | -Open an issue with: |
| 16 | +[Open an issue](https://github.com/openfetch-js/OpenFetch/issues) on this repository with: |
17 | 17 |
|
18 | 18 | - Runtime and version (Node, Bun, Deno, worker, browser). |
19 | 19 | - Minimal code sample and expected vs actual behavior. |
20 | 20 | - If relevant, the target URL shape (without secrets). |
21 | 21 |
|
22 | | -### Suggesting features |
| 22 | +## Suggesting features |
23 | 23 |
|
24 | | -Describe the use case and whether it can live in userland (middleware) vs core. Large features should be discussed in an issue before a heavy pull request. |
| 24 | +Open an issue first. Describe the use case and whether it can live in userland (middleware) vs core. Large features should be agreed in an issue before a large pull request. |
25 | 25 |
|
26 | | -### Pull requests |
| 26 | +## Pull requests |
27 | 27 |
|
28 | | -#### Branch naming |
| 28 | +### Branch naming |
29 | 29 |
|
30 | | -Use **one branch per concern**: a single feature **or** a single bug fix, not unrelated changes in the same branch. |
| 30 | +Use **one branch per concern**: one feature **or** one bug fix, not unrelated changes together. |
31 | 31 |
|
32 | | -- **Features:** `features/<short-description>` — for example `features/add-retry`, `features/cache-key-override`. |
33 | | -- **Bug fixes:** `bugs/<short-description>` — for example `bugs/timeout-signal`, `bugs/cache-key-collision`. |
| 32 | +- **Features:** `features/<short-description>` — e.g. `features/add-retry`, `features/cache-key-override`. |
| 33 | +- **Bug fixes:** `bugs/<short-description>` — e.g. `bugs/timeout-signal`, `bugs/cache-key-collision`. |
34 | 34 |
|
35 | 35 | Use **kebab-case** after the prefix. Keep the slug short but specific enough that reviewers can tell what the branch is for. |
36 | 36 |
|
37 | | -1. **Fork** the repository and create a branch from `main` following the [branch naming](#branch-naming) rules above. |
38 | | -2. **Implement** your change in `src/`. Match existing formatting and naming. |
39 | | -3. **Build** locally: `npm run build` (must pass with no TypeScript errors). |
| 37 | +### Workflow |
| 38 | + |
| 39 | +1. **Fork** this repository and create a branch from `main` using the [branch naming](#branch-naming) rules above. |
| 40 | +2. **Implement** in `src/`. Match existing formatting and naming. |
| 41 | +3. **Build** locally: `npm run build` (no TypeScript errors). |
40 | 42 | 4. **Document** user-visible behavior in `README.md` and, if structural, in `docs/PROJECT_FLOW.md`. |
41 | | -5. **Open a PR** into `main` with: |
| 43 | +5. **Open a pull request** into `main` with: |
42 | 44 | - A clear title and description. |
43 | | - - What changed and why (motivation). |
| 45 | + - What changed and why. |
44 | 46 | - Any breaking changes called out explicitly. |
45 | 47 |
|
46 | | -### Commit messages |
47 | | - |
48 | | -Use short, imperative subjects (for example `Add cache key override option`). Optional body for context. Consistent history helps maintainers and consumers. |
49 | | - |
50 | | -### Code review |
51 | | - |
52 | | -Maintainers may request tests, naming tweaks, or doc updates. Keeping changes scoped to one concern per PR speeds up merge. |
| 48 | +### Before you push |
53 | 49 |
|
54 | | -## Local development |
| 50 | +From a clone of your fork: |
55 | 51 |
|
56 | 52 | ```bash |
57 | 53 | npm install |
58 | 54 | npm run build |
59 | 55 | npm run test:security |
60 | 56 | ``` |
61 | 57 |
|
62 | | -`npm run test:security` runs the checks under `security-tests/`. `tsc` remains the compile gate for every change. |
| 58 | +`npm run test:security` runs `security-tests/`. The TypeScript compile step is the gate for every change. |
63 | 59 |
|
64 | | -## Publishing |
65 | | - |
66 | | -Publishing to npm is reserved for maintainers after version bump and changelog review. Consumers should install from the registry or from a tagged release, not from unreviewed branches. |
67 | | - |
68 | | -npm **requires two-factor authentication** (or a granular access token with publish rights) for `npm publish`. Logging in with the browser (`npm login`) is not enough by itself. |
| 60 | +### Commit messages |
69 | 61 |
|
70 | | -1. On [npmjs.com](https://www.npmjs.com/) go to **Account → Two-Factor Authentication** and enable **Authorization and writes** (authenticator app recommended). |
71 | | -2. From the package root: |
| 62 | +Use short, imperative subjects (e.g. `Add cache key override option`). Add a body when extra context helps reviewers reading the PR on GitHub. |
72 | 63 |
|
73 | | -```bash |
74 | | -npm publish --access public --otp=123456 |
75 | | -``` |
76 | | - |
77 | | -Use the current 6-digit code from your authenticator app. Do not commit or share OTPs. |
| 64 | +### Code review |
78 | 65 |
|
79 | | -**Alternative:** create a **Granular Access Token** at npm with permission to publish this package (and “bypass 2FA” only if your org policy allows it), then configure npm to use that token for `registry.npmjs.org`. |
| 66 | +Maintainers may ask for tests, naming tweaks, or doc updates on the PR. Smaller, single-concern PRs are easier to review and merge. |
80 | 67 |
|
81 | 68 | ## Code of conduct |
82 | 69 |
|
|
0 commit comments