Add eslint rule and fix as many issues as possible

This commit is contained in:
Khoa Le
2023-06-19 23:42:04 -04:00
parent e9eacc445d
commit 9d33e4756b
689 changed files with 9446 additions and 21821 deletions
@@ -1,10 +1,10 @@
import { ReactNode, useEffect } from 'react';
import { useRouter } from 'next/router';
import { ReactNode, useEffect } from "react";
import { useRouter } from "next/router";
import { publicPaths } from '@app/const';
import { useToggle } from '@app/hooks';
import { useGetAuthToken } from '@app/hooks/api';
import { isLoggedIn } from '@app/reactQuery';
import { publicPaths } from "@app/const";
import { useToggle } from "@app/hooks";
import { useGetAuthToken } from "@app/hooks/api";
import { isLoggedIn } from "@app/reactQuery";
type Props = {
children: ReactNode;
@@ -26,7 +26,7 @@ export const AuthProvider = ({ children }: Props): JSX.Element => {
if (!isLoading) {
// not a public path and not authenticated kick to login page
if (!publicPaths.includes(pathname) && !isLoggedIn()) {
push('/login').then(() => {
push("/login").then(() => {
setIsReady.on();
});
} else {
+1 -1
View File
@@ -1 +1 @@
export { AuthProvider } from './AuthContext';
export { AuthProvider } from "./AuthContext";
@@ -1,9 +1,9 @@
import { createContext, ReactNode, useContext, useMemo } from 'react';
import { createContext, ReactNode, useContext, useMemo } from "react";
import { useGetOrganization } from '@app/hooks/api';
import { Organization } from '@app/hooks/api/types';
import { useGetOrganization } from "@app/hooks/api";
import { Organization } from "@app/hooks/api/types";
import { useWorkspace } from '../WorkspaceContext';
import { useWorkspace } from "../WorkspaceContext";
type TOrgContext = {
orgs?: Organization[];
@@ -39,7 +39,7 @@ export const OrgProvider = ({ children }: Props): JSX.Element => {
export const useOrganization = () => {
const ctx = useContext(OrgContext);
if (!ctx) {
throw new Error('useOrganization to be used within <OrgContext.Provider>');
throw new Error("useOrganization to be used within <OrgContext.Provider>");
}
return ctx;
@@ -1 +1 @@
export { OrgProvider, useOrganization } from './OrganizationContext';
export { OrgProvider, useOrganization } from "./OrganizationContext";
@@ -1,9 +1,9 @@
import { createContext, ReactNode, useContext, useMemo } from 'react';
import { createContext, ReactNode, useContext, useMemo } from "react";
import { useGetOrgSubscription } from '@app/hooks/api';
import { SubscriptionPlan } from '@app/hooks/api/types';
import { useGetOrgSubscription } from "@app/hooks/api";
import { SubscriptionPlan } from "@app/hooks/api/types";
import { useWorkspace } from '../WorkspaceContext';
import { useWorkspace } from "../WorkspaceContext";
// import { Subscription } from '@app/hooks/api/workspace/types';
type TSubscriptionContext = {
@@ -20,7 +20,7 @@ type Props = {
export const SubscriptionProvider = ({ children }: Props): JSX.Element => {
const { currentWorkspace } = useWorkspace();
const { data, isLoading } = useGetOrgSubscription({
orgID: currentWorkspace?.organization || ''
orgID: currentWorkspace?.organization || ""
});
// memorize the workspace details for the context
@@ -38,7 +38,7 @@ export const SubscriptionProvider = ({ children }: Props): JSX.Element => {
export const useSubscription = () => {
const ctx = useContext(SubscriptionContext);
if (!ctx) {
throw new Error('useSubscription has to be used within <SubscriptionContext.Provider>');
throw new Error("useSubscription has to be used within <SubscriptionContext.Provider>");
}
return ctx;
@@ -1 +1 @@
export { SubscriptionProvider, useSubscription } from './SubscriptionContext';
export { SubscriptionProvider, useSubscription } from "./SubscriptionContext";
@@ -1,7 +1,7 @@
import { createContext, ReactNode, useContext, useMemo } from 'react';
import { createContext, ReactNode, useContext, useMemo } from "react";
import { useGetUser } from '@app/hooks/api';
import { User } from '@app/hooks/api/types';
import { useGetUser } from "@app/hooks/api";
import { User } from "@app/hooks/api/types";
type TUserContext = {
user: User;
@@ -31,7 +31,7 @@ export const UserProvider = ({ children }: Props): JSX.Element => {
export const useUser = () => {
const ctx = useContext(UserContext);
if (!ctx) {
throw new Error('useUser has to be used within <UserContext.Provider>');
throw new Error("useUser has to be used within <UserContext.Provider>");
}
return ctx;
+1 -1
View File
@@ -1 +1 @@
export { UserProvider, useUser } from './UserContext';
export { UserProvider, useUser } from "./UserContext";
@@ -1,8 +1,8 @@
import { createContext, ReactNode, useContext, useMemo } from 'react';
import { useRouter } from 'next/router';
import { createContext, ReactNode, useContext, useMemo } from "react";
import { useRouter } from "next/router";
import { useGetUserWorkspaces } from '@app/hooks/api';
import { Workspace } from '@app/hooks/api/workspace/types';
import { useGetUserWorkspaces } from "@app/hooks/api";
import { Workspace } from "@app/hooks/api/workspace/types";
type TWorkspaceContext = {
workspaces: Workspace[];
@@ -23,7 +23,7 @@ export const WorkspaceProvider = ({ children }: Props): JSX.Element => {
// memorize the workspace details for the context
const value = useMemo<TWorkspaceContext>(() => {
const wsId = workspaceId || localStorage.getItem('projectData.id');
const wsId = workspaceId || localStorage.getItem("projectData.id");
return {
workspaces: ws || [],
currentWorkspace: (ws || []).find(({ _id: id }) => id === wsId),
@@ -37,7 +37,7 @@ export const WorkspaceProvider = ({ children }: Props): JSX.Element => {
export const useWorkspace = () => {
const ctx = useContext(WorkspaceContext);
if (!ctx) {
throw new Error('useWorkspace has to be used within <WorkspaceContext.Provider>');
throw new Error("useWorkspace has to be used within <WorkspaceContext.Provider>");
}
return ctx;
@@ -1 +1 @@
export { useWorkspace, WorkspaceProvider } from './WorkspaceContext';
export { useWorkspace, WorkspaceProvider } from "./WorkspaceContext";
+5 -5
View File
@@ -1,5 +1,5 @@
export { AuthProvider } from './AuthContext';
export { OrgProvider, useOrganization } from './OrganizationContext';
export { SubscriptionProvider, useSubscription } from './SubscriptionContext';
export { UserProvider, useUser } from './UserContext';
export { useWorkspace, WorkspaceProvider } from './WorkspaceContext';
export { AuthProvider } from "./AuthContext";
export { OrgProvider, useOrganization } from "./OrganizationContext";
export { SubscriptionProvider, useSubscription } from "./SubscriptionContext";
export { UserProvider, useUser } from "./UserContext";
export { useWorkspace, WorkspaceProvider } from "./WorkspaceContext";