Skip to content

Commit

Permalink
Merge pull request #1254 from Arnei/eslint-no-non-null-assertion
Browse files Browse the repository at this point in the history
Enforce eslint no-non-null-assertion
  • Loading branch information
Arnei authored Jan 18, 2024
2 parents 5bd6c19 + ccfae04 commit 546e3e8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ module.exports = {
// same line as `{`.
"brace-style": "off",

// A few of those are used.
"@typescript-eslint/no-non-null-assertion": "off",

// Until we figure out how to get to React 18
"react/no-deprecated": "off",
},
Expand Down
2 changes: 1 addition & 1 deletion src/main/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const LanguageButton: React.FC = () => {
checked: isCurrentLanguage(lng.value),
children: <>{lng.label}</>,
onClick: () => {
changeLanguage(lng!.value);
changeLanguage(lng?.value);
},
}));

Expand Down
2 changes: 1 addition & 1 deletion src/main/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const ThemedTooltip = ({ className, ...props }: TooltipProps) => {
getBoundingClientRect: () => {
return new DOMRect(
positionRef.current.x,
areaRef.current!.getBoundingClientRect().y,
areaRef.current?.getBoundingClientRect().y,
0,
positionRef.current.y,
);
Expand Down
8 changes: 8 additions & 0 deletions src/main/VideoPlayers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,23 +306,31 @@ export const VideoPlayer = React.forwardRef(
// eslint-disable-next-line array-callback-return
playerConfig.file.tracks.map((t, trackIdx) => {
const track = document.createElement('track');
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
track.kind = t.kind!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
track.label = t.label!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
track.srclang = t.srcLang!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
track.default = t.default!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
track.src = t.src!;
track.track.mode = 'showing' // Because the load callback may sometimes not execute properly
track.addEventListener('error', (_e: Event) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
console.warn(`Cannot load track ${t.src!}`)
});
track.addEventListener('load', (e: Event) => {
const textTrack = e.currentTarget as HTMLTrackElement;
if (textTrack) {
if (t.default === true) {
textTrack.track.mode = 'showing';
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
video!.textTracks[trackIdx].mode = 'showing'; // thanks Firefox
} else {
textTrack.track.mode = 'hidden';
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
video!.textTracks[trackIdx].mode = 'hidden'; // thanks Firefox
}
}
Expand Down

0 comments on commit 546e3e8

Please sign in to comment.