From a301097d8152630b09356e4030d99542e70a9899 Mon Sep 17 00:00:00 2001 From: sajjad isvand Date: Fri, 17 May 2024 23:33:05 +0330 Subject: [PATCH] style: format codebase with Prettier --- src/i18n/i18n-react.tsx | 3 ++- src/i18n/i18n-util.async.ts | 3 ++- src/i18n/i18n-util.sync.ts | 3 ++- src/main/index.ts | 4 ++- .../windows/__test__/windows.platform.spec.ts | 12 ++++++--- .../platforms/windows/windows.platform.ts | 4 ++- src/main/shared/isDev.ts | 13 +++++---- .../buttons/add-custom-btn-component.tsx | 2 +- .../component/buttons/edit-btn.component.tsx | 4 ++- .../interfaces-dialog-btn-component.tsx | 2 +- .../buttons/togglePin-btn.component.tsx | 11 ++++---- .../buttons/update-btn.component.tsx | 14 +++++++--- .../component/head/navbar.component.tsx | 5 +++- .../component/modals/add-dns.component.tsx | 27 ++++++++++++++----- .../component/selectes/servers/index.tsx | 5 +++- .../component/servers/server.component.tsx | 23 +++++++--------- .../interfaces/servers-context.interface.ts | 2 +- src/renderer/pages/explore.page.tsx | 15 ++++++++--- src/shared/constants/urls.constant.ts | 2 +- 19 files changed, 99 insertions(+), 55 deletions(-) diff --git a/src/i18n/i18n-react.tsx b/src/i18n/i18n-react.tsx index bae6e12..234515c 100644 --- a/src/i18n/i18n-react.tsx +++ b/src/i18n/i18n-react.tsx @@ -14,7 +14,8 @@ const { component: TypesafeI18n, context: I18nContext } = initI18nReact< Formatters >(loadedLocales, loadedFormatters) -const useI18nContext = (): I18nContextType => useContext(I18nContext) +const useI18nContext = (): I18nContextType => + useContext(I18nContext) export { I18nContext, useI18nContext } diff --git a/src/i18n/i18n-util.async.ts b/src/i18n/i18n-util.async.ts index f807d66..6f31dcf 100644 --- a/src/i18n/i18n-util.async.ts +++ b/src/i18n/i18n-util.async.ts @@ -24,4 +24,5 @@ export const loadLocaleAsync = async (locale: Locales): Promise => { export const loadAllLocalesAsync = (): Promise => Promise.all(locales.map(loadLocaleAsync)) -export const loadFormatters = (locale: Locales): void => void (loadedFormatters[locale] = initFormatters(locale)) +export const loadFormatters = (locale: Locales): void => + void (loadedFormatters[locale] = initFormatters(locale)) diff --git a/src/i18n/i18n-util.sync.ts b/src/i18n/i18n-util.sync.ts index 5115da3..baf28f8 100644 --- a/src/i18n/i18n-util.sync.ts +++ b/src/i18n/i18n-util.sync.ts @@ -24,4 +24,5 @@ export const loadLocale = (locale: Locales): void => { export const loadAllLocales = (): void => locales.forEach(loadLocale) -export const loadFormatters = (locale: Locales): void => void (loadedFormatters[locale] = initFormatters(locale)) +export const loadFormatters = (locale: Locales): void => + void (loadedFormatters[locale] = initFormatters(locale)) diff --git a/src/main/index.ts b/src/main/index.ts index 42d1276..f81d6c8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -19,7 +19,9 @@ if (isDev) process.env.DIST_ELECTRON = join(__dirname, '../') process.env.DIST = join(process.env.DIST_ELECTRON, '../dist') -process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL ? join(process.env.DIST_ELECTRON, '../public') : process.env.DIST +process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL + ? join(process.env.DIST_ELECTRON, '../public') + : process.env.DIST if (release().startsWith('6.1')) app.disableHardwareAcceleration() diff --git a/src/main/platforms/windows/__test__/windows.platform.spec.ts b/src/main/platforms/windows/__test__/windows.platform.spec.ts index aa407b5..29c91fe 100644 --- a/src/main/platforms/windows/__test__/windows.platform.spec.ts +++ b/src/main/platforms/windows/__test__/windows.platform.spec.ts @@ -24,7 +24,9 @@ describe('WinPlatform()', function () { netmask: '', mac_address: '' } - jest.spyOn(WindowsPlatform.prototype as any, 'getValidateInterface').mockImplementation(() => activeInterface) + jest + .spyOn(WindowsPlatform.prototype as any, 'getValidateInterface') + .mockImplementation(() => activeInterface) jest.spyOn(WindowsPlatform.prototype as any, 'execCmd').mockImplementation(() => '') @@ -36,7 +38,9 @@ describe('WinPlatform()', function () { const validatedInterface = { name: 'xx' } as any - jest.spyOn(WindowsPlatform.prototype as any, 'getValidateInterface').mockImplementation(() => validatedInterface) + jest + .spyOn(WindowsPlatform.prototype as any, 'getValidateInterface') + .mockImplementation(() => validatedInterface) jest.spyOn(WindowsPlatform.prototype as any, 'execCmd').mockImplementation() @@ -50,7 +54,9 @@ describe('WinPlatform()', function () { const validatedInterface = { name: 'xx' } as any - jest.spyOn(WindowsPlatform.prototype as any, 'getValidateInterface').mockImplementation(() => validatedInterface) + jest + .spyOn(WindowsPlatform.prototype as any, 'getValidateInterface') + .mockImplementation(() => validatedInterface) jest.spyOn(WindowsPlatform.prototype as any, 'execCmd').mockImplementation() diff --git a/src/main/platforms/windows/windows.platform.ts b/src/main/platforms/windows/windows.platform.ts index 88b43a2..0ab36ee 100644 --- a/src/main/platforms/windows/windows.platform.ts +++ b/src/main/platforms/windows/windows.platform.ts @@ -74,7 +74,9 @@ export class WindowsPlatform extends Platform { private async getValidateInterface() { try { const interfaces: Interface[] = await this.getInterfacesList() - const activeInterface: Interface | null = interfaces.find((inter: Interface) => inter.gateway_ip != null) + const activeInterface: Interface | null = interfaces.find( + (inter: Interface) => inter.gateway_ip != null + ) if (!activeInterface) throw new Error('CONNECTION_FAILED') return activeInterface diff --git a/src/main/shared/isDev.ts b/src/main/shared/isDev.ts index 14b36bb..45ac144 100644 --- a/src/main/shared/isDev.ts +++ b/src/main/shared/isDev.ts @@ -1,10 +1,9 @@ -import electron from 'electron'; +import electron from 'electron' +const { env } = process +const isEnvSet = 'ELECTRON_IS_DEV' in env +const getFromEnv = Number.parseInt(env.ELECTRON_IS_DEV, 10) === 1 -const { env } = process; -const isEnvSet = 'ELECTRON_IS_DEV' in env; -const getFromEnv = Number.parseInt(env.ELECTRON_IS_DEV, 10) === 1; +const isDev = isEnvSet ? getFromEnv : !electron.app.isPackaged -const isDev = isEnvSet ? getFromEnv : !electron.app.isPackaged; - -export default isDev; +export default isDev diff --git a/src/renderer/component/buttons/add-custom-btn-component.tsx b/src/renderer/component/buttons/add-custom-btn-component.tsx index 62010c8..acb592a 100644 --- a/src/renderer/component/buttons/add-custom-btn-component.tsx +++ b/src/renderer/component/buttons/add-custom-btn-component.tsx @@ -14,7 +14,7 @@ export function AddCustomBtnComponent() { return (
- + ) diff --git a/src/renderer/component/buttons/interfaces-dialog-btn-component.tsx b/src/renderer/component/buttons/interfaces-dialog-btn-component.tsx index ee93929..365403c 100644 --- a/src/renderer/component/buttons/interfaces-dialog-btn-component.tsx +++ b/src/renderer/component/buttons/interfaces-dialog-btn-component.tsx @@ -14,7 +14,7 @@ export function InterfacesDialogButtonComponent() { return (
- + diff --git a/src/renderer/component/modals/add-dns.component.tsx b/src/renderer/component/modals/add-dns.component.tsx index 4a453e8..334f501 100644 --- a/src/renderer/component/modals/add-dns.component.tsx +++ b/src/renderer/component/modals/add-dns.component.tsx @@ -62,7 +62,8 @@ export function AddDnsModalComponent(props: Props) { }) } if (resp.success) { - if (resp.server.name === 'default') appNotif('Success', 'Default DNS server has been set/updated', 'SUCCESS') + if (resp.server.name === 'default') + appNotif('Success', 'Default DNS server has been set/updated', 'SUCCESS') else appNotif('Success', LL.dialogs.added_server({ serverName: serverName }), 'SUCCESS') setNameServer1('') setNameServer2('') @@ -84,11 +85,19 @@ export function AddDnsModalComponent(props: Props) { - - setType('ipv4')}> + + setType('ipv4')}> IPV4 - setType('default')}> + setType('default')}> Default @@ -152,8 +161,8 @@ export function AddDnsModalComponent(props: Props) {

- Set the default DNS server for your system. This will be used when no custom server is set. - (Optional) + Set the default DNS server for your system. This will be used when no custom server is + set. (Optional)

@@ -194,7 +203,11 @@ export function AddDnsModalComponent(props: Props) { -
@@ -254,7 +259,9 @@ function ServerTrComponent(prop: Prop) { className="w-72 dark:bg-[#272727] dark:border-gray-700 dark:shadow-md shadow-lg border-none"> - navigator.clipboard.writeText(servers.join(','))}> + navigator.clipboard.writeText(servers.join(','))}> @@ -264,7 +271,7 @@ function ServerTrComponent(prop: Prop) { navigator.clipboard.writeText(servers.join(','))}> + onClick={() => navigator.clipboard.writeText(servers.join(','))}> Rate diff --git a/src/shared/constants/urls.constant.ts b/src/shared/constants/urls.constant.ts index d945f71..371e547 100644 --- a/src/shared/constants/urls.constant.ts +++ b/src/shared/constants/urls.constant.ts @@ -1,4 +1,4 @@ export enum UrlsConstant { STORE = 'https://raw.githubusercontent.com/DnsChanger/dnsChanger-desktop/store/servers_DB.json', - STORE_SERVER = "https://dnschanger-store.liara.run/" + STORE_SERVER = 'https://dnschanger-store.liara.run/' }