Commit 756209e
authored
fix, test, chore: runtime bug fixes, Vitest migration, and ESLint v10 upgrade (#219)
## Bug Fixes
- **Missing `await` on email send** (`src/main.ts`) —
`sendAlertsToEmailSmtp()` was fire-and-forget, silently dropping email
failures
- **Unsafe `alerts[0]` access** (`slack.ts`, `microsoft-teams.ts`,
`zenduty.ts`) — added early return guard in each destination so they are
safe to call independently
- **Unsafe `references[0]` access** (`src/entities/advisory.ts`) —
replaced with optional chaining (`references?.[0]?.url ?? ''`) to handle
advisories with no references
- **No HTTP error handling** (`src/utils/request/index.ts`) — fetch
wrapper now throws on non-OK responses, surfacing 4xx/5xx failures
instead of silently succeeding
- **`parseInt` missing radix** (`src/main.ts`) — added `, 10` to both
calls to prevent potential octal interpretation
- **Floating promise** (`src/main.ts`) — added `void` to the top-level
`run()` call to satisfy `no-floating-promises`
## Test Coverage
- Migrated from Jest + ts-jest to **Vitest** (`jest.config.js` removed,
`vitest.config.ts` added, `test` script updated)
- Added tests for all previously untested modules:
- `src/entities/` — `toAdvisory`, `toVulnerability`,
`toRepositoryAlert`, `toOrgAlert`, `toEnterpriseAlert`,
`getFullRepositoryNameFromAlert`
- `src/fetch-alerts.ts` — repo, org, and enterprise alert fetching,
ecosystem filtering, count passthrough
- `src/destinations/` — Slack (including `validateSlackWebhookUrl`),
PagerDuty, Zenduty, Email
- Mock data in entity and fetch-alert tests typed with
`DependabotAlert`, `DependabotOrgAlert`, `DependabotEnterpriseAlert`
from `@octokit/types` — no `as any`
- Test files moved to a top-level `tests/` directory mirroring `src/`
structure to keep source files uncluttered
## ESLint Upgrade
- Upgraded `@kunalnagarco/eslint-config` from v2.2.0 to v3.0.5
- Upgraded ESLint from v8 to v10 with flat config format
(`eslint.config.mjs`)
- Removed: `@typescript-eslint/eslint-plugin`,
`@typescript-eslint/parser`, `eslint-config-airbnb`,
`eslint-config-airbnb-typescript`, `eslint-plugin-import`,
`eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `.eslintrc`,
`.eslintignore`
- Added: `@eslint/js`, `typescript-eslint`, `eslint-plugin-import-x`,
`eslint-import-resolver-typescript`
## Test plan
- [x] `yarn test` — all 48 tests pass
- [x] `yarn build` — TypeScript compiles cleanly
- [x] `yarn lint` — no lint errors
- [ ] Trigger the action with an SMTP destination and verify email
failures surface as action failures
- [ ] Trigger against a repo with no open alerts and confirm no crash on
`alerts[0]`1 parent e8db247 commit 756209e
23 files changed
Lines changed: 2434 additions & 4750 deletions
File tree
- src
- destinations
- entities
- utils/request
- tests
- destinations
- entities
- utils/request
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | 68 | | |
71 | 69 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 70 | + | |
75 | 71 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
80 | 75 | | |
81 | | - | |
82 | 76 | | |
83 | 77 | | |
84 | 78 | | |
85 | 79 | | |
86 | 80 | | |
87 | | - | |
88 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
89 | 84 | | |
90 | 85 | | |
91 | 86 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
| 130 | + | |
0 commit comments