Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThe changes in this pull request involve enhancements to error handling and data validation in the Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
src/components/SnippetDetail.tsx
Outdated
|
|
||
| const { data: snippet, isLoading } = useSnippet(snippetId || '', language) | ||
| const sourceLanguage = snippet?.language.primary_language.toLowerCase() | ||
| const { data: snippet, isLoading, error } = useSnippet(snippetId || '', language) |
src/utils/getSnippetSubtitle.tsx
Outdated
| snippet.audio_file.location_state, | ||
| format(new Date(snippet.recorded_at), 'MMM d, yyyy HH:mm zzz') | ||
| ].filter(Boolean) | ||
| if (!snippet) { |
There was a problem hiding this comment.
Is !snippet correct here?
| @@ -3,37 +3,46 @@ import { getPoliticalLabel } from './getPoliticalLabel' | |||
| import { ConfidenceChart } from '@/components/ui/ConfidenceScoreBar' | |||
|
|
|||
| export function getSnippetSubtitle(snippet: any): JSX.Element { | |||
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (3)
src/utils/getSnippetSubtitle.tsx (2)
10-10: Enhance error handling with more descriptive logging.While the error handling is good, consider including more context in the error message and returning null instead of an empty fragment.
try { // ... existing code ... } catch (error) { - console.error('Error in getSnippetSubtitle:', error) - return <></> + console.error('Error in getSnippetSubtitle:', { + error, + snippetId: snippet?.id, + audioFile: snippet?.audio_file + }); + return null; }Also applies to: 44-47
18-27: Simplify score check and extract color mapping logic.The score check can be simplified, and the color mapping logic should be extracted for better maintainability.
- const score = snippet?.political_leaning?.score - const label = score !== null && score !== undefined ? getPoliticalLabel(score) : '' + const score = snippet?.political_leaning?.score ?? null + const label = score !== null ? getPoliticalLabel(score) : '' + const getLabelColorClass = (label: string): string => { + switch (label) { + case 'Center': return 'text-purple-600' + case 'Left': + case 'Center Left': return 'text-blue-400' + case 'Right': + case 'Center Right': return 'text-red-500' + default: return '' + } + } - const labelColorClass = (() => { - if (label === 'Center') return 'text-purple-600' - if (label === 'Left' || label === 'Center Left') return 'text-blue-400' - if (label === 'Right' || label === 'Center Right') return 'text-red-500' - return '' - })() + const labelColorClass = getLabelColorClass(label)🧰 Tools
🪛 eslint
[error] 18-18: Unsafe assignment of an
anyvalue.(@typescript-eslint/no-unsafe-assignment)
[error] 18-18: Unsafe member access .political_leaning on an
anyvalue.(@typescript-eslint/no-unsafe-member-access)
[error] 19-19: Unsafe argument of type
anyassigned to a parameter of typenumber.(@typescript-eslint/no-unsafe-argument)
src/components/SnippetDetail.tsx (1)
Line range hint
137-153: LGTM! Comprehensive error handling implementation.The error handling is well-implemented with:
- Multiple validation checks (error, empty snippet, missing ID)
- User-friendly error message with translation support
- Clear navigation option
Consider extracting the error UI into a separate component for reusability:
type ErrorViewProps = { title: string; description: string; onBack: () => void; backText: string; }; const ErrorView: FC<ErrorViewProps> = ({ title, description, onBack, backText }) => ( <div className='flex h-screen items-center justify-center'> <div className='text-center'> <h2 className='mb-2 text-2xl font-bold text-gray-700'>{title}</h2> <p className='text-gray-500'>{description}</p> <Button variant='ghost' className='mt-4' onClick={onBack}> {backText} </Button> </div> </div> );🧰 Tools
🪛 eslint
[error] 137-137: Unsafe call of an
anytyped value.(@typescript-eslint/no-unsafe-call)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/components/SnippetDetail.tsx(7 hunks)src/utils/getSnippetSubtitle.tsx(1 hunks)
🧰 Additional context used
🪛 eslint
src/components/SnippetDetail.tsx
[error] 39-39: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 39-39: Unsafe argument of type any assigned to a parameter of type string.
(@typescript-eslint/no-unsafe-argument)
[error] 39-39: Unsafe argument of type any assigned to a parameter of type string.
(@typescript-eslint/no-unsafe-argument)
[error] 40-40: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 40-40: Unsafe call of an any typed value.
(@typescript-eslint/no-unsafe-call)
[error] 40-40: Unsafe member access .language on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 137-137: Unsafe call of an any typed value.
(@typescript-eslint/no-unsafe-call)
[error] 177-177: Unsafe member access .originalTranscript on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 181-181: Unsafe member access .context on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 181-181: Unsafe member access .context on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 181-181: Unsafe member access .context on an any value.
(@typescript-eslint/no-unsafe-member-access)
src/utils/getSnippetSubtitle.tsx
[error] 7-7: Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all.
(react/jsx-no-useless-fragment)
[error] 12-12: Unsafe member access .audio_file on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 13-13: Unsafe member access .audio_file on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 14-14: Unsafe member access .recorded_at on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 14-14: Unsafe call of an any typed value.
(@typescript-eslint/no-unsafe-call)
[error] 14-14: Unsafe argument of type any assigned to a parameter of type string | number | Date.
(@typescript-eslint/no-unsafe-argument)
[error] 14-14: Unsafe member access .recorded_at on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 18-18: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 18-18: Unsafe member access .political_leaning on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 19-19: Unsafe argument of type any assigned to a parameter of type number.
(@typescript-eslint/no-unsafe-argument)
[error] 32-32: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 33-33: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 34-41: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 34-34: Unsafe member access .confidence_scores on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 36-36: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 38-38: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 38-38: Unsafe member access .confidence_scores on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 46-46: Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all.
(react/jsx-no-useless-fragment)
🔇 Additional comments (3)
src/utils/getSnippetSubtitle.tsx (1)
Line range hint 1-47: Verify similar patterns across the codebase.
Let's check for similar patterns that might need the same improvements.
✅ Verification successful
Similar patterns found but no critical issues to address
Based on the verification results:
- The date formatting pattern in
getSnippetSubtitle.tsxis unique, with other date handling using different approaches (momentindate.tsand a formatter inutils.ts). - Political label handling is properly encapsulated in
getPoliticalLabel.tsand only used in this component. - Confidence scores usage is localized to this component and its related type definition.
- The conditional rendering patterns found across the codebase follow similar safe practices with proper null checks.
The patterns found in other files show consistent and safe implementations, suggesting that the improvements made to getSnippetSubtitle.tsx are sufficient and don't need to be replicated elsewhere.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find similar patterns that might need the same improvements
# Test 1: Check for other files using 'any' type with snippet
echo "Checking for 'any' typed snippet parameters..."
ast-grep --pattern 'function $_(snippet: any)'
# Test 2: Check for unsafe date formatting
echo "Checking for potentially unsafe date formatting..."
rg "format\(new Date\(" -A 2
# Test 3: Check for empty fragments
echo "Checking for empty fragments..."
rg "<></>" -A 2
# Test 4: Check for similar political label handling
echo "Checking for political label handling..."
rg "political_leaning\.score" -A 2
Length of output: 985
Script:
#!/bin/bash
# Let's try a different approach to find similar patterns
# Check for files that might handle snippets
echo "Files handling snippets:"
rg "snippet\." -l
# Check for other date formatting patterns
echo "\nDate formatting patterns:"
rg "format\(" -A 2
# Check for political label usage
echo "\nPolitical label usage:"
rg "getPoliticalLabel" -A 2
# Check for confidence score usage
echo "\nConfidence score usage:"
rg "confidence_scores" -A 2
# Check for similar UI components with conditional rendering
echo "\nSimilar conditional rendering patterns:"
rg "\? .+ : (null|undefined|\[\]|'')" -A 2
Length of output: 5927
🧰 Tools
🪛 eslint
[error] 3-3: Missing file extension for "@/components/ui/ConfidenceScoreBar"
(import/extensions)
[error] 5-48: Prefer default export on a file with single export.
(import/prefer-default-export)
[error] 5-5: Unexpected any. Specify a different type.
(@typescript-eslint/no-explicit-any)
[error] 7-7: Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all.
(react/jsx-no-useless-fragment)
[error] 12-12: Unsafe member access .audio_file on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 13-13: Unsafe member access .audio_file on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 14-14: Unsafe member access .recorded_at on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 14-14: Unsafe call of an any typed value.
(@typescript-eslint/no-unsafe-call)
[error] 14-14: Unsafe argument of type any assigned to a parameter of type string | number | Date.
(@typescript-eslint/no-unsafe-argument)
[error] 14-14: Unsafe member access .recorded_at on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 18-18: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 18-18: Unsafe member access .political_leaning on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 19-19: Unsafe argument of type any assigned to a parameter of type number.
(@typescript-eslint/no-unsafe-argument)
[error] 32-32: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 33-33: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 34-41: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 34-34: Unsafe member access .confidence_scores on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 36-36: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 38-38: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 38-38: Unsafe member access .confidence_scores on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 46-46: Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all.
(react/jsx-no-useless-fragment)
src/components/SnippetDetail.tsx (2)
154-154: LGTM! UI improvements and code formatting.
The changes improve:
- Responsive layout with better padding
- Code readability with proper JSX formatting
Also applies to: 176-176, 183-183, 201-201, 212-212
Line range hint 137-153: Verify consistent error handling patterns.
Let's check if similar error handling patterns are used consistently across the codebase.
✅ Verification successful
Error handling is consistently implemented across components
The verification shows consistent error handling patterns across the codebase:
- All components using
useSnippetoruseSnippetsproperly destructure and handle error states:SnippetDetail.tsxhandleserror,isEmpty(snippet), andsnippetIdvalidationSearchInterface.tsxhandleserrorandstatusfromuseSnippetsLiveblocksComments.tsxhandleserrorandisLoadingstatesInboxPopover.tsxusesuseSnippetwith proper data destructuring
The error handling in SnippetDetail.tsx follows the established pattern in the codebase, where error states are properly checked before rendering content.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistent error handling patterns in React components
# Look for similar error handling patterns
echo "Checking for error handling patterns in React components..."
rg -l "isLoading|isEmpty.*snippet|error.*snippet" --type ts --type tsx
# Look for potential missing error handling
echo "\nChecking for potential missing error handling..."
rg "useSnippet.*\(" --type ts --type tsx -A 5 -B 5
Length of output: 421
Script:
#!/bin/bash
# Description: Check for consistent error handling patterns in React components
# Look for similar error handling patterns
echo "Checking for error handling patterns in React components..."
rg -t typescript -t javascriptreact -t typescriptreact "isLoading|isEmpty.*snippet|error.*snippet"
# Look for potential missing error handling
echo -e "\nChecking for potential missing error handling..."
rg -t typescript -t javascriptreact -t typescriptreact "useSnippet.*\(" -A 5 -B 5
Length of output: 496
Script:
#!/bin/bash
# Description: Check for consistent error handling patterns in React components
# Look for similar error handling patterns using simpler ripgrep commands
echo "Checking for error handling patterns..."
rg "if.*error.*snippet.*return"
# Look for potential error states and loading states
echo -e "\nChecking for error and loading states..."
rg "const.*\{.*error.*\}.*=.*use"
# Look for isEmpty checks
echo -e "\nChecking for isEmpty usage..."
rg "isEmpty.*snippet"
# Look for useSnippet hook usage
echo -e "\nChecking useSnippet usage..."
rg "useSnippet"
Length of output: 2607
🧰 Tools
🪛 eslint
[error] 137-137: Unsafe call of an any typed value.
(@typescript-eslint/no-unsafe-call)
src/utils/getSnippetSubtitle.tsx
Outdated
| const parts = [ | ||
| snippet?.audio_file?.radio_station_code, | ||
| snippet?.audio_file?.location_state, | ||
| snippet?.recorded_at ? format(new Date(snippet.recorded_at), 'MMM d, yyyy HH:mm zzz') : null | ||
| ].filter(Boolean) |
There was a problem hiding this comment.
Add date validation before formatting.
The date formatting could throw an error if recorded_at contains an invalid date string.
const parts = [
snippet?.audio_file?.radio_station_code,
snippet?.audio_file?.location_state,
- snippet?.recorded_at ? format(new Date(snippet.recorded_at), 'MMM d, yyyy HH:mm zzz') : null
+ snippet?.recorded_at && !isNaN(Date.parse(snippet.recorded_at))
+ ? format(new Date(snippet.recorded_at), 'MMM d, yyyy HH:mm zzz')
+ : null
].filter(Boolean)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const parts = [ | |
| snippet?.audio_file?.radio_station_code, | |
| snippet?.audio_file?.location_state, | |
| snippet?.recorded_at ? format(new Date(snippet.recorded_at), 'MMM d, yyyy HH:mm zzz') : null | |
| ].filter(Boolean) | |
| const parts = [ | |
| snippet?.audio_file?.radio_station_code, | |
| snippet?.audio_file?.location_state, | |
| snippet?.recorded_at && !isNaN(Date.parse(snippet.recorded_at)) | |
| ? format(new Date(snippet.recorded_at), 'MMM d, yyyy HH:mm zzz') | |
| : null | |
| ].filter(Boolean) |
🧰 Tools
🪛 eslint
[error] 12-12: Unsafe member access .audio_file on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 13-13: Unsafe member access .audio_file on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 14-14: Unsafe member access .recorded_at on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 14-14: Unsafe call of an any typed value.
(@typescript-eslint/no-unsafe-call)
[error] 14-14: Unsafe argument of type any assigned to a parameter of type string | number | Date.
(@typescript-eslint/no-unsafe-argument)
[error] 14-14: Unsafe member access .recorded_at on an any value.
(@typescript-eslint/no-unsafe-member-access)
src/utils/getSnippetSubtitle.tsx
Outdated
| export function getSnippetSubtitle(snippet: any): JSX.Element { | ||
| const parts = [ | ||
| snippet.audio_file.radio_station_code, | ||
| snippet.audio_file.location_state, | ||
| format(new Date(snippet.recorded_at), 'MMM d, yyyy HH:mm zzz') | ||
| ].filter(Boolean) | ||
| if (!snippet) { | ||
| return <></> | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add proper TypeScript typing for the snippet parameter.
The any type defeats TypeScript's type safety features. Consider creating a proper interface for the snippet object structure.
-export function getSnippetSubtitle(snippet: any): JSX.Element {
+interface Snippet {
+ audio_file?: {
+ radio_station_code?: string;
+ location_state?: string;
+ };
+ recorded_at?: string;
+ political_leaning?: {
+ score?: number;
+ };
+ confidence_scores?: {
+ level?: string;
+ };
+}
+
+export function getSnippetSubtitle(snippet: Snippet | null): JSX.Element | null {
if (!snippet) {
- return <></>
+ return null;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function getSnippetSubtitle(snippet: any): JSX.Element { | |
| const parts = [ | |
| snippet.audio_file.radio_station_code, | |
| snippet.audio_file.location_state, | |
| format(new Date(snippet.recorded_at), 'MMM d, yyyy HH:mm zzz') | |
| ].filter(Boolean) | |
| if (!snippet) { | |
| return <></> | |
| } | |
| interface Snippet { | |
| audio_file?: { | |
| radio_station_code?: string; | |
| location_state?: string; | |
| }; | |
| recorded_at?: string; | |
| political_leaning?: { | |
| score?: number; | |
| }; | |
| confidence_scores?: { | |
| level?: string; | |
| }; | |
| } | |
| export function getSnippetSubtitle(snippet: Snippet | null): JSX.Element | null { | |
| if (!snippet) { | |
| return null; | |
| } |
🧰 Tools
🪛 eslint
[error] 5-48: Prefer default export on a file with single export.
(import/prefer-default-export)
[error] 5-5: Unexpected any. Specify a different type.
(@typescript-eslint/no-explicit-any)
[error] 7-7: Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all.
(react/jsx-no-useless-fragment)
src/utils/getSnippetSubtitle.tsx
Outdated
| return ( | ||
| <> | ||
| {parts.length > 0 ? parts.join(' • ') : ''} | ||
| {parts.length > 0 && label && ' • '} | ||
| {label && <span className={labelColorClass}>{label}</span>} | ||
| {snippet?.confidence_scores?.level && ( | ||
| <> | ||
| {(parts.length > 0 || label) && ' • '} | ||
| <span className='inline-flex items-center'> | ||
| <ConfidenceChart level={snippet.confidence_scores.level} /> | ||
| </span> | ||
| </> | ||
| )} | ||
| </> | ||
| ) |
There was a problem hiding this comment.
Prevent potential render leaks and simplify conditions.
The current implementation has potential render leaks flagged by ESLint. Let's make the rendering more robust.
return (
<>
- {parts.length > 0 ? parts.join(' • ') : ''}
- {parts.length > 0 && label && ' • '}
- {label && <span className={labelColorClass}>{label}</span>}
- {snippet?.confidence_scores?.level && (
+ {parts.length > 0 && <span>{parts.join(' • ')}</span>}
+ {parts.length > 0 && label && <span> • </span>}
+ {label && <span className={labelColorClass}>{label}</span>}
+ {Boolean(snippet?.confidence_scores?.level) && (
<>
- {(parts.length > 0 || label) && ' • '}
+ {(parts.length > 0 || label) && <span> • </span>}
<span className='inline-flex items-center'>
<ConfidenceChart level={snippet.confidence_scores.level} />
</span>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return ( | |
| <> | |
| {parts.length > 0 ? parts.join(' • ') : ''} | |
| {parts.length > 0 && label && ' • '} | |
| {label && <span className={labelColorClass}>{label}</span>} | |
| {snippet?.confidence_scores?.level && ( | |
| <> | |
| {(parts.length > 0 || label) && ' • '} | |
| <span className='inline-flex items-center'> | |
| <ConfidenceChart level={snippet.confidence_scores.level} /> | |
| </span> | |
| </> | |
| )} | |
| </> | |
| ) | |
| return ( | |
| <> | |
| {parts.length > 0 && <span>{parts.join(' • ')}</span>} | |
| {parts.length > 0 && label && <span> • </span>} | |
| {label && <span className={labelColorClass}>{label}</span>} | |
| {Boolean(snippet?.confidence_scores?.level) && ( | |
| <> | |
| {(parts.length > 0 || label) && <span> • </span>} | |
| <span className='inline-flex items-center'> | |
| <ConfidenceChart level={snippet.confidence_scores.level} /> | |
| </span> | |
| </> | |
| )} | |
| </> | |
| ) |
🧰 Tools
🪛 eslint
[error] 32-32: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 33-33: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 34-41: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 34-34: Unsafe member access .confidence_scores on an any value.
(@typescript-eslint/no-unsafe-member-access)
[error] 36-36: Potential leaked value that might cause unintentionally rendered values or rendering crashes
(react/jsx-no-leaked-render)
[error] 38-38: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 38-38: Unsafe member access .confidence_scores on an any value.
(@typescript-eslint/no-unsafe-member-access)
src/components/SnippetDetail.tsx
Outdated
| const { data: snippet, isLoading, error } = useSnippet(snippetId || '', language) | ||
| const sourceLanguage = snippet?.language?.primary_language?.toLowerCase() |
There was a problem hiding this comment.
Add proper TypeScript types to prevent unsafe assertions.
The current implementation has multiple TypeScript safety issues. Consider adding proper type definitions:
- const { data: snippet, isLoading, error } = useSnippet(snippetId || '', language)
- const sourceLanguage = snippet?.language?.primary_language?.toLowerCase()
+ type Snippet = {
+ language: {
+ primary_language: string;
+ };
+ // ... other snippet properties
+ };
+ const { data: snippet, isLoading, error } = useSnippet<Snippet>(snippetId || '', language)
+ const sourceLanguage = snippet?.language?.primary_language?.toLowerCase() ?? undefined🧰 Tools
🪛 eslint
[error] 39-39: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 39-39: Unsafe argument of type any assigned to a parameter of type string.
(@typescript-eslint/no-unsafe-argument)
[error] 39-39: Unsafe argument of type any assigned to a parameter of type string.
(@typescript-eslint/no-unsafe-argument)
[error] 40-40: Unsafe assignment of an any value.
(@typescript-eslint/no-unsafe-assignment)
[error] 40-40: Unsafe call of an any typed value.
(@typescript-eslint/no-unsafe-call)
[error] 40-40: Unsafe member access .language on an any value.
(@typescript-eslint/no-unsafe-member-access)
Summary by CodeRabbit
New Features
Bug Fixes
Documentation