Skip to content

Commit b0d156c

Browse files
committed
Bump Typescript version and use recommended TSLint rules
1 parent 3d5ebda commit b0d156c

37 files changed

+314
-423
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ env/
33
node_modules/
44
config.js
55
build/build.js
6+
build/awCache/

@types/global/index.d.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
declare const __DEV__: boolean;
2+
declare const Thunder: {
3+
connect: (host: string, apikey: string, channels: string[], options?: object) => void;
4+
listen: (
5+
handler: (data: { channel: string, payload: string }) => void
6+
) => void;
7+
};
8+
9+
declare const config: {
10+
API: {
11+
host: string;
12+
key: string;
13+
};
14+
THUNDER: {
15+
host: string;
16+
key: string;
17+
secret: string;
18+
};
19+
SENTRY?: string;
20+
SCREEN: "primary" | "secondary";
21+
};
22+
23+
declare module "*.scss" {
24+
interface IClassNames {
25+
[className: string]: string;
26+
}
27+
const classNames: IClassNames;
28+
export = classNames;
29+
}

typings/reflexbox/index.d.ts @types/reflexbox/index.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ declare module "reflexbox" {
99

1010
declare namespace __Reflexbox {
1111
interface Props {
12-
auto?: boolean
12+
auto?: boolean;
1313
className?: string;
1414
is?: string | Object | Function;
1515
key?: string | number;
@@ -29,7 +29,7 @@ declare namespace __Reflexbox {
2929
pt?: number;
3030
pb?: number;
3131
pl?: number;
32-
pr?: number,
32+
pr?: number;
3333
sm?: boolean;
3434
style?: React.CSSProperties;
3535
}
@@ -41,7 +41,7 @@ declare namespace __Reflexbox {
4141
order?: number;
4242
}
4343

44-
export class Box extends React.Component<BoxProps, {}> { }
44+
export class Box extends React.Component<BoxProps> { }
4545

4646
interface FlexProps extends Props {
4747
align?: "stretch" | "center" | "baseline" | "flex-start" | "flex-end";
@@ -53,7 +53,7 @@ declare namespace __Reflexbox {
5353
wrap?: boolean;
5454
}
5555

56-
export class Flex extends React.Component<FlexProps, {}> { }
56+
export class Flex extends React.Component<FlexProps> { }
5757
}
5858

5959
declare module "reflexbox/Box" {

package.json

+21-28
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"description": "Foobar Kiosk application.",
55
"scripts": {
66
"start": "node server.js",
7-
"build": "NODE_ENV=production webpack --progress --hide-modules --config webpack.prod.config.js"
7+
"build": "NODE_ENV=production webpack --progress --hide-modules --config webpack.prod.config.js",
8+
"tslint": "node node_modules/tslint/bin/tslint --project tsconfig.json",
9+
"precommit": "npm run tslint"
810
},
911
"repository": {
1012
"type": "git",
@@ -16,51 +18,42 @@
1618
},
1719
"devDependencies": {
1820
"@types/classnames": "0.0.28",
19-
"@types/es6-promise": "0.0.31",
20-
"@types/isomorphic-fetch": "0.0.30",
21-
"@types/node": "6.0.38",
22-
"@types/object-assign": "4.0.28",
23-
"@types/react": "0.14.33",
24-
"@types/react-addons-css-transition-group": "0.14.16",
25-
"@types/react-dom": "0.14.16",
26-
"@types/react-redux": "4.4.31",
27-
"@types/redux": "3.5.28",
21+
"@types/isomorphic-fetch": "0.0.34",
22+
"@types/qrcode.react": "0.6.2",
23+
"@types/react": "15.6.1",
24+
"@types/react-addons-css-transition-group": "15.0.3",
25+
"@types/react-dom": "15.5.2",
26+
"@types/react-redux": "4.4.47",
2827
"@types/redux-logger": "2.6.31",
2928
"@types/redux-thunk": "2.1.30",
30-
"apeman-react-clock": "^3.0.3",
3129
"autoprefixer": "6.4.0",
32-
"awesome-typescript-loader": "2.2.4",
30+
"awesome-typescript-loader": "3.2.2",
3331
"classnames": "2.2.5",
3432
"css-loader": "0.24.0",
35-
"expect": "1.6.0",
3633
"file-loader": "0.10.1",
34+
"husky": "0.14.3",
3735
"isomorphic-fetch": "2.2.1",
3836
"node-sass": "3.8.0",
39-
"object-assign": "4.1.0",
4037
"postcss": "5.1.2",
4138
"postcss-loader": "0.11.0",
42-
"qrcode.react": "^0.6.1",
39+
"qrcode.react": "0.6.1",
4340
"raven-for-redux": "0.3.0",
4441
"raven-js": "3.12.1",
4542
"react": "15.3.1",
46-
"react-addons-css-transition-group": "15.3.1",
43+
"react-addons-css-transition-group": "15.3.0",
4744
"react-dom": "15.3.1",
48-
"react-hot-loader": "1.3.0",
49-
"react-redux": "4.4.5",
50-
"redux": "3.5.0",
51-
"redux-devtools": "3.3.1",
45+
"react-hot-loader": "1.3.1",
46+
"react-redux": "4.4.8",
47+
"redux": "3.7.2",
5248
"redux-logger": "2.6.1",
53-
"redux-router": "2.1.2",
5449
"redux-thunk": "2.1.0",
55-
"reflexbox": "2.2.3",
56-
"requirejs": "2.2.0",
50+
"reflexbox": "1.1.4",
5751
"sass-loader": "4.0.0",
5852
"style-loader": "0.13.1",
59-
"tslint": "3.14.0",
60-
"tslint-loader": "2.1.5",
61-
"typed-css-modules": "0.1.12",
62-
"typed-css-modules-loader": "0.0.4",
63-
"typescript": "2.0.10",
53+
"tslib": "1.7.1",
54+
"tslint": "5.5.0",
55+
"typescript": "2.4.2",
56+
"typings-for-css-modules-loader": "1.5.0",
6457
"webpack": "1.13.1",
6558
"webpack-dev-middleware": "1.6.1",
6659
"webpack-dev-server": "1.14.1",

src/App.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { Flex } from "reflexbox";
1010
import { DevToolbar } from "components";
1111
import { IAppProps } from "types";
1212

13-
class App extends React.Component<IAppProps, {}> {
13+
class App extends React.Component<IAppProps> {
1414
render() {
15-
var classList = classNames({
16-
[style.fillScreen]: process.env.SCREEN === 'secondary',
15+
const classList = classNames({
16+
[style.fillScreen]: config.SCREEN === 'secondary'
1717
});
1818
return (
1919
<Flex column className={classList}>
@@ -24,7 +24,7 @@ class App extends React.Component<IAppProps, {}> {
2424
}
2525

2626
renderDevToolbar() {
27-
if (process.env.NODE_ENV === 'development') {
27+
if (__DEV__) {
2828
return (
2929
<DevToolbar
3030
dispatch={this.props.dispatch}
@@ -35,9 +35,9 @@ class App extends React.Component<IAppProps, {}> {
3535
}
3636

3737
renderApp() {
38-
if (process.env.SCREEN === 'primary') {
38+
if (config.SCREEN === 'primary') {
3939
return (<PrimaryScreen {...this.props} />);
40-
} else if (process.env.SCREEN === 'secondary') {
40+
} else if (config.SCREEN === 'secondary') {
4141
return (<SecondaryScreen {...this.props} />);
4242
}
4343
}

src/actions/account.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ export const FAILED_ACCOUNT = "FAILED_ACCOUNT";
88
export const LOGIN_ACCOUNT = "LOGIN_ACCOUNT";
99
export const CLEAR_ACCOUNT = "CLEAR_ACCOUNT";
1010

11-
export function requestAccount(cardId: string) {
11+
export function requestAccount(cardId?: string) {
1212
return {
1313
type: REQUEST_ACCOUNT,
1414
cardId
1515
};
16-
};
16+
}
1717

18-
export function receiveAccount(data: IAccount = undefined) {
18+
export function receiveAccount(data?: IAccount) {
1919
return {
2020
type: LOGIN_ACCOUNT,
2121
data
2222
};
23-
};
23+
}
2424

2525
export function failedRequestAccount() {
2626
return {
2727
type: FAILED_ACCOUNT
2828
};
29-
};
29+
}
3030

31-
export function login(cardId: string = undefined) {
31+
export function login(cardId?: string) {
3232
return (dispatch: Function, getState: any) => {
3333
const { account } = getState();
3434

@@ -58,10 +58,10 @@ export function login(cardId: string = undefined) {
5858
}
5959
}
6060
};
61-
};
61+
}
6262

6363
export function clearAccount() {
6464
return {
6565
type: CLEAR_ACCOUNT
6666
};
67-
};
67+
}

src/actions/product.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Cache {
3434
}
3535

3636
add(key: string, value: any, ttl: number) {
37-
let expirationDate = new Date();
37+
const expirationDate = new Date();
3838
expirationDate.setSeconds(expirationDate.getSeconds() + ttl);
3939

4040
this.cache[key] = {
@@ -93,7 +93,7 @@ class ProductFetcher {
9393
// appropriate actions
9494
dispatch(requestProduct(code));
9595
this.promises[code] = apiCall(`/products/?code=${code}`)
96-
.then((response: IResponse) => {
96+
.then((response: any) => {
9797
return response.json();
9898
})
9999
.then((data: IProduct[]) => {
@@ -111,7 +111,7 @@ class ProductFetcher {
111111
}
112112
}
113113

114-
let fetcher = new ProductFetcher();
114+
const fetcher = new ProductFetcher();
115115

116116
export function addProduct(code: string) {
117117
return (dispatch: Function, getState: Function) => {
@@ -124,58 +124,59 @@ export function addProduct(code: string) {
124124
return fetcher.productWithCode(dispatch, code);
125125
}
126126
};
127-
};
127+
}
128128

129129
export function requestProduct(code: string) {
130130
return {
131131
type: REQUEST_PRODUCT,
132132
code
133133
};
134-
};
134+
}
135+
135136
export function failedProduct(code: string) {
136137
return {
137138
type: FAILED_PRODUCT,
138139
code
139140
};
140-
};
141+
}
141142

142143
export function receiveProduct(product: IProduct) {
143144
return {
144145
type: ADD_PRODUCT,
145146
product
146147
};
147-
};
148+
}
148149

149150
export function increaseProductQty(count: number) {
150151
return {
151152
type: INCREASE_PRODUCT_QTY,
152153
count
153154
};
154-
};
155+
}
155156

156157
export function selectProduct(code: string) {
157158
return {
158159
type: SELECT_PRODUCT,
159160
code
160161
};
161-
};
162+
}
162163

163164
export function removeProduct(code?: string) {
164165
return {
165166
type: REMOVE_PRODUCT,
166167
code
167168
};
168-
};
169+
}
169170

170171
export function changePage(count: number) {
171172
return {
172173
type: CHANGE_PAGE,
173174
count
174175
};
175-
};
176+
}
176177

177178
export function clearProducts() {
178179
return {
179180
type: CLEAR_PRODUCTS
180181
};
181-
};
182+
}

0 commit comments

Comments
 (0)