Skip to content

Commit ff11fef

Browse files
committed
[CHORE]: Merged from upstream
2 parents db1b069 + 6eef68d commit ff11fef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+882
-739
lines changed

.eslintrc.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es6": true
5+
},
6+
7+
"globals": {
8+
"fetch": false
9+
},
10+
11+
"parserOptions": {
12+
"ecmaVersion": 8,
13+
"ecmaFeatures": {
14+
"arrowFunctions": true,
15+
"blockBindings": true,
16+
"classes": true,
17+
"defaultParameters": true,
18+
"destructuring": true,
19+
"forOf": true,
20+
"generators": true,
21+
"modules": true,
22+
"objectLiteralComputedProperties": true,
23+
"objectLiteralDuplicateProperties": true,
24+
"objectLiteralShorthandMethods": true,
25+
"objectLiteralShorthandProperties": true,
26+
"regexUFlag": true,
27+
"regexYFlag": true,
28+
"restParams": true,
29+
"spread": true,
30+
"superInFunctions": true,
31+
"templateStrings": true,
32+
"unicodeCodePointEscapes": true,
33+
"globalReturn": true
34+
},
35+
"sourceType": "module"
36+
},
37+
38+
"extends": "airbnb",
39+
40+
"rules": {
41+
"arrow-parens": 0,
42+
"no-param-reassign": 0,
43+
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
44+
}
45+
}
46+
47+
// https://eslint.org/docs/rules/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__tests__/data

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tabWidth: 2
2+
useTabs: false
3+
semi: true
4+
singleQuote: true
5+
trailingComma: all
6+
bracketSpacing: true
7+
jsxBracketSameLine: false
8+
arrowParens: avoid
9+
parser: flow
10+
printWidth: 80

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing
2+
3+
To contribute to hackd, clone/fork the repository, make changes and open a PR with your changes. Any type of change is welcomed, including bug fixes, new features, documentation or tests.
4+
5+
Opening issues for bugs, features or anything else is also welcomed.
6+
7+
If you are implementing a new feature, or modifying styles, please replace/add screenshot(s) to the [README](README.md).
8+
9+
### Prettier
10+
11+
[Prettier](https://github.com/prettier/prettier) is used to keep a consistent code style across the project. Before committing, run `npm run prettier` which will transform your code to fit the projects style.
12+
13+
### ESLint
14+
15+
[ESLint](https://github.com/eslint/eslint) is used for code linting inside your IDE/text editor. If you don't have ESLint installed in your editor, you should install it - [https://eslint.org/docs/user-guide/integrations](https://eslint.org/docs/user-guide/integrations).
16+
17+
To find any errors or warnings, either view them in your editor once you've installed the right package, or run `npm run eslint`. Not all errors/warnings can be fixed, and some will be picked up by prettier, so don't worry if you can't fix them.
18+
19+
### Lock Files
20+
21+
All lock files (`package-lock.json`, `yarn.lock`) should be committed.
22+
23+
### Dependencies
24+
25+
Try to keep dependencies to a minimum where possible. If you are pulling a whole library for just one function, try to implement that function as a helper method.
26+
27+
### Testing
28+
29+
[Jest](https://github.com/facebook/jest) is used for testing. Once you've made changes, writing a test case helps to catch any bugs. Feel free to open a PR that just includes more tests.
30+
31+
### Setup
32+
33+
Follow the instructions in the [README](README.md) to get setup. Once hackd is running in the iOS simulator, you can enable debugging and view redux-logger logs in the console.

__tests__/tests/actions/auth.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ import { post } from '../../data/api/post';
77
const dispatch = jest.fn();
88

99
describe('Auth Actions', () => {
10-
1110
it('should login a user', () => {
1211
const getState = () => ({});
1312

1413
actions.login(appUser)(dispatch, getState);
1514
expect(dispatch).toHaveBeenCalledWith({
16-
type: 'UPDATE_USER',
15+
type: 'UPDATE_USER',
1716
user: appUser,
1817
});
1918
});
2019

2120
it('should add a post to the upvoted section of a new users account', () => {
22-
const getState = () => ({
21+
const getState = () => ({
2322
user: appUser,
2423
accounts: {},
2524
});
@@ -32,13 +31,13 @@ describe('Auth Actions', () => {
3231

3332
actions.addIdToUserAccount(post.id, 'upvoted')(dispatch, getState);
3433
expect(dispatch).toHaveBeenCalledWith({
35-
type: 'SET_ACCOUNTS_DETAILS',
34+
type: 'SET_ACCOUNTS_DETAILS',
3635
accounts: expectedAccounts,
3736
});
3837
});
3938

4039
it('should add a post to the saved section of a new users account', () => {
41-
const getState = () => ({
40+
const getState = () => ({
4241
user: appUser,
4342
accounts: {},
4443
});
@@ -51,13 +50,13 @@ describe('Auth Actions', () => {
5150

5251
actions.addIdToUserAccount(post.id, 'saved')(dispatch, getState);
5352
expect(dispatch).toHaveBeenCalledWith({
54-
type: 'SET_ACCOUNTS_DETAILS',
53+
type: 'SET_ACCOUNTS_DETAILS',
5554
accounts: expectedAccounts,
5655
});
5756
});
5857

5958
it('should remove a post from the saved section of an existing users account', () => {
60-
const getState = () => ({
59+
const getState = () => ({
6160
user: appUser,
6261
accounts: {
6362
[appUser.username]: {
@@ -74,13 +73,13 @@ describe('Auth Actions', () => {
7473

7574
actions.removeIdFromUserAccount(post.id, 'saved')(dispatch, getState);
7675
expect(dispatch).toHaveBeenCalledWith({
77-
type: 'SET_ACCOUNTS_DETAILS',
76+
type: 'SET_ACCOUNTS_DETAILS',
7877
accounts: expectedAccounts,
7978
});
8079
});
8180

8281
it('should add a post to the upvotedComments section of a new users account', () => {
83-
const getState = () => ({
82+
const getState = () => ({
8483
user: appUser,
8584
accounts: {},
8685
});
@@ -93,13 +92,13 @@ describe('Auth Actions', () => {
9392

9493
actions.addIdToUserAccount(post.id, 'upvotedComments')(dispatch, getState);
9594
expect(dispatch).toHaveBeenCalledWith({
96-
type: 'SET_ACCOUNTS_DETAILS',
95+
type: 'SET_ACCOUNTS_DETAILS',
9796
accounts: expectedAccounts,
9897
});
9998
});
10099

101100
it('should remove a post from the upvotedComments section of an existing users account', () => {
102-
const getState = () => ({
101+
const getState = () => ({
103102
user: appUser,
104103
accounts: {
105104
[appUser.username]: {
@@ -114,11 +113,13 @@ describe('Auth Actions', () => {
114113
},
115114
};
116115

117-
actions.removeIdFromUserAccount(post.id, 'upvotedComments')(dispatch, getState);
116+
actions.removeIdFromUserAccount(post.id, 'upvotedComments')(
117+
dispatch,
118+
getState,
119+
);
118120
expect(dispatch).toHaveBeenCalledWith({
119-
type: 'SET_ACCOUNTS_DETAILS',
121+
type: 'SET_ACCOUNTS_DETAILS',
120122
accounts: expectedAccounts,
121123
});
122124
});
123-
124-
});
125+
});

__tests__/tests/actions/items.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as actions from '../../../app/actions/items';
44
import { posts } from '../../data/api/post';
55

66
describe('Items Actions', () => {
7-
87
it('should set first page posts', () => {
98
const getState = () => ({});
109

@@ -15,7 +14,7 @@ describe('Items Actions', () => {
1514
actions.setPosts(1, posts)(dispatch, getState);
1615

1716
expect(dispatch).toHaveBeenCalledWith({
18-
type: 'SET_POSTS',
17+
type: 'SET_POSTS',
1918
posts,
2019
});
2120
});
@@ -24,9 +23,8 @@ describe('Items Actions', () => {
2423
const storyType = 'top';
2524

2625
expect(actions.setStoryType(storyType)).toEqual({
27-
type: 'SET_STORY_TYPE',
26+
type: 'SET_STORY_TYPE',
2827
storyType,
2928
});
3029
});
31-
32-
});
30+
});

__tests__/tests/utilities/utils.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import {
22
capitalize,
33
truncate,
44
addToUserAccount,
@@ -29,7 +29,7 @@ describe('App Utils', () => {
2929
expect(addToUserAccount(account, appUser, id, type)).toEqual({
3030
[appUser.username]: {
3131
upvoted: [id],
32-
}
32+
},
3333
});
3434
});
3535

@@ -45,8 +45,7 @@ describe('App Utils', () => {
4545
expect(removeFromUserAccount(account, appUser, id, type)).toEqual({
4646
[appUser.username]: {
4747
upvotedComments: [id2],
48-
}
48+
},
4949
});
5050
});
51-
5251
});

app/actions/auth.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import * as types from './types';
2-
import {
3-
addToUserAccount,
4-
removeFromUserAccount
5-
} from '../helpers/utils';
6-
import { logout, upvote, } from '../helpers/api';
2+
import { addToUserAccount, removeFromUserAccount } from '../helpers/utils';
3+
import { logout, upvote } from '../helpers/api';
74

85
const setUser = user => {
96
return {
@@ -37,12 +34,11 @@ export const removeIdFromUserAccount = (id, type) => {
3734
};
3835
};
3936

40-
export const upvotePost = (id) => {
37+
export const upvotePost = id => {
4138
return (dispatch, getState) => {
42-
4339
// Add upvote initially for immediate feedback
4440
dispatch(addIdToUserAccount(id, 'upvoted'));
45-
41+
4642
upvote(id).then(upvoted => {
4743
if (!upvoted) {
4844
dispatch(removeIdFromUserAccount(id, 'upvoted'));
@@ -51,7 +47,7 @@ export const upvotePost = (id) => {
5147
};
5248
};
5349

54-
export const savePost = (id) => {
50+
export const savePost = id => {
5551
return (dispatch, getState) => {
5652
dispatch(addIdToUserAccount(id, 'saved'));
5753
};

app/actions/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import * as ItemActions from './items';
22
import * as AuthActions from './auth';
33
import * as SettingActions from './settings';
44

5-
export const ActionCreators = Object.assign({},
5+
export const ActionCreators = Object.assign(
6+
{},
67
ItemActions,
78
AuthActions,
89
SettingActions,

app/actions/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export const ADD_UPVOTED_POST = 'ADD_UPVOTED_POST';
1010
export const CHANGE_SAVED_POSTS = 'CHANGE_SAVED_POSTS';
1111

1212
// Settings
13-
export const SET_SETTINGS = 'SET_SETTINGS';
13+
export const SET_SETTINGS = 'SET_SETTINGS';

0 commit comments

Comments
 (0)