Skip to content

Commit

Permalink
configure prettier as pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
talhainvenxion committed Apr 8, 2023
1 parent 025eeb5 commit 4a62e1b
Show file tree
Hide file tree
Showing 81 changed files with 1,596 additions and 1,235 deletions.
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
yarn prettier:fix && git add .
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@
"lint": "eslint './src/**/*.ts*'",
"fix-lint": "eslint './src/**/*.ts*' --fix",
"tslint": "tsc",
"all": "eslint './src/**/*.ts*' & react-scripts test --all & tsc"
"prettier:fix": "prettier --write './src/**/*.{ts,tsx}'",
"prettier:check": "prettier --check './src/**/*.{ts,tsx}'",
"all": "eslint './src/**/*.ts*' & react-scripts test --all & tsc",
"prepare": "husky install"
},
"browserslist": {
"production": [
Expand All @@ -104,7 +107,8 @@
"postcss": "^8.4.16",
"prettier": "^2.0.5",
"react-hooks-testing-library": "^0.6.0",
"react-test-renderer": "^16.13.1"
"react-test-renderer": "^16.13.1",
"husky": "^8.0.0"
},
"engines": {
"npm": ">=6.14.17",
Expand Down
2 changes: 1 addition & 1 deletion src/api/apiUrl.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { BASE_API_URL } from './constants';

export const apiUrl = (url: string) => `${BASE_API_URL}${url}`;
export const apiUrl = (url: string) => `${BASE_API_URL}${url}`;
2 changes: 1 addition & 1 deletion src/api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const httpMethods = {
export const BASE_API_URL = process.env.REACT_APP_BASE_API_URL;

// https://appserver.zenml.io/api/v1
// http://localhost:8080/api/v1
// http://localhost:8080/api/v1
2 changes: 1 addition & 1 deletion src/api/organizations/deleteInviteApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ const deleteInviteApi = ({
authenticationToken,
});

export default deleteInviteApi;
export default deleteInviteApi;
6 changes: 3 additions & 3 deletions src/api/session/emailUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const emailUpdate = ({
name,
authenticationToken,
}: {
userId: string,
fullName: string
userId: string;
fullName: string;
name: string;
authenticationToken: string;
}): Promise<TUser> =>
Expand All @@ -24,4 +24,4 @@ const emailUpdate = ({
data: { full_name: fullName, name },
});

export default emailUpdate;
export default emailUpdate;
10 changes: 5 additions & 5 deletions src/api/session/saveUserEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const SaveUserEmail = ({
email_opted_in,
authenticationToken,
}: {
userId: string,
email: string,
email_opted_in: any,
authenticationToken: string,
userId: string;
email: string;
email_opted_in: any;
authenticationToken: string;
}): Promise<TUser> =>
fetchApiWithAuthRequest({
url: apiUrl(endpoints.userEmail(userId)),
Expand All @@ -24,4 +24,4 @@ const SaveUserEmail = ({
data: { email, email_opted_in },
});

export default SaveUserEmail;
export default SaveUserEmail;
2 changes: 1 addition & 1 deletion src/api/testUtils/mockFetchApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const getMockFetchApi = () => jest.fn();

export const getMockFetchApiResponse = (): any =>
new Promise(resolve => resolve());
new Promise((resolve) => resolve());
2 changes: 1 addition & 1 deletion src/api/workspaces/getMyWorkspaceStatsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ const getMyWorkspaceStatsApi = ({
authenticationToken,
});

export default getMyWorkspaceStatsApi;
export default getMyWorkspaceStatsApi;
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export * from './stripe';

export const DEFAULT_FULL_NAME = 'Jane Doe';
export const ID_MAX_LENGTH = 8;
export const DEFAULT_WORKSPACE_NAME = 'default'
export const DEFAULT_WORKSPACE_NAME = 'default';
8 changes: 4 additions & 4 deletions src/redux/actionTypes/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { generateApiActionsTypes } from './generateApiActionsTypes';
export const ACCOUNT_LOGOUT = actionTypes.LOGOUT;

export const loginActionTypes = generateApiActionsTypes(
actionTypes.ACCOUNT_LOGIN
actionTypes.ACCOUNT_LOGIN,
);

export const signupActionTypes = generateApiActionsTypes(
actionTypes.ACCOUNT_SIGNUP
actionTypes.ACCOUNT_SIGNUP,
);

export const forgotActionTypes = generateApiActionsTypes(
actionTypes.FORGOT_PASSWORD
actionTypes.FORGOT_PASSWORD,
);

export const updateEmailTypes = generateApiActionsTypes(
actionTypes.UPDATE_EMAIL
actionTypes.UPDATE_EMAIL,
);
8 changes: 6 additions & 2 deletions src/redux/actionTypes/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { actionTypes } from './constants';
import { generateApiActionsTypes } from './generateApiActionsTypes';

export const workspaceActionTypes = {
getMyWorkspaces: generateApiActionsTypes(actionTypes.WORKSPACES_GET_MY_WORKSPACES),
getMyWorkspaceStats: generateApiActionsTypes(actionTypes.GET_MY_WORKSPACE_STATS),
getMyWorkspaces: generateApiActionsTypes(
actionTypes.WORKSPACES_GET_MY_WORKSPACES,
),
getMyWorkspaceStats: generateApiActionsTypes(
actionTypes.GET_MY_WORKSPACE_STATS,
),
selectWorkspace: generateApiActionsTypes(
actionTypes.SELECT_WORKSPACE_FROM_MY_WORKSPACES,
),
Expand Down
2 changes: 1 addition & 1 deletion src/redux/actions/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { emailUpdateAction } from './emailUpdate';
export const sessionActions = {
logout: logoutAction,
forgotPassword: forgotAction,
emailUpdate: emailUpdateAction
emailUpdate: emailUpdateAction,
};
2 changes: 1 addition & 1 deletion src/redux/actions/session/signupAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const signUpAction = ({
username,
fullName,
password,
token,
token,
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion src/redux/reducers/rolesReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const newState = (roles: Roles[]): State => ({
const rolesReducer = (state: State = initialState, action: Action): State => {
switch (action.type) {
case rolesActionTypes.getRoles.success: {
const roles: Roles[] = camelCaseArray(action.payload?.items as RolesPayload);
const roles: Roles[] = camelCaseArray(
action.payload?.items as RolesPayload,
);

return { ...newState(roles) };
}
Expand Down
8 changes: 6 additions & 2 deletions src/redux/reducers/workspacesReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const workspacesReducer = (
const workspaces: Workspaces[] = camelCaseArray(
action.payload.items as WorkspacesPayload,
);

const myWorkspaceIds: TId[] = workspaces.map(
(workspace: Workspaces) => workspace.id,
);
Expand All @@ -63,7 +63,11 @@ const workspacesReducer = (
};
} else {
return {
...newState(state, workspaces, action.requestParams.selectedWorkspace),
...newState(
state,
workspaces,
action.requestParams.selectedWorkspace,
),
myWorkspaceIds,
};
}
Expand Down
6 changes: 2 additions & 4 deletions src/redux/selectors/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const getSelectedWorkspaceIds = (state: State): string =>
const getWorkspaceStats = (state: State): any =>
_.get(stateKey(state), 'workspaceStats');


export const myWorkspaces = (state?: State | null): Workspaces[] => {
if (!state) return [];
const myWorkspaceIds = getMyWorkspaceIds(state);
Expand Down Expand Up @@ -45,11 +44,10 @@ export const workspaceStats = (state?: State | null): string => {
return workspaceStats;
};


const workspaceSelectors = {
myWorkspaces: myWorkspaces,
selectedWorkspace: selectedWorkspace,
myWorkspaceStats: workspaceStats
myWorkspaceStats: workspaceStats,
};

export { workspaceSelectors };
export { workspaceSelectors };
2 changes: 1 addition & 1 deletion src/redux/setup/storeSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import rootSaga from '../rootSaga';
import { persistedReducer, persistConfig } from './storeReduxSetup';

function crossBrowserListener(store: any, persistConfig: any) {
return async function() {
return async function () {
const state = await getStoredState(persistConfig);

store.dispatch({
Expand Down
10 changes: 5 additions & 5 deletions src/serviceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function register(config?: Config) {
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
Expand Down Expand Up @@ -103,7 +103,7 @@ function registerValidSW(swUrl: string, config?: Config) {
};
};
})
.catch(error => {
.catch((error) => {
console.error('Error during service worker registration:', error);
});
}
Expand All @@ -113,15 +113,15 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then(response => {
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
Expand All @@ -140,7 +140,7 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {

export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister();
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/ui/components/buttons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const PrimaryButton: React.FC<
<div className={styles.spinner}>
<Spinner size="xs" color="white" />
</div>
) : (children)}
) : (
children
)}
</button>
);

Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/logos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export const ZenMLLogoWhite: React.FC = () => (

export const ZenMLLogoSmall: React.FC = () => (
<Image style={{ width: 36, height: 36 }} src={logoSmallWhite} />
);
);
2 changes: 1 addition & 1 deletion src/ui/components/separators/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export const SeparatorNew: React.FC = () => (

export const Separator = {
Light: SeparatorLight,
LightNew: SeparatorNew
LightNew: SeparatorNew,
};
Loading

0 comments on commit 4a62e1b

Please sign in to comment.