Skip to content

Commit d4941d8

Browse files
authored
Update dependencies (#192)
1 parent 0bb2aad commit d4941d8

File tree

7 files changed

+2834
-3079
lines changed

7 files changed

+2834
-3079
lines changed

.github/workflows/ci.yml

+15-22
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
env: {}
2-
3-
# FILE GENERATED WITH: npx ghat fregante/ghatemplates/node
4-
# SOURCE: https://github.com/fregante/ghatemplates
5-
61
name: CI
72

83
on:
@@ -13,30 +8,28 @@ jobs:
138
Lint:
149
runs-on: ubuntu-latest
1510
steps:
16-
- uses: actions/checkout@v3
17-
- name: install
18-
run: npm ci || npm install
19-
- name: XO
20-
run: npx xo
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version-file: package.json
15+
- run: npm ci
16+
- run: npx xo
2117

2218
Test:
2319
runs-on: ubuntu-latest
2420
steps:
25-
- uses: actions/checkout@v3
26-
- name: install
27-
run: npm ci || npm install
28-
- name: build
29-
run: npm run build --if-present
30-
- name: Test
31-
run: npm run test:unit
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version-file: package.json
25+
- run: npm ci
26+
- run: npm run test:unit
3227

3328
Build:
3429
runs-on: ubuntu-latest
3530
steps:
36-
- uses: actions/checkout@v3
37-
- name: install
38-
run: npm ci || npm install
39-
- name: build
40-
run: npm run build
31+
- uses: actions/checkout@v4
32+
- run: npm ci
33+
- run: npm run build
4134
- name: Ensure that test URLs aren't included in the built file
4235
run: '! grep http distribution/index.js'

collector.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
export const testableUrls = new Map<string, string[]>();
44

55
export function addTests(test: string, urls: string[]): void {
6+
// eslint-disable-next-line n/prefer-global/process -- Better not import `process` to avoid bundling its polyfills by mistake
67
if (process.env.NODE_ENV !== 'bundling') {
78
testableUrls.set(test, urls);
89
}

global.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Broaden types because testing against `"undefined"` is fine for our regexes
2+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- Module augmentation
3+
interface RegExp {
4+
test(s: string | undefined): boolean;
5+
}

index.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import reservedNames from 'github-reserved-names/reserved-names.json' assert {type: 'json'};
1+
import reservedNames from 'github-reserved-names/reserved-names.json' with {type: 'json'};
22
import {addTests} from './collector.js';
33

44
const $ = <E extends Element>(selector: string) => document.querySelector<E>(selector);
@@ -130,7 +130,7 @@ addTests('isGlobalSearchResults', [
130130
'https://github.com/search?q=refined-github&ref=opensearch',
131131
]);
132132

133-
export const isIssue = (url: URL | HTMLAnchorElement | Location = location): boolean => /^issues\/\d+/.test(getRepo(url)?.path!) && document.title !== 'GitHub · Where software is built'; // The title check excludes deleted issues
133+
export const isIssue = (url: URL | HTMLAnchorElement | Location = location): boolean => /^issues\/\d+/.test(getRepo(url)?.path) && document.title !== 'GitHub · Where software is built'; // The title check excludes deleted issues
134134
addTests('isIssue', [
135135
'https://github.com/sindresorhus/refined-github/issues/146',
136136
]);
@@ -150,7 +150,7 @@ addTests('isLabelList', [
150150
'https://github.com/sindresorhus/refined-github/labels/',
151151
]);
152152

153-
export const isMilestone = (url: URL | HTMLAnchorElement | Location = location): boolean => /^milestone\/\d+/.test(getRepo(url)?.path!);
153+
export const isMilestone = (url: URL | HTMLAnchorElement | Location = location): boolean => /^milestone\/\d+/.test(getRepo(url)?.path);
154154
addTests('isMilestone', [
155155
'https://github.com/kubernetes/kubernetes/milestone/56',
156156
]);
@@ -201,7 +201,7 @@ export const isOwnUserProfile = (): boolean => getCleanPathname() === getUsernam
201201
// If there's a Report Abuse link, we're not part of the org
202202
export const isOwnOrganizationProfile = (): boolean => isOrganizationProfile() && !exists('[href*="contact/report-abuse?report="]');
203203

204-
export const isProject = (url: URL | HTMLAnchorElement | Location = location): boolean => /^projects\/\d+/.test(getRepo(url)?.path!);
204+
export const isProject = (url: URL | HTMLAnchorElement | Location = location): boolean => /^projects\/\d+/.test(getRepo(url)?.path);
205205
addTests('isProject', [
206206
'https://github.com/sindresorhus/refined-github/projects/3',
207207
]);
@@ -211,7 +211,7 @@ addTests('isProjects', [
211211
'https://github.com/sindresorhus/refined-github/projects',
212212
]);
213213

214-
export const isDiscussion = (url: URL | HTMLAnchorElement | Location = location): boolean => /^discussions\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path!);
214+
export const isDiscussion = (url: URL | HTMLAnchorElement | Location = location): boolean => /^discussions\/\d+/.test(getRepo(url)?.path ?? getOrg(url)?.path);
215215
addTests('isDiscussion', [
216216
'https://github.com/tophf/mpiv/discussions/50',
217217
'https://github.com/orgs/community/discussions/11202',
@@ -229,14 +229,14 @@ addTests('isDiscussionList', [
229229
'https://github.com/orgs/community/discussions',
230230
]);
231231

232-
export const isPR = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+/.test(getRepo(url)?.path!) && !isPRConflicts(url);
232+
export const isPR = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+/.test(getRepo(url)?.path) && !isPRConflicts(url);
233233
addTests('isPR', [
234234
'isPRFiles',
235235
'isPRCommitList',
236236
'https://github.com/sindresorhus/refined-github/pull/148',
237237
]);
238238

239-
export const isPRConflicts = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path!);
239+
export const isPRConflicts = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path);
240240
addTests('isPRConflicts', [
241241
'https://github.com/sindresorhus/refined-github/pull/148/conflicts',
242242
]);
@@ -252,7 +252,7 @@ addTests('isPRList', [
252252
'https://github.com/sindresorhus/refined-github/pulls?q=is%3Apr+is%3Aclosed',
253253
]);
254254

255-
export const isPRCommit = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(getRepo(url)?.path!);
255+
export const isPRCommit = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/commits\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
256256
addTests('isPRCommit', [
257257
'https://github.com/sindresorhus/refined-github/pull/148/commits/0019603b83bd97c2f7ef240969f49e6126c5ec85',
258258
'https://github.com/sindresorhus/refined-github/pull/148/commits/00196',
@@ -261,17 +261,17 @@ addTests('isPRCommit', [
261261
export const isPRCommit404 = (): boolean => isPRCommit() && document.title.startsWith('Commit range not found · Pull Request');
262262
export const isPRFile404 = (): boolean => isPRFiles() && document.title.startsWith('Commit range not found · Pull Request');
263263

264-
export const isPRConversation = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+$/.test(getRepo(url)?.path!);
264+
export const isPRConversation = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+$/.test(getRepo(url)?.path);
265265
addTests('isPRConversation', [
266266
'https://github.com/sindresorhus/refined-github/pull/148',
267267
]);
268268

269-
export const isPRCommitList = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/commits$/.test(getRepo(url)?.path!);
269+
export const isPRCommitList = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/commits$/.test(getRepo(url)?.path);
270270
addTests('isPRCommitList', [
271271
'https://github.com/sindresorhus/refined-github/pull/148/commits',
272272
]);
273273

274-
export const isPRFiles = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/files/.test(getRepo(url)?.path!) || isPRCommit(url);
274+
export const isPRFiles = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/files/.test(getRepo(url)?.path) || isPRCommit(url);
275275
addTests('isPRFiles', [
276276
'isPRCommit', // File contents but lacks "Viewed" checkbox, has commit information
277277
'https://github.com/sindresorhus/refined-github/pull/148/files',
@@ -378,7 +378,7 @@ export const isArchivedRepo = (): boolean => Boolean(isRepo() && $('main > .flas
378378

379379
export const isBlank = (): boolean => exists('main .blankslate:not([hidden] .blankslate)');
380380

381-
export const isRepoTaxonomyIssueOrPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path!);
381+
export const isRepoTaxonomyIssueOrPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => /^labels\/.+|^milestones\/\d+(?!\/edit)/.test(getRepo(url)?.path);
382382
addTests('isRepoTaxonomyIssueOrPRList', [
383383
'https://github.com/sindresorhus/refined-github/labels/bug',
384384
'https://github.com/sindresorhus/refined-github/labels/implemented%20by%20github',
@@ -402,7 +402,7 @@ addTests('isRepoPRList', [
402402

403403
export const isRepoIssueList = (url: URL | HTMLAnchorElement | Location = location): boolean =>
404404
// `issues/fregante` is a list but `issues/1`, `issues/new`, `issues/new/choose`, `issues/templates/edit` aren’t
405-
/^labels\/|^issues(?!\/(\d+|new|templates)($|\/))/.test(getRepo(url)?.path!);
405+
/^labels\/|^issues(?!\/(\d+|new|templates)($|\/))/.test(getRepo(url)?.path);
406406
addTests('isRepoIssueList', [
407407
'http://github.com/sindresorhus/ava/issues',
408408
'https://github.com/sindresorhus/refined-github/issues',
@@ -513,7 +513,7 @@ addTests('isRepoWiki', [
513513
'https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d',
514514
]);
515515

516-
export const isSingleCommit = (url: URL | HTMLAnchorElement | Location = location): boolean => /^commit\/[\da-f]{5,40}$/.test(getRepo(url)?.path!);
516+
export const isSingleCommit = (url: URL | HTMLAnchorElement | Location = location): boolean => /^commit\/[\da-f]{5,40}$/.test(getRepo(url)?.path);
517517
addTests('isSingleCommit', [
518518
'https://github.com/sindresorhus/refined-github/commit/5b614b9035f2035b839f48b4db7bd5c3298d526f',
519519
'https://github.com/sindresorhus/refined-github/commit/5b614',
@@ -549,14 +549,14 @@ addTests('isRepoNetworkGraph', [
549549

550550
export const isForkedRepo = (): boolean => exists('meta[name="octolytics-dimension-repository_is_fork"][content="true"]');
551551

552-
export const isSingleGist = (url: URL | HTMLAnchorElement | Location = location): boolean => /^[^/]+\/[\da-f]{20,32}(\/[\da-f]{40})?$/.test(getCleanGistPathname(url)!);
552+
export const isSingleGist = (url: URL | HTMLAnchorElement | Location = location): boolean => /^[^/]+\/[\da-f]{20,32}(\/[\da-f]{40})?$/.test(getCleanGistPathname(url));
553553
addTests('isSingleGist', [
554554
'https://gist.github.com/fregante/2205329b71218fa2c1d3',
555555
'https://gist.github.com/fregante/2205329b71218fa2c1d3/d1ebf7d9cfaba4d4596d2ea9174e202479a5f9ad',
556556
'https://gist.github.com/sindresorhus/0ea3c2845718a0a0f0beb579ff14f064',
557557
]);
558558

559-
export const isGistRevision = (url: URL | HTMLAnchorElement | Location = location): boolean => /^[^/]+\/[\da-f]{20,32}\/revisions$/.test(getCleanGistPathname(url)!);
559+
export const isGistRevision = (url: URL | HTMLAnchorElement | Location = location): boolean => /^[^/]+\/[\da-f]{20,32}\/revisions$/.test(getCleanGistPathname(url));
560560
addTests('isGistRevision', [
561561
'https://gist.github.com/kidonng/0d16c7f17045f486751fad1b602204a0/revisions',
562562
]);
@@ -713,7 +713,7 @@ addTests('isActionJobRun', [
713713
'https://github.com/refined-github/github-url-detection/runs/1224552520?check_suite_focus=true',
714714
]);
715715

716-
export const isActionRun = (url: URL | HTMLAnchorElement | Location = location): boolean => /^(actions\/)?runs/.test(getRepo(url)?.path!);
716+
export const isActionRun = (url: URL | HTMLAnchorElement | Location = location): boolean => /^(actions\/)?runs/.test(getRepo(url)?.path);
717717
addTests('isActionRun', [
718718
'https://github.com/sindresorhus/refined-github/runs/639481849',
719719
'https://github.com/refined-github/github-url-detection/runs/1224552520?check_suite_focus=true',
@@ -725,7 +725,7 @@ addTests('isNewAction', [
725725
'https://github.com/sindresorhus/refined-github/actions/new',
726726
]);
727727

728-
export const isRepositoryActions = (url: URL | HTMLAnchorElement | Location = location): boolean => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path!);
728+
export const isRepositoryActions = (url: URL | HTMLAnchorElement | Location = location): boolean => /^actions(\/workflows\/.+\.ya?ml)?$/.test(getRepo(url)?.path);
729729
addTests('isRepositoryActions', [
730730
'https://github.com/refined-github/github-url-detection/actions',
731731
'https://github.com/refined-github/github-url-detection/actions/workflows/demo.yml',
@@ -749,7 +749,7 @@ addTests('isNewRepoTemplate', [
749749
]);
750750

751751
/** Get the logged-in user’s username */
752-
const getUsername = (): string | undefined => $('meta[name="user-login"]')?.getAttribute('content')!;
752+
const getUsername = (): string | undefined => $('meta[name="user-login"]')?.getAttribute('content') ?? undefined;
753753

754754
/** Drop all duplicate slashes */
755755
const getCleanPathname = (url: URL | HTMLAnchorElement | Location = location): string => url.pathname.replaceAll(/\/+/g, '/').slice(1, url.pathname.endsWith('/') ? -1 : undefined);

0 commit comments

Comments
 (0)