Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.

Commit 9d80935

Browse files
author
rsavian
committed
Merge branch 'typescript' into feature/typescript-code-splitting
# Conflicts: # src/client.tsx # src/services/ProviderService.ts
2 parents 7c5768c + beaefaf commit 9d80935

17 files changed

+121
-39
lines changed

package.json

+15-13
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
"description": "Simple React Hot Loading example with Hapi Server-side rendering",
55
"scripts": {
66
"---------- HELPERS -----------------------------------------------------------------------------": "",
7-
"remove": "cross-env rimraf dist",
8-
"buildServer": "cross-env tsc -project tsconfig.server.json",
9-
"watchServer": "cross-env tsc -watch -project tsconfig.server.json",
10-
"removeAndBuildServer": "cross-env npm run remove && npm run buildServer",
7+
"remove": "rimraf dist",
8+
"buildServer": "tsc -project tsconfig.server.json",
9+
"watchServer": "tsc -watch -project tsconfig.server.json",
10+
"removeAndBuildServer": "npm run remove && npm run buildServer",
1111
"start": "cross-env NODE_ENV=production node ./dist/server.js",
1212
"---------- DEVELOPMENT -------------------------------------------------------------------------": "",
13-
"predev": "cross-env npm run removeAndBuildServer",
14-
"dev": "cross-env npm run watchServer & npm run devServer",
13+
"predev": "npm run removeAndBuildServer",
14+
"dev": "npm run watchServer & npm run devServer",
1515
"devServer": "cross-env BABEL_ENV=client NODE_ENV=development nodemon ./dist/server.js",
1616
"---------- STAGING -----------------------------------------------------------------------------": "",
17-
"prestaging:build": "cross-env npm run removeAndBuildServer",
17+
"prestaging:build": "npm run removeAndBuildServer",
1818
"staging:build": "cross-env BABEL_ENV=client NODE_ENV=staging webpack",
19-
"staging": "cross-env npm run staging:build && npm run start",
19+
"staging": "npm run staging:build && npm run start",
2020
"---------- PRODUCTION --------------------------------------------------------------------------": "",
21-
"preprod:build": "cross-env npm run removeAndBuildServer",
21+
"preprod:build": "npm run removeAndBuildServer",
2222
"prod:build": "cross-env BABEL_ENV=client NODE_ENV=production webpack -p",
23-
"prod": "cross-env npm run prod:build && npm run start",
23+
"prod": "npm run prod:build && npm run start",
2424
"---------- TESTING -----------------------------------------------------------------------------": "",
25-
"test": "cross-env npm run lint && npm run unit",
26-
"lint": "cross-env eslint src --ext .js,.jsx",
27-
"unit": "cross-env jest",
25+
"test": "npm run lint && npm run unit",
26+
"lint": "tslint 'src/**/*.ts{,x}' --exclude 'src/_declare/**/*'",
27+
"unit": "jest",
2828
"------------------------------------------------------------------------------------------------": ""
2929
},
3030
"repository": {
@@ -98,6 +98,8 @@
9898
"robotstxt-webpack-plugin": "2.0.0",
9999
"style-loader": "0.18.2",
100100
"tslib": "1.7.1",
101+
"tslint": "5.7.0",
102+
"tslint-react": "3.2.0",
101103
"typescript": "2.4.2",
102104
"webpack-dev-middleware": "1.12.0",
103105
"webpack-hot-middleware": "2.18.2"

src/RouterWrapper.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const RouterWrapper: React.StatelessComponent<IProviderWrapperProps> = (props: I
3131
<Header />
3232
<Switch>
3333
<Route
34-
exact
34+
exact={true}
3535
path="/"
3636
component={Home}
3737
/>

src/interfaces/store/ISagaStore.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {Store} from 'redux';
22

33
interface ISagaStore<S> extends Store<S> {
4-
runSaga: Function; // TODO: figure out type
5-
endSaga: Function; // TODO: figure out type
4+
runSaga: any; // TODO: figure out type
5+
endSaga: any; // TODO: figure out type
66
}
77

88
export default ISagaStore;

src/interfaces/store/reducers/ILoadingReducerState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ interface ILoadingReducerState {
22
readonly isLoading: boolean;
33
}
44

5-
export default ILoadingReducerState
5+
export default ILoadingReducerState;

src/interfaces/store/reducers/IMetaReducerState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ interface IMetaReducerState {
33
readonly description?: string;
44
}
55

6-
export default IMetaReducerState
6+
export default IMetaReducerState;

src/interfaces/store/reducers/IRenderReducerState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ interface IRenderReducerState {
22
readonly isServerSide: boolean;
33
}
44

5-
export default IRenderReducerState
5+
export default IRenderReducerState;

src/interfaces/store/reducers/IUserReducerState.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ interface IUserReducerState {
33
title: string;
44
first: string;
55
last: string;
6-
}
6+
};
77
readonly email: string;
88
readonly dob: string;
99
readonly phone: string;
1010
readonly id: {
1111
name: string;
1212
value: string;
13-
},
13+
};
1414
readonly picture: {
1515
large: string;
1616
medium: string;
1717
thumbnail: string;
18-
}
18+
};
1919
}
2020

21-
export default IUserReducerState
21+
export default IUserReducerState;

src/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const manager = new ServerManager();
1010
manager.registerPlugin(inert);
1111

1212
if (manager.isDevelopment) {
13-
new HapiWebpackHotPlugin(manager.server); // eslint-disable-line no-new
13+
new HapiWebpackHotPlugin(manager.server); // tslint:disable-line
1414
}
1515

1616
manager.registerController(new AssetsController());

src/server/ServerManager.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import * as Hapi from 'hapi';
22
import IController from '../interfaces/server/IController';
3-
import {ServerConnectionOptions} from 'hapi';
43

54
const PORT = process.env.PORT || 3000;
65
const HOST = process.env.HOST || 'localhost';
76
const NODE_ENV = process.env.NODE_ENV;
87

98
class ServerManager {
109

11-
public static log: Function = (): void => console.info(`\n\nServer running in ${NODE_ENV} mode at: http://${HOST}:${PORT}\n`);
10+
public isDevelopment: boolean = (NODE_ENV === 'development');
1211

1312
private _server: Hapi.Server = new Hapi.Server({debug: {request: ['error']}});
1413

15-
public isDevelopment: boolean = (NODE_ENV === 'development');
16-
1714
public get server(): Hapi.Server {
1815
return this._server;
1916
}
@@ -22,7 +19,11 @@ class ServerManager {
2219
this._server.connection({
2320
host: HOST,
2421
port: PORT,
25-
} as ServerConnectionOptions);
22+
});
23+
}
24+
25+
public static log(): void {
26+
console.info(`\n\nServer running in ${NODE_ENV} mode at: http://${HOST}:${PORT}\n`);
2627
}
2728

2829
public async registerPlugin(pluginConfig: any): Promise<void> {

src/server/plugin/HapiWebpackHotPlugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ServerManager from '../ServerManager';
77
class HapiWebpackHotPlugin {
88

99
constructor(server: Hapi.Server) {
10-
const config: Webpack.Configuration = require('../../../webpack.config.js');
10+
const config: Webpack.Configuration = require('../../../webpack.config.js'); // tslint:disable-line no-require-imports
1111
const compiler: Webpack.Compiler = Webpack(config);
1212

1313
compiler.plugin('done', (stats: any) => this._onDone(stats));
@@ -34,7 +34,7 @@ class HapiWebpackHotPlugin {
3434
}
3535

3636
private _onDone(stats: any): void {
37-
const pkg = require('../../../package.json');
37+
const pkg = require('../../../package.json'); // tslint:disable-line no-require-imports
3838
const time = ((stats.endTime - stats.startTime) / 1000).toFixed(2);
3939

4040
setTimeout(() => {

src/views/about/About.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,3 @@ class About extends React.Component<IStateToProps & IDispatchToProps, {}> {
6767
}
6868

6969
export default connect<IStateToProps, IDispatchToProps, {}>(mapStateToProps, mapDispatchToProps)(About);
70-

src/views/contact/ContactForm.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ interface IProps extends InjectedFormProps<IContactForm> {}
77

88
class ContactForm extends React.Component<IProps> {
99

10-
private _handleSubmitHandler = (formData: IContactForm) => this._onFormSubmit(formData);
10+
private _handleSubmitHandler: (formData: IContactForm) => void = null;
11+
12+
constructor(props: IProps) {
13+
super(props);
14+
15+
this._handleSubmitHandler = (formData: IContactForm) => this._onFormSubmit(formData);
16+
}
1117

1218
public render(): JSX.Element {
1319
const {handleSubmit, reset} = this.props;

src/views/errors/NotFound.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NotFound extends React.Component<IStateToProps & IDispatchToProps, {}> {
2323
this.props.setMeta({title: '404 Page Not Found'});
2424
}
2525

26-
render() {
26+
public render() {
2727
return (
2828
<div>
2929
<div className="jumbotron">

src/views/home/Home.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,3 @@ class Home extends React.Component<IStateToProps & IDispatchToProps, {}> {
6262
}
6363

6464
export default connect<IStateToProps, IDispatchToProps, {}>(mapStateToProps, mapDispatchToProps)(Home);
65-

src/views/landmarks/Header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Header extends React.Component<IProps, IState> {
1313
<ul className="nav nav-pills float-right">
1414
<li className="nav-item">
1515
<NavLink
16-
exact
16+
exact={true}
1717
className="nav-link"
1818
activeClassName="active"
1919
to="/"

tslint.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"extends": ["tslint:latest", "tslint-react"],
3+
"rules": {
4+
"arrow-parens": true,
5+
"arrow-return-shorthand": [true],
6+
"comment-format": [true],
7+
"curly": true,
8+
"import-blacklist": [true, "rxjs"],
9+
"interface-over-type-literal": true,
10+
"max-line-length": [false],
11+
"member-access": true,
12+
"member-ordering": [true, {"order": "fields-first"}],
13+
"newline-before-return": true,
14+
"no-any": false,
15+
"no-bitwise": true,
16+
"no-conditional-assignment": true,
17+
"no-console": [true, "log"],
18+
"no-duplicate-variable": true,
19+
"no-empty-interface": false,
20+
"no-inferrable-types": [true, "ignore-params", "ignore-properties"],
21+
"no-invalid-this": [true, "check-function-in-method"],
22+
"no-null-keyword": false,
23+
"no-parameter-reassignment": true,
24+
"no-require-imports": true,
25+
"no-submodule-imports": false,
26+
"no-switch-case-fall-through": true,
27+
"no-this-assignment": [true, {"allow-destructuring": true}],
28+
"no-trailing-whitespace": true,
29+
"no-var-keyword": true,
30+
"object-literal-shorthand": true,
31+
"object-literal-sort-keys": false,
32+
"one-variable-per-declaration": [true],
33+
"only-arrow-functions": [true, "allow-declarations"],
34+
"ordered-imports": [false],
35+
"prefer-conditional-expression": [true, "check-else-if"],
36+
"prefer-method-signature": false,
37+
"prefer-template": [true, "allow-single-concat"],
38+
"quotemark": [true, "single", "jsx-double"],
39+
"semicolon": [true],
40+
"triple-equals": [true, "allow-null-check"],
41+
"typedef": [true,"parameter", "property-declaration"],
42+
"variable-name": [true, "ban-keywords", "check-format", "allow-pascal-case", "allow-leading-underscore"]
43+
}
44+
}

yarn.lock

+34-3
Original file line numberDiff line numberDiff line change
@@ -2040,6 +2040,10 @@ detect-indent@^4.0.0:
20402040
dependencies:
20412041
repeating "^2.0.0"
20422042

2043+
diff@^3.2.0:
2044+
version "3.3.0"
2045+
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.0.tgz#056695150d7aa93237ca7e378ac3b1682b7963b9"
2046+
20432047
diffie-hellman@^5.0.0:
20442048
version "5.0.2"
20452049
resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.2.tgz#b5835739270cfe26acf632099fded2a07f209e5e"
@@ -2834,7 +2838,7 @@ glob@^6.0.4:
28342838
once "^1.3.0"
28352839
path-is-absolute "^1.0.0"
28362840

2837-
glob@^7.0.3, glob@^7.0.5, glob@^7.1.2:
2841+
glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
28382842
version "7.1.2"
28392843
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
28402844
dependencies:
@@ -5656,7 +5660,7 @@ resolve-url@^0.2.1:
56565660
version "0.2.1"
56575661
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
56585662

5659-
resolve@^1.1.7, resolve@^1.2.0:
5663+
resolve@^1.1.7, resolve@^1.2.0, resolve@^1.3.2:
56605664
version "1.4.0"
56615665
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.4.0.tgz#a75be01c53da25d934a98ebd0e4c4a7312f92a86"
56625666
dependencies:
@@ -6261,10 +6265,37 @@ tryit@^1.0.1:
62616265
version "1.0.3"
62626266
resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb"
62636267

6264-
tslib@1.7.1:
6268+
tslib@1.7.1, tslib@^1.7.1:
62656269
version "1.7.1"
62666270
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec"
62676271

6272+
tslint-react@3.2.0:
6273+
version "3.2.0"
6274+
resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-3.2.0.tgz#851fb505201c63d0343c51726e6364f7e9ad2e99"
6275+
dependencies:
6276+
tsutils "^2.8.0"
6277+
6278+
tslint@5.7.0:
6279+
version "5.7.0"
6280+
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.7.0.tgz#c25e0d0c92fa1201c2bc30e844e08e682b4f3552"
6281+
dependencies:
6282+
babel-code-frame "^6.22.0"
6283+
colors "^1.1.2"
6284+
commander "^2.9.0"
6285+
diff "^3.2.0"
6286+
glob "^7.1.1"
6287+
minimatch "^3.0.4"
6288+
resolve "^1.3.2"
6289+
semver "^5.3.0"
6290+
tslib "^1.7.1"
6291+
tsutils "^2.8.1"
6292+
6293+
tsutils@^2.8.0, tsutils@^2.8.1:
6294+
version "2.8.1"
6295+
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.8.1.tgz#3771404e7ca9f0bedf5d919a47a4b1890a68efff"
6296+
dependencies:
6297+
tslib "^1.7.1"
6298+
62686299
tty-browserify@0.0.0:
62696300
version "0.0.0"
62706301
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"

0 commit comments

Comments
 (0)