Skip to content

Commit 45ec91c

Browse files
authored
JS dependency updates (#275)
* update all deps * drop openssl patch * ignore generated license file * no return in finally * change node version * prettier * pare back deps * knip
1 parent 0aada26 commit 45ec91c

18 files changed

Lines changed: 2646 additions & 4462 deletions

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
3737
test-js:
3838
docker:
39-
- image: cimg/node:20.14
39+
- image: cimg/node:24.7
4040
steps:
4141
- checkout
4242
- run: node --version

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ node_modules
6262
webdiff/static/components
6363
webdiff/static/js/file_diff.js
6464
webdiff/static/js/file_diff.js.map
65+
webdiff/static/js/file_diff.js.LICENSE.txt
6566

6667
wheelhouse
6768
.vscode
6869
NOTES.md
70+

ts/CodeDiffContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function FileDiff(props: FileDiffProps) {
195195
if (contentsAfter && lengthOrZero(contentsAfter) > lengthOrZero(contentsBefore)) {
196196
byLength = [byLength[1], byLength[0]];
197197
}
198-
language = byLength[0] ? guessLanguageUsingContents(byLength[0]) ?? null : null;
198+
language = byLength[0] ? (guessLanguageUsingContents(byLength[0]) ?? null) : null;
199199
}
200200
return language;
201201
}, [contentsAfter, contentsBefore, numLines, path]);

ts/Root.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
2-
import {useNavigate, useParams} from 'react-router';
3-
import {useSearchParams} from 'react-router-dom';
2+
import {useNavigate, useParams, useSearchParams} from 'react-router';
43
import {FilePair} from './CodeDiffContainer';
54
import {DiffView, PerceptualDiffMode} from './DiffView';
65
import {FileSelector, FileSelectorMode} from './FileSelector';
@@ -34,7 +33,7 @@ export function Root() {
3433
(idx: number) => {
3534
const search = searchParams.toString();
3635
const url = `/${idx}` + (search ? `?${search}` : '');
37-
navigate(url);
36+
void navigate(url);
3837
},
3938
[navigate, searchParams],
4039
);

ts/codediff/DiffRow.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ const makeCodeTd = (type: string, text: string | undefined, html: string | undef
2828
if (text === undefined) {
2929
return {text: '', html: '', className: 'empty code'};
3030
}
31-
if (html === undefined) {
32-
html = escapeHtml(text);
33-
}
31+
html ??= escapeHtml(text);
3432
text = text.replaceAll('\t', '\u00a0\u00a0\u00a0\u00a0');
3533
html = html.replaceAll('\t', '\u00a0\u00a0\u00a0\u00a0');
3634
const className = 'code ' + type;

ts/codediff/__tests__/addcharacterdiffs_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function textToHtml(text: string) {
1818
function htmlToText(html: string) {
1919
const div = document.createElement('div');
2020
div.innerHTML = html;
21+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
2122
return div.textContent ?? '';
2223
}
2324

ts/codediff/__tests__/htmlsubstr_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {htmlTextMapper} from '../html-text-mapper';
44
function htmlToText(html: string) {
55
const div = document.createElement('div');
66
div.innerHTML = html;
7+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
78
return div.textContent ?? '';
89
}
910

ts/codediff/char-diffs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function strArrayLen(x: string[]) {
99
}
1010

1111
function allWhitespace(x: string) {
12-
return !!x.match(/^\s*$/);
12+
return !!/^\s*$/.exec(x);
1313
}
1414

1515
/**
@@ -114,10 +114,10 @@ export function splitIntoWords(line: string): string[] {
114114
WS = 4,
115115
SYM = 5;
116116
const charType = function (c: string) {
117-
if (c.match(/[a-z]/)) return LC;
118-
if (c.match(/[A-Z]/)) return UC;
119-
if (c.match(/[0-9]/)) return NUM;
120-
if (c.match(/\s/)) return WS;
117+
if (/[a-z]/.exec(c)) return LC;
118+
if (/[A-Z]/.exec(c)) return UC;
119+
if (/[0-9]/.exec(c)) return NUM;
120+
if (/\s/.exec(c)) return WS;
121121
return SYM;
122122
};
123123

ts/codediff/dom-utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export function copyOnlyMatching(e: ClipboardEvent, selector: string) {
7070
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7171
text = doc.textContent!;
7272
} else {
73+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
7374
text = [...nodes].map(n => n.textContent ?? '').join('\n');
7475
}
7576

@@ -84,5 +85,9 @@ interface WebkitElement extends Element {
8485
/** scrollIntoViewIfNeeded has nicer behavior than the web standard, but is non-standard. */
8586
export function scrollIntoViewIfNeeded(el: Element) {
8687
const wkEl = el as WebkitElement;
87-
wkEl.scrollIntoViewIfNeeded?.() ?? wkEl.scrollIntoView({block: 'nearest'});
88+
if (wkEl.scrollIntoViewIfNeeded) {
89+
wkEl.scrollIntoViewIfNeeded();
90+
} else {
91+
wkEl.scrollIntoView({block: 'nearest'});
92+
}
8893
}

ts/codediff/language.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function guessLanguageUsingFileName(name: string) {
1616

1717
// Highlighting based purely on file name, e.g. "Makefile".
1818
m = /(?:.*\/)?([^/]*)$/.exec(name);
19-
if (m && m[1] == 'Makefile') {
19+
if (m?.[1] == 'Makefile') {
2020
return 'makefile';
2121
}
2222
return null;

0 commit comments

Comments
 (0)