Skip to content

Commit 2eade8b

Browse files
authored
Merge pull request #39 from FoxComm/apple-pay
Feature: Apple pay
2 parents 571a98f + 290cd43 commit 2eade8b

48 files changed

Lines changed: 1586 additions & 284 deletions

Some content is hidden

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

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"plugins": ["lodash"],
3-
"presets": ["es2015", "stage-1"]
3+
"presets": ["es2015", "stage-1", "flow"]
44
}

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lib
2+
docs
3+
node_modules
4+
bin

.eslintrc

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"extends": "airbnb",
3+
"plugins": [
4+
"flowtype"
5+
],
6+
"env": {
7+
"es6": true,
8+
"node": true,
9+
"browser": true,
10+
"mocha": true
11+
},
12+
"settings": {
13+
"import/resolver": {
14+
"node": {
15+
"paths": ["src"]
16+
}
17+
},
18+
"import/external-module-folders": ["src", "node_modules"],
19+
"import/extensions": [".js"]
20+
},
21+
"rules": {
22+
"no-console": ["error", { "allow": ["warn", "error", "info"] }],
23+
"flowtype/define-flow-type": 1,
24+
"flowtype/use-flow-type": 1,
25+
"eqeqeq": 0,
26+
"strict": 0,
27+
"space-before-function-paren": 0,
28+
"func-names": 0,
29+
"no-void": 0,
30+
"require-yield": 0,
31+
"comma-dangle": ["error", {
32+
"arrays": "always-multiline",
33+
"objects": "always-multiline",
34+
"imports": "always-multiline",
35+
"exports": "always-multiline",
36+
"functions": "never"
37+
}],
38+
"prefer-arrow-callback": 0,
39+
"object-curly-spacing": 0,
40+
"max-len": [2, 120, 4,
41+
{
42+
"ignoreComments": true,
43+
"ignoreUrls": true,
44+
"ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\("
45+
}
46+
],
47+
"arrow-body-style": 0,
48+
"no-continue": 0,
49+
"no-plusplus": 0,
50+
"no-mixed-operators": 0,
51+
"no-unused-vars": [2, { "varsIgnorePattern": "^styles$", "ignoreRestSiblings": true }],
52+
"consistent-return": 0,
53+
"import/extensions": 0,
54+
"import/first": 0,
55+
"import/prefer-default-export": 0,
56+
"import/no-named-default": 0,
57+
"import/no-named-as-default": 0,
58+
"import/no-extraneous-dependencies": 0,
59+
"global-require": 0,
60+
"no-underscore-dangle": 0,
61+
"class-methods-use-this": 0,
62+
"quotes": [2, "single", {"avoidEscape": false}],
63+
"no-useless-escape": 0,
64+
"arrow-parens": 1,
65+
"import/no-duplicates": 0 // turn on later
66+
},
67+
"globals": {
68+
"makeXhr": false,
69+
"ga": false,
70+
"ApplePaySession": true,
71+
"Stripe": true
72+
},
73+
"parserOptions": {
74+
"sourceType": "module",
75+
},
76+
"parser": "babel-eslint"
77+
}

.flowconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
[include]
1010
src
1111

12+
[libs]
13+
types/
14+
1215
[options]
1316
esproposal.decorators=ignore
1417
esproposal.class_static_fields=enable
@@ -19,4 +22,4 @@ module.system=haste
1922
module.system.node.resolve_dirname=node_modules
2023
module.system.node.resolve_dirname=src
2124
unsafe.enable_getters_and_setters=true
22-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe
25+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
.DEFAULT_GOAL := build
22

3+
PRETTIER_IGNORE = "bin|dist|docs|lib|node_modules"
4+
JS_FILES = $(shell find $(pwd) -name "*.js" | grep -v -E $(PRETTIER_IGNORE))
5+
PRETTIER_OPTIONS = --single-quote --trailing-comma es5 --print-width 120
6+
37
setup: clean
48
yarn --pure-lockfile
59

@@ -10,7 +14,10 @@ clean:
1014
rm -rf ./node_modules
1115
rm -rf ./lib/*
1216

13-
test: build
17+
test:
18+
yarn lint
1419
yarn flow
1520

16-
.PHONY: setup build clean test
21+
fmt:
22+
./node_modules/.bin/prettier --write $(PRETTIER_OPTIONS) $(JS_FILES) && yarn fix-lint
23+
.PHONY: setup build clean test fmt

flow-typed/api.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
declare module '@foxcomm/api-js' {
2-
declare type StringDict = {[name: string]: string};
2+
declare type StringDict = { [name: string]: string };
33

44
declare type AbortablePromise = Promise<*> & {
5-
abort(): void;
5+
abort(): void,
66
};
77

88
declare type AgentLike = AbortablePromise & {
9-
get(url: string): AgentLike;
10-
post(url: string): AgentLike;
11-
patch(url: string): AgentLike;
12-
delete(url: string): AgentLike;
9+
get(url: string): AgentLike,
10+
post(url: string): AgentLike,
11+
patch(url: string): AgentLike,
12+
delete(url: string): AgentLike,
1313

14-
set(headers: StringDict): AgentLike;
15-
withCredentials(): AgentLike;
14+
set(headers: StringDict): AgentLike,
15+
withCredentials(): AgentLike,
1616
};
1717

1818
declare type RequestOptions = {
1919
headers?: StringDict,
2020
credentials?: string,
21-
agent?: AgentLike;
21+
agent?: AgentLike,
2222
};
2323

2424
// @TODO: add subclasses
2525
declare class ApiClass {
26-
addresses: mixed;
27-
auth: mixed;
28-
creditCards: mixed;
29-
storeCredits: mixed;
30-
cart: mixed;
31-
account: mixed;
32-
orders: mixed;
33-
reviews: mixed;
34-
analytics: mixed;
35-
crossSell: mixed;
36-
37-
addAuth(jwt: string): ApiClass;
38-
removeAuth(): ApiClass;
26+
addresses: mixed,
27+
auth: mixed,
28+
creditCards: mixed,
29+
storeCredits: mixed,
30+
cart: mixed,
31+
account: mixed,
32+
orders: mixed,
33+
reviews: mixed,
34+
analytics: mixed,
35+
crossSell: mixed,
36+
37+
addAuth(jwt: string): ApiClass,
38+
removeAuth(): ApiClass,
3939

4040
// Returns customer id from parsed jwt string
4141
// You can define jwt string via `addAuth` method, if there is no jwt strings method returns null.
42-
getCustomerId(): ?number;
43-
44-
setHeaders(headers: StringDict): ApiClass;
45-
addHeaders(headers: StringDict): ApiClass;
46-
uri(path: string): string;
47-
queryStringToObject(qs: string): StringDict;
48-
49-
request(method: string, uri: string, data: ?Object, options: ?RequestOptions): AbortablePromise;
50-
get(uri: string, data: ?Object, options: ?Object): AbortablePromise;
51-
post(uri: string, data: ?Object, options: ?Object): AbortablePromise;
52-
patch(uri: string, data: ?Object, options: ?Object): AbortablePromise;
53-
delete(uri: string, data: ?Object, options: ?Object): AbortablePromise;
42+
getCustomerId(): ?number,
43+
44+
setHeaders(headers: StringDict): ApiClass,
45+
addHeaders(headers: StringDict): ApiClass,
46+
uri(path: string): string,
47+
queryStringToObject(qs: string): StringDict,
48+
49+
request(method: string, uri: string, data: ?Object, options: ?RequestOptions): AbortablePromise,
50+
get(uri: string, data: ?Object, options: ?Object): AbortablePromise,
51+
post(uri: string, data: ?Object, options: ?Object): AbortablePromise,
52+
patch(uri: string, data: ?Object, options: ?Object): AbortablePromise,
53+
delete(uri: string, data: ?Object, options: ?Object): AbortablePromise,
5454
}
5555

5656
declare function parseError(err: mixed): Array<string>;

package.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"build": "babel src -d lib",
1212
"docs": "APIARY_DOCS_PATH=../phoenix-scala/docs/api/docs/objects node ./bin/import-docs.js && node ./bin/make-docs.js",
1313
"prepublish": "npm run build",
14-
"flow": "./node_modules/.bin/flow check"
14+
"flow": "./node_modules/.bin/flow check",
15+
"lint": "eslint .",
16+
"fix-lint": "eslint . --fix"
1517
},
1618
"repository": {
1719
"type": "git",
@@ -36,14 +38,23 @@
3638
},
3739
"devDependencies": {
3840
"babel-cli": "^6.9.0",
41+
"babel-eslint": "^7.2.3",
3942
"babel-plugin-lodash": "^3.2.11",
4043
"babel-preset-es2015": "^6.9.0",
44+
"babel-preset-flow": "^6.23.0",
4145
"babel-preset-stage-1": "^6.5.0",
4246
"escape-html": "^1.0.3",
43-
"flow-bin": "^0.46.0",
47+
"eslint": "^3.18.0",
48+
"eslint-config-airbnb": "^14.1.0",
49+
"eslint-plugin-flowtype": "^2.30.3",
50+
"eslint-plugin-import": "^2.2.0",
51+
"eslint-plugin-jsx-a11y": "^4.0.0",
52+
"eslint-plugin-react": "^6.10.3",
53+
"flow-bin": "^0.47.0",
4454
"leafdoc": "github:anru/Leafdoc#v1.1",
4555
"mkdirp": "^0.5.1",
4656
"mocha": "^2.5.2",
47-
"nock": "^8.0.0"
57+
"nock": "^8.0.0",
58+
"prettier": "^1.4.4"
4859
}
4960
}

src/api/account.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// @class Account
32

43
import * as endpoints from '../endpoints';

src/api/adresses.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
// @class Addresses
32
// Accessible via [addresses](#foxapi-addresses) property of [FoxApi](#foxapi) instance.
43

@@ -40,7 +39,7 @@ export default class Addresses {
4039
// @method add(address: CreateAddressPayload): Promise<Address>
4140
// Adds new address.
4241
add(address) {
43-
return this.api.post(endpoints.addresses, address)
42+
return this.api.post(endpoints.addresses, address);
4443
}
4544

4645
// @method update(addressId: Number, address: UpdateAddressPayload): Promise<Address>

src/api/analytics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ export default class Analytics {
5858
// Unique number that can trace the object being tracked
5959
//
6060
// @field count: Number
61-
// Quantity
61+
// Quantity

0 commit comments

Comments
 (0)