-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: streamline imports and improve type usage across components #116
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
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import config from '@egor.xyz/eslint-config'; | ||
| import tseslint from 'typescript-eslint'; | ||
|
|
||
| export default tseslint.config( | ||
| { | ||
| // ignore files and folders from root: node_modules, dist, build, *.js, *.ts | ||
| ignores: ['node_modules', 'dist', 'build', '*.js', '*.ts', '.tmp', '.vite'] | ||
| }, | ||
| { | ||
| extends: config, | ||
| files: ['**/*.{ts,tsx}'] | ||
| } | ||
| ); |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,15 @@ | ||
| import { ipcMain } from 'electron'; | ||
| import { type LaunchEditor } from 'types/foundEditor'; | ||
| import { type LaunchShell } from 'types/foundShell'; | ||
|
|
||
| import { LaunchEditor } from 'types/foundEditor'; | ||
| import { LaunchShell } from 'types/foundShell'; | ||
|
|
||
| import { launch } from '../libs/integrations/shellsLaunch'; | ||
| import { launchExternalEditor } from '../libs/integrations/editrosLaunch'; | ||
| import { launch } from '../libs/integrations/shellsLaunch'; | ||
|
|
||
| ipcMain.handle('launch:editor', async (e, launchEditor: LaunchEditor) => { | ||
| launchExternalEditor(launchEditor.fullPath, launchEditor.editor); | ||
| }); | ||
|
|
||
| ipcMain.handle('launch:shell', async (e, launchShell: LaunchShell) => { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| launch(launchShell.shell as any, launchShell.fullPath); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,3 @@ | ||
| /** Throw an error. */ | ||
| export function fatalError(msg: string): never { | ||
| throw new Error(msg); | ||
| } | ||
|
|
||
| /** | ||
| * Utility function used to achieve exhaustive type checks at compile time. | ||
| * | ||
|
|
@@ -25,22 +20,27 @@ export function assertNever(x: never, message: string): never { | |
| * this will throw. The message should contain the rationale for knowing the | ||
| * value is defined. | ||
| */ | ||
| export function forceUnwrap<T>(message: string, x: T | null | undefined): T { | ||
| if (x == null) { | ||
| export function assertNonNullable<T>(x: T, message: string): asserts x is NonNullable<T> { | ||
| if (x === null) { | ||
| return fatalError(message); | ||
| } else { | ||
| return x; | ||
| } | ||
| } | ||
|
Comment on lines
+23
to
27
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. Critical bug: Incomplete null/undefined checking in assertion function. The function documentation states it handles values that "could be null or undefined", but the implementation only checks for Apply this fix to check for both null and undefined: - if (x === null) {
+ if (x == null) {
return fatalError(message);
}Alternatively, use explicit checks for both: - if (x === null) {
+ if (x === null || x === undefined) {
return fatalError(message);
}🤖 Prompt for AI Agents |
||
|
|
||
| /** Throw an error. */ | ||
| export function fatalError(msg: string): never { | ||
| throw new Error(msg); | ||
| } | ||
|
|
||
| /** | ||
| * Unwrap a value that, according to the type system, could be null or | ||
| * undefined, but which we know is not. If the value _is_ null or undefined, | ||
| * this will throw. The message should contain the rationale for knowing the | ||
| * value is defined. | ||
| */ | ||
| export function assertNonNullable<T>(x: T, message: string): asserts x is NonNullable<T> { | ||
| if (x == null) { | ||
| export function forceUnwrap<T>(message: string, x: null | T | undefined): T { | ||
| if (x === null) { | ||
| return fatalError(message); | ||
| } else { | ||
| return x; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import { access } from 'fs/promises'; | ||
|
|
||
| import { constant } from 'lodash'; | ||
|
|
||
| /** | ||
|
|
||
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.
Hard-coded
darwinflag breaks Windows / Linux supportconst darwin = true;forces macOS logic on every platform.Without this, non-mac users will hit the
opencommand path or incorrect error labels.📝 Committable suggestion
🤖 Prompt for AI Agents