-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable no unchecked index access rule #6441
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,10 +79,12 @@ const UserParentalControl = () => { | |
for (let i = 0, length = allParentalRatings.length; i < length; i++) { | ||
rating = allParentalRatings[i]; | ||
|
||
if (!rating) continue; | ||
|
||
if (ratings.length) { | ||
const lastRating = ratings[ratings.length - 1]; | ||
|
||
if (lastRating.Value === rating.Value) { | ||
if (lastRating && lastRating.Value === rating.Value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we have a rule to use an optional chain instead of |
||
lastRating.Name += '/' + rating.Name; | ||
continue; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,12 +29,15 @@ function playAllFromHere(opts: PlayAllFromHereOptions) { | |
let startIndex; | ||
|
||
for (let i = 0, length = items?.length; i < length; i++) { | ||
if (!items[i]) continue; | ||
|
||
if (items[i] === item) { | ||
foundCard = true; | ||
startIndex = i; | ||
} | ||
|
||
if (foundCard || !queue) { | ||
ids.push(items[i].Id); | ||
ids.push(items[i]?.Id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The optional chain is redundant - |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import type { MediaSegmentDto } from '@jellyfin/sdk/lib/generated-client/models/media-segment-dto'; | ||
|
||
const isBeforeSegment = (segment: MediaSegmentDto, time: number, direction: number) => { | ||
const isBeforeSegment = (segment: MediaSegmentDto | undefined, time: number, direction: number) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be better to force the caller to check that |
||
if (direction === -1) { | ||
return ( | ||
typeof segment.EndTicks !== 'undefined' | ||
typeof segment?.EndTicks !== 'undefined' | ||
&& segment.EndTicks <= time | ||
); | ||
} | ||
return ( | ||
typeof segment.StartTicks !== 'undefined' | ||
typeof segment?.StartTicks !== 'undefined' | ||
&& segment.StartTicks > time | ||
); | ||
}; | ||
|
||
export const isInSegment = (segment: MediaSegmentDto, time: number) => ( | ||
typeof segment.StartTicks !== 'undefined' | ||
export const isInSegment = (segment: MediaSegmentDto | undefined, time: number) => ( | ||
typeof segment?.StartTicks !== 'undefined' | ||
&& segment.StartTicks <= time | ||
&& (typeof segment.EndTicks === 'undefined' || segment.EndTicks > time) | ||
); | ||
|
@@ -26,7 +26,7 @@ export const findCurrentSegment = (segments: MediaSegmentDto[], time: number, la | |
} | ||
|
||
let direction = 1; | ||
if (lastIndex > 0 && lastSegment.StartTicks && lastSegment.StartTicks > time) { | ||
if (lastIndex > 0 && lastSegment?.StartTicks && lastSegment.StartTicks > time) { | ||
direction = -1; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,8 @@ function getPosition(positionTo: Element, options: Options, dlg: HTMLElement) { | |
|
||
const pos = getOffsets([positionTo])[0]; | ||
|
||
if (!pos) return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only case (with |
||
|
||
if (options.positionY !== 'top') { | ||
pos.top += (pos.height || 0) / 2; | ||
} | ||
|
@@ -250,6 +252,8 @@ export function show(options: Options) { | |
for (let i = 0; i < options.items.length; i++) { | ||
const item = options.items[i]; | ||
|
||
if (!item) continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can happen? |
||
|
||
if (item.divider) { | ||
html += '<div class="actionsheetDivider"></div>'; | ||
continue; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we even get
allParentalRatings
withnull|undefined
elements?I'm not a fan of checking everything (following some "pattern"), ignoring the fact that it will never happen. 🤷♂️ If this can happen, we silently ignore the invalid argument (the array with the invalid element), which can make it harder to find the error.