Skip to content

Commit 6deee85

Browse files
committed
cleaning regarding linting rules
1 parent 6f859aa commit 6deee85

File tree

8 files changed

+23
-21
lines changed

8 files changed

+23
-21
lines changed

src/app.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export function __reload(prevModule) {
44
appComponent.setState(prevModule.appComponent.state);
55
}
66

7-
// create app container
8-
var appContainer = document.getElementById('app-container');
9-
if (appContainer == undefined) {
7+
// auto create app container if missing
8+
let appContainer = document.getElementById('app-container');
9+
if (appContainer == null) {
1010
appContainer = document.createElement('div');
1111
appContainer.id = 'app-container';
1212
document.body.appendChild(appContainer);
@@ -16,7 +16,7 @@ if (appContainer == undefined) {
1616
import * as React from 'react';
1717
import * as ReactDOM from 'react-dom';
1818
// components imports
19-
import {App} from './components/app';
19+
import {Main} from './components/main';
2020

2121
// todo: refactor name to appComponent
22-
export var appComponent = ReactDOM.render(<App />, appContainer);
22+
export var appComponent: any = ReactDOM.render(<Main welcomeMessage="Welcome to React"/>, appContainer);

src/components/app.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/components/main.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.main-component {
2+
background-color: #24b544;
3+
}

src/components/app.tsx renamed to src/components/main.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
// style imports
2-
import './app.css!';
2+
import './main.css!';
33
// lib imports
44
import * as React from 'react';
55
// components imports
66
import {AppStore, UserData} from '../stores/app-store';
77
import {UserProfile} from './user-profile';
88

9-
interface LocalProps extends React.Props<App> {
9+
interface LocalProps extends React.Props<Main> {
10+
welcomeMessage: string;
1011
}
1112

1213
// App pure component
13-
export class App extends React.Component<LocalProps, AppStore> {
14+
export class Main extends React.Component<LocalProps, AppStore> {
1415
constructor() {
1516
super();
1617
this.state = new AppStore();
1718
}
1819

1920
render() {
2021
const {userData} = this.state;
21-
return (<div>
22+
return (<div className="main-component">
23+
<h2>{this.props.welcomeMessage}</h2>
2224
<UserProfile name={userData.name} age={userData.age} complete={userData.complete} />
2325
</div>
2426
);

src/components/user-profile.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.myComponent {
2-
background-color: #379922;
1+
.user-profile-component {
2+
background-color: #58da3c;
33
}

src/components/user-profile.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// style imports
22
import './user-profile.css!';
33
// lib imports
4-
import * as React from "react";
4+
import * as React from 'react';
55

66
enum Texts {
77
Complete,
@@ -11,9 +11,9 @@ enum Texts {
1111
function getTranslation(text: Texts) {
1212
switch (text) {
1313
case Texts.Complete:
14-
return "complete";
14+
return 'complete';
1515
case Texts.Incomplete:
16-
return "incomplete";
16+
return 'incomplete';
1717
}
1818
}
1919

@@ -32,7 +32,7 @@ export class UserProfile extends React.Component<LocalProps, LocalState> {
3232
super();
3333
this.state = {
3434
complete: props.complete
35-
}
35+
};
3636
}
3737

3838
getStatusText = () => {
@@ -46,7 +46,7 @@ export class UserProfile extends React.Component<LocalProps, LocalState> {
4646
render(): JSX.Element {
4747
const {name, age} = this.props;
4848
return (
49-
<div className='myComponent'>
49+
<div className="user-profile-component">
5050
<div>{name} is {age} years old.</div>
5151
<div>Profile status: {this.getStatusText() }</div>
5252
<button onClick={this.handleToggleCompletion}>Toggle completion</button>

src/stores/app-store.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class AppStore {
1414
userData: UserData;
1515

1616
constructor() {
17-
this.userData = new UserData("Piotr", 33);
17+
this.userData = new UserData('Piotr', 33);
1818
}
1919

2020
}

src/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"files": [
2323
"app-typings.d.ts",
2424
"app.tsx",
25-
"components/app.tsx",
25+
"components/main.tsx",
2626
"components/user-profile.tsx",
2727
"stores/app-store.tsx"
2828
],

0 commit comments

Comments
 (0)