From 8c131073730ec684145c2cc8ee8d6b39bbe9278d Mon Sep 17 00:00:00 2001 From: MCMXC <16797721+mcmxcdev@users.noreply.github.com> Date: Sun, 23 Jul 2023 20:08:52 -0600 Subject: chore: improve lint setup - update eslint config - merged eslint rules for JS and TS to avoid duplicates - extended stricter lint ruleset from typescript-eslint - corrected wrong setup for certain eslint rulesets - opt in to reportUnusedDisableDirectives config option - fix or disable a lot of lint issues throughout codebase - remove trailingComma: all from prettier config which is default in prettier v3 - add volta configuration to package.json to autoload correct node and pnpm versions - upgrade all eslint and prettier related dependencies to latest - remove config options from settings.json which are default anyways - remove config options from settings.json which are outdated/unknown - set up prettier as default formatter in settings.json --- src/@types/ferdium.types.ts | 1 + src/@types/stores.types.ts | 1 + src/actions/lib/actions.ts | 1 + src/api/apiBase.ts | 7 +- src/api/server/ServerApi.ts | 2 +- src/app.tsx | 2 +- src/components/AppUpdateInfoBar.tsx | 1 + src/components/auth/Login.tsx | 1 - src/components/auth/Welcome.tsx | 4 - src/components/layout/Sidebar.tsx | 248 ++++++++++----------- .../services/tabs/TabBarSortableList.tsx | 2 +- src/components/services/tabs/TabItem.tsx | 8 +- src/components/services/tabs/Tabbar.tsx | 2 +- .../settings/navigation/SettingsNavigation.tsx | 6 +- .../supportFerdium/SupportFerdiumDashboard.tsx | 2 +- src/components/ui/AppLoader/index.tsx | 23 +- src/components/ui/Link.tsx | 4 - src/components/ui/Select.tsx | 4 - src/components/ui/Tabs/Tabs.tsx | 2 + src/components/ui/WebviewLoader/index.tsx | 2 +- src/components/ui/colorPickerInput/index.tsx | 2 +- src/components/ui/headline/index.tsx | 11 +- src/components/ui/select/index.tsx | 6 +- src/containers/auth/WelcomeScreen.tsx | 4 - src/containers/layout/AppLayoutContainer.tsx | 1 - src/containers/settings/EditSettingsScreen.tsx | 2 - src/containers/settings/EditUserScreen.tsx | 2 - src/electron/macOSPermissions.ts | 1 + src/environment.ts | 2 +- src/features/serviceProxy/index.ts | 6 +- .../workspaces/components/WorkspaceDrawer.tsx | 5 +- .../workspaces/components/WorkspaceDrawerItem.tsx | 1 + .../workspaces/components/WorkspacesDashboard.tsx | 1 - src/features/workspaces/store.ts | 1 + src/helpers/recipe-helpers.ts | 1 + src/index.ts | 2 + .../app/Controllers/Http/UserController.js | 14 +- src/internal-server/public/js/transfer.js | 1 + src/lib/Form.ts | 1 + src/lib/Menu.ts | 3 + src/models/Recipe.ts | 8 +- src/routes.tsx | 18 +- src/stores/AppStore.ts | 2 + src/stores/GlobalErrorStore.ts | 12 +- src/stores/RecipesStore.ts | 1 + src/stores/ServicesStore.ts | 2 +- src/stores/SettingsStore.ts | 21 +- src/stores/UserStore.ts | 4 +- src/stores/lib/TypedStore.ts | 2 +- src/webview/contextMenuBuilder.ts | 7 +- src/webview/lib/Userscript.ts | 9 +- src/webview/recipe.ts | 17 +- 52 files changed, 245 insertions(+), 248 deletions(-) (limited to 'src') diff --git a/src/@types/ferdium.types.ts b/src/@types/ferdium.types.ts index 70306f5fb..f54fb64ae 100644 --- a/src/@types/ferdium.types.ts +++ b/src/@types/ferdium.types.ts @@ -3,6 +3,7 @@ declare global { ferdium: any; } + // eslint-disable-next-line @typescript-eslint/no-namespace namespace NodeJS { interface ProcessEnv { GITHUB_AUTH_TOKEN: string; diff --git a/src/@types/stores.types.ts b/src/@types/stores.types.ts index edea41ea9..ff8f127ed 100644 --- a/src/@types/stores.types.ts +++ b/src/@types/stores.types.ts @@ -59,6 +59,7 @@ interface Actions { interface Api { app: AppStore; features: FeaturesStore; + // eslint-disable-next-line @typescript-eslint/ban-types local: {}; recipePreviews: RecipePreviewsStore; recipes: RecipeStore; diff --git a/src/actions/lib/actions.ts b/src/actions/lib/actions.ts index faf576fd8..d3fd5f27c 100644 --- a/src/actions/lib/actions.ts +++ b/src/actions/lib/actions.ts @@ -8,6 +8,7 @@ export interface Actions { [key: string]: { [key: string]: { (...args: any[]): void; + // eslint-disable-next-line @typescript-eslint/ban-types listeners: Function[]; notify: (params: any) => void; listen: (listener: (params: any) => void) => void; diff --git a/src/api/apiBase.ts b/src/api/apiBase.ts index bc2cb3dd1..649895fbc 100644 --- a/src/api/apiBase.ts +++ b/src/api/apiBase.ts @@ -14,12 +14,7 @@ import { fixUrl } from '../helpers/url-helpers'; // Note: This cannot be used from the internal-server since we are not running within the context of a browser window export default function apiBase(withVersion = true) { - if ( - !(window as any).ferdium || - !(window as any).ferdium.stores.settings || - !(window as any).ferdium.stores.settings.all || - !(window as any).ferdium.stores.settings.all.app.server - ) { + if (!(window as any).ferdium?.stores.settings?.all?.app.server) { // Stores have not yet been loaded - return SERVER_NOT_LOADED to force a retry when stores are loaded return SERVER_NOT_LOADED; } diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts index a3d873c65..860b7b76e 100644 --- a/src/api/server/ServerApi.ts +++ b/src/api/server/ServerApi.ts @@ -507,7 +507,7 @@ export default class ServerApi { async _mapServiceModels(services: any[]) { const recipes = services.map((s: { recipeId: string }) => s.recipeId); await this._bulkRecipeCheck(recipes); - /* eslint-disable no-return-await */ + return Promise.all( services.map(async (service: any) => this._prepareServiceModel(service)), ); diff --git a/src/app.tsx b/src/app.tsx index 4d4100c40..77ec27021 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -24,7 +24,7 @@ window.addEventListener('load', () => { const api = apiFactory(serverApi, new LocalApi()); const history = createHashHistory(); const router = new RouterStore(history); - // @ts-ignore - Need to provide proper typings for actions + // @ts-expect-error - Need to provide proper typings for actions const stores = storeFactory(api, actions, router); const menu = new MenuFactory(stores, actions); const touchBar = new TouchBarFactory(stores, actions); diff --git a/src/components/AppUpdateInfoBar.tsx b/src/components/AppUpdateInfoBar.tsx index b27578d10..b8e1bb61e 100644 --- a/src/components/AppUpdateInfoBar.tsx +++ b/src/components/AppUpdateInfoBar.tsx @@ -38,6 +38,7 @@ const AppUpdateInfoBar = (props: IProps) => { type="primary" ctaLabel={intl.formatMessage(messages.buttonInstallUpdate)} onClick={event => { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions !isWinPortable && onInstallUpdate(event); }} onHide={onHide} diff --git a/src/components/auth/Login.tsx b/src/components/auth/Login.tsx index 0a95b0565..eaa04256c 100644 --- a/src/components/auth/Login.tsx +++ b/src/components/auth/Login.tsx @@ -68,7 +68,6 @@ interface IProps extends WrappedComponentProps { isTokenExpired: boolean; isServerLogout: boolean; signupRoute: string; - // eslint-disable-next-line react/no-unused-prop-types passwordRoute: string; // TODO: Uncomment this line after fixing password recovery in-app error: GlobalError; } diff --git a/src/components/auth/Welcome.tsx b/src/components/auth/Welcome.tsx index 1aa8da4d6..047512ea4 100644 --- a/src/components/auth/Welcome.tsx +++ b/src/components/auth/Welcome.tsx @@ -44,10 +44,6 @@ interface IProps extends Partial, WrappedComponentProps { @inject('actions') @observer class Welcome extends Component { - constructor(props: IProps) { - super(props); - } - useLocalServer(): void { serverlessLogin(this.props.actions); } diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index 2b1e87023..ceb9cfff9 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -205,133 +205,131 @@ class Sidebar extends Component { hibernateService={this.props.hibernateService} wakeUpService={this.props.wakeUpService} /> - <> - {numberActiveButtons <= 1 || hideCollapseButton ? null : ( - - )} - {!hideRecipesButton && !isMenuCollapsed ? ( - - ) : null} - {!hideSplitModeButton && !isMenuCollapsed ? ( - - ) : null} - {!hideWorkspacesButton && !isMenuCollapsed ? ( - - ) : null} - {!hideNotificationsButton && !isMenuCollapsed ? ( - - ) : null} - {todosStore.isFeatureEnabledByUser && !isMenuCollapsed ? ( - - ) : null} - {stores!.settings.all.app.lockingFeatureEnabled ? ( - - ) : null} - + {!isMenuCollapsed && useHorizontalStyle ? ( + + ) : null} + + )} + {!hideRecipesButton && !isMenuCollapsed ? ( + + ) : null} + {!hideSplitModeButton && !isMenuCollapsed ? ( + + ) : null} + {!hideWorkspacesButton && !isMenuCollapsed ? ( + + ) : null} + {!hideNotificationsButton && !isMenuCollapsed ? ( + + ) : null} + {todosStore.isFeatureEnabledByUser && !isMenuCollapsed ? ( + + ) : null} + {stores!.settings.all.app.lockingFeatureEnabled ? ( + + ) : null} {this.state.tooltipEnabled && ( { {services.map((service, index) => ( setActive({ serviceId: service.id })} service={service} index={index} diff --git a/src/components/services/tabs/TabItem.tsx b/src/components/services/tabs/TabItem.tsx index c25af4427..287dedfcb 100644 --- a/src/components/services/tabs/TabItem.tsx +++ b/src/components/services/tabs/TabItem.tsx @@ -234,7 +234,7 @@ class TabItem extends Component { } = this.props; const { intl } = this.props; - const menuTemplate: Array = [ + const menuTemplate: MenuItemConstructorOptions[] = [ { label: service.name || service.recipe.name, enabled: false, @@ -295,7 +295,7 @@ class TabItem extends Component { ? messages.wakeUpService : messages.hibernateService, ), - // eslint-disable-next-line no-confusing-arrow + click: () => service.isHibernating ? wakeUpService() : hibernateService(), enabled: service.isEnabled && service.canHibernate, @@ -311,7 +311,7 @@ class TabItem extends Component { { label: intl.formatMessage(messages.deleteService), click: () => { - // @ts-ignore + // @ts-expect-error Fix me const selection = dialog.showMessageBoxSync(app.mainWindow, { type: 'question', message: intl.formatMessage(messages.deleteService), @@ -417,6 +417,6 @@ class TabItem extends Component { } export default injectIntl( - // @ts-ignore + // @ts-expect-error Fix me SortableElement(injectSheet(styles, { injectTheme: true })(TabItem)), ); diff --git a/src/components/services/tabs/Tabbar.tsx b/src/components/services/tabs/Tabbar.tsx index f09877b2f..d19a4b8de 100644 --- a/src/components/services/tabs/Tabbar.tsx +++ b/src/components/services/tabs/Tabbar.tsx @@ -99,7 +99,7 @@ class TabBar extends Component { return (
, WrappedComponentProps { @inject('stores', 'actions') @observer class SettingsNavigation extends Component { - constructor(props: IProps) { - super(props); - } - handleLogout(): void { const isUsingWithoutAccount = this.props.stores!.settings.app.server === LOCAL_SERVER; @@ -186,7 +182,7 @@ class SettingsNavigation extends Component {