Skip to content

Commit

Permalink
Update devDependencies; Fix @typescript-eslint/no-redeclare. (#974)
Browse files Browse the repository at this point in the history
* npm update; npm i (react-toastify, redux-persist)@latest

* npm i typescript@latest

* fix @typescript-eslint/no-redeclare

* Improve for potential future expansion.

* Update CreateProject unit tests.

* Merge in 'master'.

* Merge branch 'master' into npm-update
  • Loading branch information
imnasnainaec authored Feb 4, 2021
1 parent 57d748d commit b4e988b
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 93 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@
"@testing-library/user-event": "^12.6.3",
"@types/jest": "^26.0.20",
"@types/loadable__component": "^5.13.1",
"@types/node": "^14.14.22",
"@types/node": "^14.14.25",
"@types/nspell": "^2.1.0",
"@types/react": "^17.0.1",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-modal": "^3.10.5",
"@types/react-modal": "^3.12.0",
"@types/react-redux": "^7.1.16",
"@types/react-router-dom": "^5.1.7",
"@types/react-test-renderer": "^17.0.0",
Expand All @@ -122,6 +122,6 @@
"prettier": "2.2.1",
"react-test-renderer": "^17.0.1",
"redux-mock-store": "^1.5.4",
"typescript": "^3.9.7"
"typescript": "^4.1.3"
}
}
43 changes: 13 additions & 30 deletions src/components/Login/LoginActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,31 @@ import { StoreStateDispatch } from "types/actions";
import { User } from "types/user";

export const LOGIN_ATTEMPT = "LOGIN_ATTEMPT";
export type LOGIN_ATTEMPT = typeof LOGIN_ATTEMPT;

export const LOGIN_FAILURE = "LOGIN_FAILURE";
export type LOGIN_FAILURE = typeof LOGIN_FAILURE;

export const LOGIN_SUCCESS = "LOGIN_SUCCESS";
export type LOGIN_SUCCESS = typeof LOGIN_SUCCESS;

export const LOGIN_RESET = "LOGIN_RESET";
export type LOGIN_RESET = typeof LOGIN_RESET;

export const LOGIN_SUCCESS = "LOGIN_SUCCESS";
export const LOGOUT = "LOGOUT";
export type LOGOUT = typeof LOGOUT;

export const REGISTER_ATTEMPT = "REGISTER_ATTEMPT";
export type REGISTER_ATTEMPT = typeof REGISTER_ATTEMPT;

export const REGISTER_SUCCESS = "REGISTER_SUCCESS";
export type REGISTER_SUCCESS = typeof REGISTER_SUCCESS;

export const REGISTER_FAILURE = "REGISTER_FAILURE";
export type REGISTER_FAILURE = typeof REGISTER_FAILURE;

export const REGISTER_RESET = "REGISTER_RESET";
export type REGISTER_RESET = typeof REGISTER_RESET;
export const REGISTER_SUCCESS = "REGISTER_SUCCESS";

export type LoginType =
| typeof LOGIN_ATTEMPT
| typeof LOGIN_FAILURE
| typeof LOGIN_SUCCESS
| typeof LOGIN_RESET
| typeof REGISTER_ATTEMPT
| typeof REGISTER_FAILURE
| typeof REGISTER_SUCCESS
| typeof REGISTER_RESET
| typeof LOGOUT;

export interface LoginData {
username: string;
password?: string;
}

export type LoginType =
| LOGIN_ATTEMPT
| LOGIN_FAILURE
| LOGIN_SUCCESS
| LOGIN_RESET
| REGISTER_ATTEMPT
| REGISTER_FAILURE
| REGISTER_SUCCESS
| REGISTER_RESET
| LOGOUT;

export interface UserAction {
type: LoginType;
payload: LoginData;
Expand Down
22 changes: 10 additions & 12 deletions src/components/PasswordReset/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@ import history, { Path } from "browserHistory";
import { StoreStateDispatch } from "types/actions";

export const RESET_PASSWORD_ATTEMPT = "RESET_PASSWORD_ATTEMPT";
export type RESET_PASSWORD_ATTEMPT = typeof RESET_PASSWORD_ATTEMPT;

export const RESET_PASSWORD_FAIL = "RESET_PASSWORD_FAIL";
export const RESET_PASSWORD_SUCCESS = "RESET_PASSWORD_SUCCESS";
export type RESET_PASSWORD_SUCCESS = typeof RESET_PASSWORD_SUCCESS;

export const RESET_PASSWORD_FAIL = "RESET_PASSWORD_FAIL";
export type RESET_PASSWORD_FAIL = typeof RESET_PASSWORD_FAIL;
type ResetActionType =
| typeof RESET_PASSWORD_ATTEMPT
| typeof RESET_PASSWORD_FAIL
| typeof RESET_PASSWORD_SUCCESS;

export interface ResetAction {
type: RESET_PASSWORD_ATTEMPT | RESET_PASSWORD_FAIL | RESET_PASSWORD_SUCCESS;
type: ResetActionType;
}

export function resetAttempt(): ResetAction {
return {
type: RESET_PASSWORD_ATTEMPT,
};
}

export function resetSuccess(): ResetAction {
export function resetFail(): ResetAction {
return {
type: RESET_PASSWORD_SUCCESS,
type: RESET_PASSWORD_FAIL,
};
}

export function resetFail(): ResetAction {
export function resetSuccess(): ResetAction {
return {
type: RESET_PASSWORD_FAIL,
type: RESET_PASSWORD_SUCCESS,
};
}

Expand Down
7 changes: 2 additions & 5 deletions src/components/Project/ProjectActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { StoreStateDispatch } from "types/actions";
import { Project } from "types/project";

export const SET_CURRENT_PROJECT = "SET_CURRENT_PROJECT";
export type SET_CURRENT_PROJECT = typeof SET_CURRENT_PROJECT;

type ProjectType = SET_CURRENT_PROJECT;

//action types
type ProjectActionType = typeof SET_CURRENT_PROJECT;

export interface ProjectAction {
type: ProjectType;
type: ProjectActionType;
payload: Project;
}

Expand Down
34 changes: 15 additions & 19 deletions src/components/ProjectScreen/CreateProject/CreateProjectActions.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import * as backend from "backend";
import history, { Path } from "browserHistory";
import { StoreStateDispatch } from "types/actions";
import { defaultProject, Project, WritingSystem } from "types/project";
import { asyncCreateUserEdits } from "components/GoalTimeline/GoalsActions";
import { setCurrentProject } from "components/Project/ProjectActions";
import { StoreStateDispatch } from "types/actions";
import { defaultProject, Project, WritingSystem } from "types/project";

export const IN_PROGRESS = "CREATE_PROJECT_IN_PROGRESS";
export type IN_PROGRESS = typeof IN_PROGRESS;

export const SUCCESS = "CREATE_PROJECT_SUCCESS";
export type SUCCESS = typeof SUCCESS;

export const FAILURE = "CREATE_PROJECT_FAILURE";
export type FAILURE = typeof FAILURE;
export const CREATE_PROJECT_FAILURE = "CREATE_PROJECT_FAILURE";
export const CREATE_PROJECT_IN_PROGRESS = "CREATE_PROJECT_IN_PROGRESS";
export const CREATE_PROJECT_RESET = "CREATE_PROJECT_RESET";
export const CREATE_PROJECT_SUCCESS = "CREATE_PROJECT_SUCCESS";

export const RESET = "CREATE_PROJECT_RESET";
export type RESET = typeof RESET;
type CreateProjectType =
| typeof CREATE_PROJECT_FAILURE
| typeof CREATE_PROJECT_IN_PROGRESS
| typeof CREATE_PROJECT_RESET
| typeof CREATE_PROJECT_SUCCESS;

export interface CreateProjectData {
name: string;
Expand All @@ -24,9 +23,6 @@ export interface CreateProjectData {
languageData?: File;
errorMsg?: string;
}
type CreateProjectType = IN_PROGRESS | SUCCESS | FAILURE | RESET;

//action types

export interface CreateProjectAction {
type: CreateProjectType;
Expand Down Expand Up @@ -106,7 +102,7 @@ export function inProgress(
analysisLanguages: WritingSystem[]
): CreateProjectAction {
return {
type: IN_PROGRESS,
type: CREATE_PROJECT_IN_PROGRESS,
payload: { name, vernacularLanguage, analysisLanguages },
};
}
Expand All @@ -117,7 +113,7 @@ export function success(
analysisLanguages: WritingSystem[]
): CreateProjectAction {
return {
type: SUCCESS,
type: CREATE_PROJECT_SUCCESS,
payload: { name, vernacularLanguage, analysisLanguages },
};
}
Expand All @@ -129,14 +125,14 @@ export function failure(
errorMsg: string = ""
): CreateProjectAction {
return {
type: FAILURE,
type: CREATE_PROJECT_FAILURE,
payload: { name, errorMsg, vernacularLanguage, analysisLanguages },
};
}

export function reset(): CreateProjectAction {
return {
type: RESET,
type: CREATE_PROJECT_RESET,
payload: {
name: "",
vernacularLanguage: { name: "", bcp47: "", font: "" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
IN_PROGRESS,
SUCCESS,
FAILURE,
RESET,
CREATE_PROJECT_IN_PROGRESS,
CREATE_PROJECT_SUCCESS,
CREATE_PROJECT_FAILURE,
CREATE_PROJECT_RESET,
CreateProjectAction,
} from "components/ProjectScreen/CreateProject/CreateProjectActions";
import { Project, WritingSystem } from "types/project";
Expand Down Expand Up @@ -32,7 +32,7 @@ export const createProjectReducer = (
action: StoreAction | CreateProjectAction
): CreateProjectState => {
switch (action.type) {
case IN_PROGRESS:
case CREATE_PROJECT_IN_PROGRESS:
return {
name: action.payload.name,
vernacularLanguage: action.payload.vernacularLanguage,
Expand All @@ -41,7 +41,7 @@ export const createProjectReducer = (
inProgress: true,
errorMsg: "",
};
case SUCCESS:
case CREATE_PROJECT_SUCCESS:
return {
name: action.payload.name,
vernacularLanguage: action.payload.vernacularLanguage,
Expand All @@ -50,7 +50,7 @@ export const createProjectReducer = (
inProgress: false,
errorMsg: "",
};
case FAILURE:
case CREATE_PROJECT_FAILURE:
return {
name: action.payload.name,
vernacularLanguage: action.payload.vernacularLanguage,
Expand All @@ -59,7 +59,7 @@ export const createProjectReducer = (
inProgress: false,
errorMsg: action.payload.errorMsg || "",
};
case RESET:
case CREATE_PROJECT_RESET:
return defaultState;
case StoreActions.RESET:
return defaultState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const project = {
describe("CreateProjectAction Tests", () => {
let mockState: reducer.CreateProjectState = reducer.defaultState;
let CreateProject: action.CreateProjectAction = {
type: action.IN_PROGRESS,
type: action.CREATE_PROJECT_IN_PROGRESS,
payload: {
name: project.name,
vernacularLanguage: project.vernacularLanguage,
Expand All @@ -43,7 +43,7 @@ describe("CreateProjectAction Tests", () => {
project.analysisLanguages
)
).toEqual({
type: action.IN_PROGRESS,
type: action.CREATE_PROJECT_IN_PROGRESS,
payload: {
name: project.name,
vernacularLanguage: project.vernacularLanguage,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { StoreAction, StoreActions } from "rootActions";
import {
CREATE_PROJECT_IN_PROGRESS,
CREATE_PROJECT_RESET,
CreateProjectAction,
IN_PROGRESS,
RESET,
} from "components/ProjectScreen/CreateProject/CreateProjectActions";
import * as reducer from "components/ProjectScreen/CreateProject/CreateProjectReducer";

Expand Down Expand Up @@ -30,15 +30,15 @@ describe("createActionReducer Tests", () => {
};

let inProgress: CreateProjectAction = {
type: IN_PROGRESS,
type: CREATE_PROJECT_IN_PROGRESS,
payload: project,
};

// Test with no state
test("no state, expecting default state", () => {
expect(
reducer.createProjectReducer(undefined, {
type: RESET,
type: CREATE_PROJECT_RESET,
payload: project,
})
).toEqual(reducer.defaultState);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",
"downlevelIteration": true,
"baseUrl": "src",
"noFallthroughCasesInSwitch": true
Expand Down

0 comments on commit b4e988b

Please sign in to comment.