Skip to content

Commit

Permalink
tslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
quick-xp committed Apr 20, 2019
1 parent ae8c56b commit f8f5ccc
Show file tree
Hide file tree
Showing 28 changed files with 420 additions and 383 deletions.
14 changes: 7 additions & 7 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import { Switch, Route } from 'react-router-dom';
import { withRouter } from 'react-router';
import { GlobalStyle } from 'styles';
import * as React from 'react'
import { Switch, Route } from 'react-router-dom'
import { withRouter } from 'react-router'
import { GlobalStyle } from 'styles'

import { Test } from './modules';
import { Test } from './modules'

const App = () => (
<main>
Expand All @@ -14,6 +14,6 @@ const App = () => (
</Switch>
</React.Suspense>
</main>
);
)

export default withRouter(App);
export default withRouter(App)
18 changes: 9 additions & 9 deletions src/components/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { ThemeProvider } from 'styled-components';
import { theme } from 'styles';
import store from 'src/store';
import 'static/favicon.ico';
import App from './App';
import * as React from 'react'
import { BrowserRouter } from 'react-router-dom'
import { Provider } from 'react-redux'
import { ThemeProvider } from 'styled-components'
import { theme } from 'styles'
import store from 'src/store'
import 'static/favicon.ico'
import App from './App'

export default () => (
<>
Expand All @@ -17,4 +17,4 @@ export default () => (
</ThemeProvider>
</Provider>
</>
);
)
19 changes: 10 additions & 9 deletions src/components/common/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import * as i from 'types';
import * as React from 'react';
import styled from 'styled-components';
import * as i from 'types'
import * as React from 'react'
import styled from 'styled-components'

const Button = styled.button<ButtonProps>`
background: ${(props) => props.theme.color.primary};
background: ${props => props.theme.color.primary};
padding: 10px 20px;
border: none;
color: ${(props) => props.theme.color.white};
color: ${props => props.theme.color.white};
font-size: 16px;
outline: none;
border-radius: 5px;
cursor: pointer;
font-family: ${(props) => props.theme.font.futura};
`;
font-family: ${props => props.theme.font.futura};
`

// Use type for easier and composition
export type ButtonProps = i.BaseStyled & React.ButtonHTMLAttributes<HTMLButtonElement>;
export type ButtonProps = i.BaseStyled &
React.ButtonHTMLAttributes<HTMLButtonElement>

export default Button;
export default Button
2 changes: 1 addition & 1 deletion src/components/common/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as Button } from './Button';
export { default as Button } from './Button'
12 changes: 6 additions & 6 deletions src/components/modules/Test/components/TestPassed.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as React from 'react';
import * as confettiImg from 'images/confetti.png';
import * as React from 'react'
import * as confettiImg from 'images/confetti.png'

import { Message, Confetti } from './styled';
import { Message, Confetti } from './styled'

const TestPassed: React.StatelessComponent = () => (
<div>
<Message>
The boilerplate is successfully installed, you&apos;re ready to start.
<Confetti src={confettiImg} alt="confetti"/>
<Confetti src={confettiImg} alt="confetti" />
</Message>
<Message>Good Luck!</Message>
</div>
);
)

export default TestPassed;
export default TestPassed
2 changes: 1 addition & 1 deletion src/components/modules/Test/components/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as TestPassed } from './TestPassed';
export { default as TestPassed } from './TestPassed'
32 changes: 16 additions & 16 deletions src/components/modules/Test/components/styled.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import styled from 'styled-components';
import LogoIcon from 'vectors/logo.svg';
import styled from 'styled-components'
import LogoIcon from 'vectors/logo.svg'

export const Section = styled.section`
text-align: center;
`;
text-align: center;
`

export const LogoIconWrapper = styled(LogoIcon)`
width: 200px;
display: block;
margin: 0 auto;
`;
width: 200px;
display: block;
margin: 0 auto;
`

export const Message = styled.div`
font-size: 18px;
margin-top: 0;
color: ${(props) => props.theme.color.text};
font-family: ${(props) => props.theme.font.futura};
line-height: 30px;
`;
font-size: 18px;
margin-top: 0;
color: ${props => props.theme.color.text};
font-family: ${props => props.theme.font.futura};
line-height: 30px;
`

export const Confetti = styled.img`
width: 22px;
`;
width: 22px;
`
35 changes: 19 additions & 16 deletions src/components/modules/Test/index.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import * as i from 'types';
import * as React from 'react';
import { connect } from 'react-redux';
import * as i from 'types'
import * as React from 'react'
import { connect } from 'react-redux'

import { install } from 'ducks/test';
import { install } from 'ducks/test'

import { Button } from 'common';
import { TestPassed } from './components';
import { LogoIconWrapper, Section } from './components/styled';
import { Button } from 'common'
import { TestPassed } from './components'
import { LogoIconWrapper, Section } from './components/styled'

const Test: React.FC<HomeProps> = ({ test, ...props }) => (
<Section>
<LogoIconWrapper/>
<LogoIconWrapper />
{test.passed ? (
<TestPassed/>
<TestPassed />
) : (
<Button onClick={props.install}>
{test.loading ? 'Installing ...' : 'Test installation'}
</Button>
)}
</Section>
);
)

const mapStateToProps: i.MapStateToProps = (state) => ({
test: state.test,
});
const mapStateToProps: i.MapStateToProps = state => ({
test: state.test
})

export interface HomeProps {
test: i.TestState;
install: i.InstallAction;
test: i.TestState
install: i.InstallAction
}

export default connect(mapStateToProps, { install })(Test);
export default connect(
mapStateToProps,
{ install }
)(Test)
4 changes: 2 additions & 2 deletions src/components/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as React from 'react';
import * as React from 'react'

export const Test = React.lazy(() => import('./Test'));
export const Test = React.lazy(() => import('./Test'))
6 changes: 3 additions & 3 deletions src/ducks/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from './test';
import test from './test'

export const appReducers = {
test,
};
test
}
46 changes: 23 additions & 23 deletions src/ducks/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as i from 'types';
import { action } from 'typesafe-actions';
import * as i from 'types'
import { action } from 'typesafe-actions'

const LOAD = 'user/load';
const SUCCESS = 'user/success';
const FAILED = 'user/failed';
const LOAD = 'user/load'
const SUCCESS = 'user/success'
const FAILED = 'user/failed'

const initialState: i.TestState = {
error: false,
loading: false,
passed: false,
};
passed: false
}

export default (state = initialState, action: i.Actions<typeof actions>) => {
switch (action.type) {
Expand All @@ -18,44 +18,44 @@ export default (state = initialState, action: i.Actions<typeof actions>) => {
...state,
loading: true,
error: false,
passed: false,
};
passed: false
}

case SUCCESS:
return {
...state,
loading: false,
error: false,
passed: action.payload,
};
passed: action.payload
}

case FAILED:
return {
...state,
loading: false,
error: true,
passed: false,
};
passed: false
}

default:
return state;
return state
}
};
}

export const actions = {
load: () => action(LOAD),
success: (passed: boolean) => action(SUCCESS, passed),
failed: () => action(FAILED),
};
failed: () => action(FAILED)
}

export const install: i.InstallAction = () => {
return async (dispatch, getState, api) => {
dispatch(actions.load());
dispatch(actions.load())

setTimeout(() => {
dispatch(actions.success(true));
}, 2000);
dispatch(actions.success(true))
}, 2000)

return;
};
};
return
}
}
10 changes: 5 additions & 5 deletions src/ducks/test/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as i from 'types';
import * as i from 'types'

export interface TestState {
error: boolean;
loading: boolean;
passed: boolean;
error: boolean
loading: boolean
passed: boolean
}

export type InstallAction = () => i.ThunkAction<Promise<void>>;
export type InstallAction = () => i.ThunkAction<Promise<void>>
33 changes: 19 additions & 14 deletions src/ducks/types.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import * as i from 'types';
import { Dispatch } from 'redux';
import { ThunkAction as IThunkAction } from 'redux-thunk';
import { ActionType } from 'typesafe-actions';
import * as i from 'types'
import { Dispatch } from 'redux'
import { ThunkAction as IThunkAction } from 'redux-thunk'
import { ActionType } from 'typesafe-actions'

export interface ReduxState {
test: i.TestState;
test: i.TestState
}

export interface Action<P = any> {
type: string;
payload?: P;
error?: boolean,
meta?: any,
type: string
payload?: P
error?: boolean
meta?: any
}

export type Actions<A> = ActionType<A>;
export type Actions<A> = ActionType<A>

export type ThunkAction<ReturnType> = IThunkAction<ReturnType, i.ReduxState, i.ApiHelper, Action>;
export type ThunkAction<ReturnType> = IThunkAction<
ReturnType,
i.ReduxState,
i.ApiHelper,
Action
>

export type D = Dispatch<i.Action>;
export type GS = () => i.ReduxState;
export type A = i.ApiHelper;
export type D = Dispatch<i.Action>
export type GS = () => i.ReduxState
export type A = i.ApiHelper
14 changes: 7 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as React from 'react'
import * as ReactDOM from 'react-dom'

const render = () => {
const Root = require('components/Root').default;
ReactDOM.render(<Root />, document.getElementById('app'));
};
const Root = require('components/Root').default
ReactDOM.render(<Root />, document.getElementById('app'))
}

if (__DEV__ && module.hot) {
module.hot.accept('components/Root', render);
module.hot.accept('components/Root', render)
}

render();
render()
Loading

0 comments on commit f8f5ccc

Please sign in to comment.