-
Notifications
You must be signed in to change notification settings - Fork 187
fix: remove temporary ESLint exclusions for re-export violations #3839
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
base: main
Are you sure you want to change the base?
Changes from all commits
efbbadc
71b4236
9c2dff7
4c1578a
f0b8dd1
10d7efb
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 |
|---|---|---|
|
|
@@ -62,19 +62,35 @@ export class PGliteInstanceManager { | |
| * Execute SQL statements and return results with metadata | ||
| * Uses PostgreSQL parser to properly handle complex statements including dollar-quoted strings | ||
| */ | ||
| private isParseError( | ||
| result: PgParseResult, | ||
| ): result is { error: { message: string } } { | ||
| return (result as any).error !== null | ||
| } | ||
|
|
||
| private isParseSuccess( | ||
| result: PgParseResult, | ||
| ): result is { parse_tree: { stmts: any[] } } { | ||
| return (result as any).parse_tree?.stmts != null | ||
| } | ||
|
Comment on lines
+65
to
+75
Contributor
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. 🧩 Analysis chainVerify PgParseResult type structure to ensure correct type guards. The type guards assume a specific discriminated union structure for Run the following script to examine the PgParseResult type definition: 🏁 Script executed: #!/bin/bash
# Description: Find and display the PgParseResult type definition from the parser module
# Search for PgParseResult type definition
ast-grep --pattern 'type PgParseResult = $$$'
# Also search for interface definitions
ast-grep --pattern 'interface PgParseResult {
$$$
}'
# Search for export statements
rg -nP --type=ts 'export.*PgParseResult' -A 5Length of output: 2518 Fix type guard return types to properly narrow The logic in both guards is correct, but the return type annotations are incomplete. They only reflect the discriminating field (
This ensures callers can still access 🤖 Prompt for AI Agents
Comment on lines
+71
to
+75
Contributor
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. Remove unsafe type assertion from type guard. The type guard uses Apply this diff to use the private isParseSuccess(
result: PgParseResult,
): result is { parse_tree: { stmts: any[] } } {
- return (result as any).parse_tree?.stmts != null
+ return 'parse_tree' in result && Array.isArray(result.parse_tree?.stmts)
}🤖 Prompt for AI Agents |
||
|
|
||
| private async executeSql(sqlText: string, db: PGlite): Promise<SqlResult[]> { | ||
| try { | ||
| const parseResult: PgParseResult = await pgParse(sqlText) | ||
|
|
||
| if (parseResult.error) { | ||
| if (this.isParseError(parseResult)) { | ||
| return [this.createParseErrorResult(sqlText, parseResult.error.message)] | ||
| } | ||
|
|
||
| const statements = this.extractStatements( | ||
| sqlText, | ||
| parseResult.parse_tree.stmts, | ||
| ) | ||
| return await this.executeStatements(statements, db) | ||
| if (this.isParseSuccess(parseResult)) { | ||
| const statements = this.extractStatements( | ||
| sqlText, | ||
| parseResult.parse_tree.stmts, | ||
| ) | ||
| return await this.executeStatements(statements, db) | ||
| } | ||
|
|
||
| return [this.createParseErrorResult(sqlText, 'No statements found')] | ||
| } catch (error) { | ||
| return await this.executeFallback(sqlText, db, error) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,19 @@ | ||
| export { | ||
| import { | ||
| detectFormat, | ||
| ProcessError, | ||
| parse, | ||
| type SupportedFormat, | ||
| setPrismWasmUrl, | ||
| supportedFormatSchema, | ||
| pgParse, | ||
| } from './parser/index.js' | ||
| import type { SupportedFormat, PgParseResult } from './parser/index.js' | ||
|
|
||
| // Export PostgreSQL-specific parser | ||
| export { | ||
| type PgParseResult, | ||
| parse as pgParse, | ||
| } from './parser/sql/postgresql/parser.js' | ||
| detectFormat, | ||
| ProcessError, | ||
| parse, | ||
| setPrismWasmUrl, | ||
| supportedFormatSchema, | ||
| pgParse, | ||
| } | ||
| export type { SupportedFormat, PgParseResult } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| // Re-export for custom implementations | ||
| export { | ||
| ItemIndicator as DropdownMenuItemIndicator, | ||
| RadioItem as DropdownMenuPrimitiveRadioItem, | ||
| } from '@radix-ui/react-dropdown-menu' | ||
|
|
||
| export * from './DropdownMenu' |
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.
Fix type guard implementation to avoid unsafe type assertions.
The type guard uses
as any, which defeats TypeScript's type safety and can lead to runtime errors. Additionally, checkingerror !== nullwithout first verifying the property exists could throw iferroris undefined.Apply this diff to use proper type narrowing:
private isParseError( result: PgParseResult, ): result is { error: { message: string } } { - return (result as any).error !== null + return 'error' in result && result.error != null }Alternatively, if the property is always present but may be null/undefined:
private isParseError( result: PgParseResult, ): result is { error: { message: string } } { - return (result as any).error !== null + return (result as { error?: { message: string } | null }).error != null }🤖 Prompt for AI Agents