Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Commit

Permalink
Merge fc53e5b into 93fc6ad
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Oct 17, 2020
2 parents 93fc6ad + fc53e5b commit f656e0a
Show file tree
Hide file tree
Showing 34 changed files with 4,001 additions and 2,868 deletions.
14 changes: 7 additions & 7 deletions .eslintrc.js
Expand Up @@ -5,20 +5,20 @@ module.exports = {
ecmaVersion: 7,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true
jsx: true,
},
sourceType: 'module'
sourceType: 'module',
},
extends: ['plugin:jest/recommended', 'prettier'],
plugins: ['json', 'prettier'],
env: {
es6: true,
node: true
node: true,
},
globals: {
document: false,
navigator: false,
window: false
window: false,
},
rules: {
'accessor-pairs': 'error',
Expand Down Expand Up @@ -111,7 +111,7 @@ module.exports = {
'spaced-comment': [
'error',
'always',
{ markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }
{ markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] },
],
'use-isnan': 'error',
'valid-typeof': 'error',
Expand All @@ -127,6 +127,6 @@ module.exports = {
'jest/prefer-to-have-length': 'error',
'jest/valid-describe': 'error',
'jest/valid-expect': 'error',
'jest/valid-expect-in-promise': 'error'
}
'jest/valid-expect-in-promise': 'error',
},
};
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

4 changes: 3 additions & 1 deletion .travis.yml
@@ -1,6 +1,8 @@
language: node_js
node_js:
- "8"
- '10'
- '12'
- '14'
script:
- npm run lint:ci
- npm run test:ci
Expand Down
4 changes: 2 additions & 2 deletions examples/github/index.js
Expand Up @@ -11,8 +11,8 @@ const request = https.request(
path: '/repos/paularmstrong/normalizr/issues',
method: 'get',
headers: {
'user-agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'
}
'user-agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)',
},
},
(res) => {
res.on('data', (d) => {
Expand Down
8 changes: 4 additions & 4 deletions examples/github/schema.js
Expand Up @@ -5,29 +5,29 @@ export const user = new schema.Entity('users');
export const label = new schema.Entity('labels');

export const milestone = new schema.Entity('milestones', {
creator: user
creator: user,
});

export const issue = new schema.Entity('issues', {
assignee: user,
assignees: [user],
labels: label,
milestone,
user
user,
});

export const pullRequest = new schema.Entity('pullRequests', {
assignee: user,
assignees: [user],
labels: label,
milestone,
user
user,
});

export const issueOrPullRequest = new schema.Array(
{
issues: issue,
pullRequests: pullRequest
pullRequests: pullRequest,
},
(entity) => (entity.pull_request ? 'pullRequests' : 'issues')
);
34 changes: 17 additions & 17 deletions examples/redux/index.js
Expand Up @@ -18,8 +18,8 @@ const start = () => {
return 'Repo slug must be in the form "user/project"';
}
return true;
}
}
},
},
])
.then(({ repo }) => {
store.dispatch(Action.setRepo(repo));
Expand All @@ -34,8 +34,8 @@ const main = () => {
type: 'list',
name: 'action',
message: 'What would you like to do?',
choices: ['Browse current state', 'Get new data', new inquirer.Separator(), 'Quit']
}
choices: ['Browse current state', 'Get new data', new inquirer.Separator(), 'Quit'],
},
])
.then(({ action }) => {
switch (action) {
Expand All @@ -62,10 +62,10 @@ const browseMain = () => {
new inquirer.Separator(),
...Object.keys(store.getState()).map((value) => ({ value, name: `Browse ${value}` })),
new inquirer.Separator(),
{ value: 'main', name: 'Go Back to Main Menu' }
{ value: 'main', name: 'Go Back to Main Menu' },
];
}
}
},
},
])
.then((answers) => {
switch (answers.browseMainAction) {
Expand Down Expand Up @@ -95,16 +95,16 @@ const browse = (stateKey) => {
{ value: 'denormalize', name: 'Denormalize' },
new inquirer.Separator(),
{ value: 'browseMain', name: 'Go Back to Browse Menu' },
{ value: 'main', name: 'Go Back to Main Menu' }
]
{ value: 'main', name: 'Go Back to Main Menu' },
],
},
{
type: 'list',
name: 'list',
message: `Select the ${stateKey} to view:`,
choices: Object.keys(store.getState()[stateKey]),
when: ({ action }) => action === 'view'
}
when: ({ action }) => action === 'view',
},
])
.then(({ action, list }) => {
const state = store.getState()[stateKey];
Expand Down Expand Up @@ -144,9 +144,9 @@ const browseDenormalized = (stateKey) => {
...Object.keys(store.getState()[stateKey]),
new inquirer.Separator(),
{ value: 'browse', name: 'Go Back to Browse Menu' },
{ value: 'main', name: 'Go Back to Main Menu' }
]
}
{ value: 'main', name: 'Go Back to Main Menu' },
],
},
])
.then(({ selector }) => {
switch (selector) {
Expand Down Expand Up @@ -174,10 +174,10 @@ const pull = () => {
return [
...Object.keys(store.getState()).map((value) => ({ value, name: value })),
new inquirer.Separator(),
{ value: 'main', name: 'Go Back to Main Menu' }
{ value: 'main', name: 'Go Back to Main Menu' },
];
}
}
},
},
])
.then((answers) => {
switch (answers.pullAction) {
Expand Down
4 changes: 2 additions & 2 deletions examples/redux/src/api/index.js
Expand Up @@ -2,6 +2,6 @@ import GitHubApi from 'github';

export default new GitHubApi({
headers: {
'user-agent': 'Normalizr Redux Example'
}
'user-agent': 'Normalizr Redux Example',
},
});
10 changes: 5 additions & 5 deletions examples/redux/src/api/schema.js
Expand Up @@ -6,37 +6,37 @@ export const commit = new schema.Entity(
'commits',
{
author: user,
committer: user
committer: user,
},
{ idAttribute: 'sha' }
);

export const label = new schema.Entity('labels');

export const milestone = new schema.Entity('milestones', {
creator: user
creator: user,
});

export const issue = new schema.Entity('issues', {
assignee: user,
assignees: [user],
labels: [label],
milestone,
user
user,
});

export const pullRequest = new schema.Entity('pullRequests', {
assignee: user,
assignees: [user],
labels: [label],
milestone,
user
user,
});

export const issueOrPullRequest = new schema.Array(
{
issues: issue,
pullRequests: pullRequest
pullRequests: pullRequest,
},
(entity) => (entity.pull_request ? 'pullRequests' : 'issues')
);
2 changes: 1 addition & 1 deletion examples/redux/src/redux/actions.js
Expand Up @@ -8,5 +8,5 @@ export { setRepo } from './modules/repos';
export const ADD_ENTITIES = 'ADD_ENTITIES';
export const addEntities = (entities) => ({
type: ADD_ENTITIES,
payload: entities
payload: entities,
});
4 changes: 2 additions & 2 deletions examples/redux/src/redux/modules/commits.js
Expand Up @@ -10,7 +10,7 @@ export default function reducer(state = {}, action) {
case ADD_ENTITIES:
return {
...state,
...action.payload.commits
...action.payload.commits,
};

default:
Expand All @@ -25,7 +25,7 @@ export const getCommits = ({ page = 0 } = {}) => (dispatch, getState, { api, sch
return api.repos
.getCommits({
owner,
repo
repo,
})
.then((response) => {
const data = normalize(response, [schema.commit]);
Expand Down
4 changes: 2 additions & 2 deletions examples/redux/src/redux/modules/issues.js
Expand Up @@ -10,7 +10,7 @@ export default function reducer(state = {}, action) {
case ADD_ENTITIES:
return {
...state,
...action.payload.issues
...action.payload.issues,
};

default:
Expand All @@ -25,7 +25,7 @@ export const getIssues = ({ page = 0 } = {}) => (dispatch, getState, { api, sche
return api.issues
.getForRepo({
owner,
repo
repo,
})
.then((response) => {
const data = normalize(response, [schema.issue]);
Expand Down
4 changes: 2 additions & 2 deletions examples/redux/src/redux/modules/labels.js
Expand Up @@ -10,7 +10,7 @@ export default function reducer(state = {}, action) {
case ADD_ENTITIES:
return {
...state,
...action.payload.labels
...action.payload.labels,
};

default:
Expand All @@ -25,7 +25,7 @@ export const getLabels = ({ page = 0 } = {}) => (dispatch, getState, { api, sche
return api.issues
.getLabels({
owner,
repo
repo,
})
.then((response) => {
const data = normalize(response, [schema.label]);
Expand Down
4 changes: 2 additions & 2 deletions examples/redux/src/redux/modules/milestones.js
Expand Up @@ -10,7 +10,7 @@ export default function reducer(state = {}, action) {
case ADD_ENTITIES:
return {
...state,
...action.payload.milestones
...action.payload.milestones,
};

default:
Expand All @@ -25,7 +25,7 @@ export const getMilestones = ({ page = 0 } = {}) => (dispatch, getState, { api,
return api.issues
.getMilestones({
owner,
repo
repo,
})
.then((response) => {
const data = normalize(response, [schema.milestone]);
Expand Down
4 changes: 2 additions & 2 deletions examples/redux/src/redux/modules/pull-requests.js
Expand Up @@ -10,7 +10,7 @@ export default function reducer(state = {}, action) {
case ADD_ENTITIES:
return {
...state,
...action.payload.pullRequests
...action.payload.pullRequests,
};

default:
Expand All @@ -25,7 +25,7 @@ export const getPullRequests = ({ page = 0 } = {}) => (dispatch, getState, { api
return api.pullRequests
.getAll({
owner,
repo
repo,
})
.then((response) => {
const data = normalize(response, [schema.pullRequest]);
Expand Down
6 changes: 3 additions & 3 deletions examples/redux/src/redux/modules/repos.js
Expand Up @@ -5,7 +5,7 @@ export default function reducer(state = {}, action) {
case Action.SET_REPO:
return {
...state,
...action.payload
...action.payload,
};

default:
Expand All @@ -14,14 +14,14 @@ export default function reducer(state = {}, action) {
}

const Action = {
SET_REPO: 'SET_REPO'
SET_REPO: 'SET_REPO',
};

export const setRepo = (slug) => {
const [owner, repo] = slug.split('/');
return {
type: Action.SET_REPO,
payload: { owner, repo }
payload: { owner, repo },
};
};

Expand Down
4 changes: 2 additions & 2 deletions examples/redux/src/redux/modules/users.js
Expand Up @@ -12,8 +12,8 @@ export default function reducer(state = {}, action) {
...mergedUsers,
[id]: {
...(mergedUsers[id] || {}),
...user
}
...user,
},
};
}, state);

Expand Down
2 changes: 1 addition & 1 deletion examples/redux/src/redux/reducer.js
Expand Up @@ -14,7 +14,7 @@ const reducer = combineReducers({
[MILESTONES_STATE_KEY]: milestones,
[PULLREQUESTS_STATE_KEY]: pullRequests,
[REPO_STATE_KEY]: repos,
[USERS_STATE_KEY]: users
[USERS_STATE_KEY]: users,
});

export default reducer;

0 comments on commit f656e0a

Please sign in to comment.