Skip to content

Commit

Permalink
Merge pull request #146 from thorgate/feat/rtk-migration
Browse files Browse the repository at this point in the history
feat: Migrate to @redux/toolkit
  • Loading branch information
jorgenader authored Mar 26, 2021
2 parents 4244fc8 + 111e620 commit d61fd05
Show file tree
Hide file tree
Showing 65 changed files with 2,684 additions and 1,941 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ module.exports = {

'@typescript-eslint/no-explicit-any': 'off', // warn
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/camelcase': [
'error',
{ allow: ['non_field_errors'] },
],
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
- name: Lint tools
run: yarn lint
- name: Run tests
env:
NODE_OPTIONS: --max_old_space_size=4096
run: yarn testAll
- name: Coveralls
uses: coverallsapp/github-action@master
Expand Down
2 changes: 1 addition & 1 deletion examples/example-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-helmet": "^5.2.0",
"react-redux": "^7.1.0",
"react-redux": "^7.2.2",
"react-router": "^5.2.0",
"react-router-config": "^5.1.1",
"react-router-dom": "^5.2.0",
Expand Down
42 changes: 0 additions & 42 deletions greenkeeper.json

This file was deleted.

36 changes: 20 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
{
"private": true,
"name": "tg-spa-utils-root",
"prettier": "@thorgate/prettier-config",
"workspaces": [
"examples/*",
"packages/*"
],
"devDependencies": {
"@reduxjs/toolkit": "^1.5.0",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-replace": "^2.4.1",
"@testing-library/jest-dom": "^5.1.1",
"@testing-library/react": "^9.4.0",
"@testing-library/react-hooks": "^3.2.1",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/react-hooks": "^5.1.0",
"@tg-resources/core": "^3.1.3",
"@tg-resources/redux-saga-router": "^3.1.3",
"@thorgate/prettier-config": "1.0.1",
"@types/express": "^4.17.2",
"@types/is": "^0.0.21",
"@types/jest": "^25.1.2",
"@types/jest": "^26.0.20",
"@types/lru-cache": "^5.1.0",
"@types/node": "^13.7.0",
"@types/qs": "^6.9.1",
"@types/react": "^16.9.19",
"@types/react-dom": "^16.9.5",
"@types/react-redux": "^7.1.7",
"@types/react-redux": "^7.1.16",
"@types/react-router": "^5.1.12",
"@types/react-router-config": "^5.0.2",
"@types/react-router-dom": "^5.1.7",
"@types/uuid": "^3.4.7",
"@types/warning": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^2.19.0",
"@typescript-eslint/parser": "^2.19.0",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"check-engines": "^1.5.0",
"connected-react-router": "^6.9.1",
"coveralls": "*",
"dtslint": "4.0.7",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
Expand All @@ -42,22 +45,22 @@
"formik": "^2.1.4",
"history": "^4.10.1",
"i18next": "^19.9.1",
"jest": "^25.1.0",
"jest-cli": "^25.1.0",
"jest": "^26.6.3",
"jest-cli": "^26.6.3",
"lerna": "^3.20.2",
"lodash.template": "^4.5.0",
"lru-cache": "^5.1.1",
"normalizr": "^3.5.0",
"path-to-regexp": "^6.1.0",
"prettier": "1.19.1",
"prettier": "2.2.1",
"qs": "^6.9.1",
"razzle": "^3.3.0",
"razzle-plugin-eslint": "^3.3.0",
"razzle-plugin-scss": "^3.3.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-i18next": "^11.8.8",
"react-redux": "^7.1.3",
"react-redux": "^7.2.2",
"react-router": "^5.2.0",
"react-router-config": "^5.1.1",
"react-router-dom": "^5.2.0",
Expand All @@ -68,9 +71,9 @@
"rollup": "^2.40.0",
"rollup-plugin-typescript2": "^0.30.0",
"tg-resources": "^3.1.3",
"ts-jest": "^25.2.0",
"tslib": "^1.10.0",
"typescript": "3.7.5",
"ts-jest": "^26.5.3",
"tslib": "^2.1.0",
"typescript": "4.2.3",
"uuid": "^3.4.0"
},
"scripts": {
Expand All @@ -82,10 +85,11 @@
"show-formatting": "prettier 'packages/**/src/**/*.{ts,tsx}'",
"code-format": "prettier --write 'packages/**/src/**/*.{ts,tsx}'",
"lint": "yarn check-formatting && lerna --ignore=example-razzle-app exec yarn lint",
"type-check": "lerna run type-check",
"test": "jest",
"testAll": "yarn test:coverage && yarn test:examples",
"test:examples": "lerna --scope example-* exec -- yarn test --coverage",
"test:coverage": "yarn test --coverage --maxWorkers=2",
"test:coverage": "yarn test --coverage --runInBand",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"check-packages": "yarn clean && yarn build && yarn test && yarn lint",
"bump-version": "lerna --ignore=examples/* version --exact",
Expand Down
69 changes: 0 additions & 69 deletions packages/create-resource-saga/src/actionCreator.ts

This file was deleted.

46 changes: 0 additions & 46 deletions packages/create-resource-saga/src/actionType.ts

This file was deleted.

5 changes: 1 addition & 4 deletions packages/create-resource-saga/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export { createResourceAction, getResourceType } from './actionCreator';

export { resourceAction } from './actionType';

export { getBaseConfig, setBaseConfig } from './configuration';

export { createResourceSaga } from './sagaCreator';
Expand All @@ -10,6 +6,7 @@ export {
MetaOptions,
ResourceActionPayload,
ResourcePayloadMetaAction,
ResourceActionCreator,
ResourceSaga,
ResourceSagaConfig,
ResourceSagaOptions,
Expand Down
38 changes: 6 additions & 32 deletions packages/create-resource-saga/src/sagaCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,16 @@ import {
* @param options - Options to configure resource saga
*/
export function createResourceSaga<
ResourceType extends TypeConstant,
Klass extends Resource,
KW extends Kwargs<KW>,
Params extends Kwargs<Params>,
Data = any,
Meta = undefined
>(
options: ResourceSagaOptions<ResourceType, Klass, KW, Params, Data, Meta>
): ResourceSaga<ResourceType, Klass, KW, Params, Data, Meta> {
options: ResourceSagaOptions<Klass, KW, Params, Data, Meta>
): ResourceSaga<Klass, KW, Params, Data, Meta> {
function createCloneableSaga(
config: ResourceSagaOptions<
ResourceType,
Klass,
KW,
Params,
Data,
Meta
> = {}
config: ResourceSagaOptions<Klass, KW, Params, Data, Meta> = {}
) {
const mergedOptions = { ...options, ...config };

Expand All @@ -53,21 +45,10 @@ export function createResourceSaga<

function* resourceSaga(
matchObj: match<Params> | null,
action: ResourcePayloadMetaAction<
ResourceType,
TypeConstant,
KW,
Data,
Meta
>
action: ResourcePayloadMetaAction<TypeConstant, KW, Data, Meta>
) {
// Expect action created with createResourceAction
validateResourceAction(action.type, 'type', 'Action');
validateResourceAction(
action.resourceType,
'resourceType',
'Action'
);

const { payload } = action;

Expand Down Expand Up @@ -125,14 +106,7 @@ export function createResourceSaga<

return Object.assign(resourceSaga, {
cloneSaga: (
override: ResourceSagaOptions<
ResourceType,
Klass,
KW,
Params,
Data,
Meta
>
override: ResourceSagaOptions<Klass, KW, Params, Data, Meta>
) => createCloneableSaga(override),

getConfiguration: () => ({
Expand All @@ -144,5 +118,5 @@ export function createResourceSaga<
});
}

return createCloneableSaga();
return createCloneableSaga() as ResourceSaga<Klass, KW, Params, Data, Meta>;
}
Loading

0 comments on commit d61fd05

Please sign in to comment.