Skip to content

Commit 204b01d

Browse files
committed
Integrate TSLint
1 parent 48b9f11 commit 204b01d

File tree

33 files changed

+471
-279
lines changed

33 files changed

+471
-279
lines changed

.eslintrc

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

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
language: node_js
1313
node_js: 8.11.2
1414
install: yarn
15-
script: npm run lint
15+
script: yarn lint
1616
- stage: Build Android 🤖
1717
before_install:
1818
- sudo apt-get install build-essential checkinstall && sudo apt-get install libssl-dev

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![License](https://img.shields.io/github/license/AmitM30/react-native-typescript-boilerplate.svg) ![Build](https://build.appcenter.ms/v0.1/apps/d3466edd-c992-45c8-abd3-a2f40f6a7fa1/branches/master/badge)
44

5-
### An opinionated [React Native](https://facebook.github.io/react-native/docs/getting-started) Starter Kit with [React Native Navigation](https://github.com/wix/react-native-navigation) + [Redux](https://github.com/reactjs/redux) + [Eslint](https://github.com/airbnb/javascript) to build iOS / Android apps using [TypeScript](https://github.com/Microsoft/TypeScript-React-Native-Starter)
5+
### An opinionated [React Native](https://facebook.github.io/react-native/docs/getting-started) Starter Kit with [React Native Navigation](https://github.com/wix/react-native-navigation) + [Redux](https://github.com/reactjs/redux) + [TSLint](https://github.com/airbnb/javascript) to build iOS / Android apps using [TypeScript](https://github.com/Microsoft/TypeScript-React-Native-Starter)
66

77
The project has been setup based off [RN Getting Started](https://facebook.github.io/react-native/docs/getting-started) and instructions from [Microsoft's Github TypeScript React Native Starter](https://github.com/Microsoft/TypeScript-React-Native-Starter) repo.
88

@@ -17,7 +17,7 @@ You might also want to [rename](https://medium.com/the-react-native-log/how-to-r
1717
_Disclaimer_:
1818
This is an **opinionated** approach to building apps with RN. The project structure is inspired by multiple production apps built by the contributors.
1919

20-
The project uses and encourages to use industry best practices / tools / libraries like RNN, redux, eslint, separation of concern and structure to build a maintainable app.
20+
The project uses and encourages to use industry best practices / tools / libraries like RNN, redux, tslint, separation of concern and structure to build a maintainable app.
2121

2222
### Table of Contents
2323

@@ -62,10 +62,11 @@ The project uses and encourages to use industry best practices / tools / librari
6262
│ ├── presentation
6363
│ └── redux
6464
├── .babelrc
65-
├── .eslintrc Lint configuration - extending AirBnb
6665
├── .gitignore
67-
├── .travis.yml Travis CI
66+
├── .travis.yml Travis CI
6867
├── tsconfig.json TypeScript Configuration
68+
├── tslint.js TSLint configuration - extending AirBnb
69+
├── tsconfig.json
6970
├── app.json
7071
├── index.js Application Entry point
7172
├── package.json
@@ -113,16 +114,16 @@ and the launch from IDE.
113114

114115
#### Lint
115116

116-
To run lint on the application:
117+
To run tslint on the application:
117118

118119
```
119-
npm run lint
120+
yarn lint
120121
```
121122

122-
To fix lint issues automatically
123+
To fix most tslint issues automatically
123124

124125
```
125-
npm run lint:fix
126+
yarn lint:fix
126127
```
127128

128129
#### Unit Test
@@ -166,7 +167,7 @@ Please check out [Contributing](https://github.com/AmitM30/react-native-typescri
166167

167168
#### Authors
168169

169-
- **Anurag Chutani** - _Android Setup_ - [Profile](https://github.com/a7urag)
170+
- [**Anurag Chutani**](https://github.com/a7urag) - _Android Setup_
170171

171172
See also the list of [contributors](https://github.com/AmitM30/react-native-typescript-boilerplate/contributors) who participated in this project.
172173

__tests__/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
*/
55

66
import 'react-native';
7-
import renderer from 'react-test-renderer';
7+
import reactTestRenderer from 'react-test-renderer';
88

9-
import App from '../src/navigators';
9+
import * as App from '../src/navigators';
1010

1111
// Note: test renderer must be required after react-native.
1212

1313
it('renders correctly', () => {
14-
renderer.create(App());
14+
reactTestRenderer.create(App());
1515
});

__tests__/views/home.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import React from 'react';
21
import 'react-native';
3-
import renderer from 'react-test-renderer';
2+
import reactTestRenderer from 'react-test-renderer';
43

5-
import Home from '../../src/view/screens/home';
4+
import * as Home from '../../src/view/screens/home';
65
// Note: test renderer must be required after react-native.
76

87
it('renders correctly with defaults', () => {
9-
const tree = renderer.create(<Home name="Amit" />).toJSON();
8+
const tree = reactTestRenderer.create(<Home name="Amit" />).toJSON();
109
expect(tree).toMatchSnapshot();
1110
});

index.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
// /**
2-
// * @format
3-
// * @lint-ignore-every XPLATJSCOPYRIGHT1
4-
// */
5-
6-
// import { AppRegistry } from "react-native";
7-
// import App from "./App";
8-
// import { name as appName } from "./app.json";
9-
10-
// AppRegistry.registerComponent(appName, () => App);
11-
12-
import App from './src/navigators';
1+
/**
2+
* @format
3+
* @lint-ignore-every XPLATJSCOPYRIGHT1
4+
*/
5+
import App from "./src/navigators";
136

147
App();

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"start": "node node_modules/react-native/local-cli/cli.js start",
2727
"test": "jest",
2828
"android": "react-native run-android --variant=Debug",
29-
"lint": "eslint .",
30-
"lint:fix": "npm run lint -- --fix"
29+
"lint": "tslint --project ./tsconfig.json",
30+
"lint:fix": "tslint --fix --project ./tsconfig.json"
3131
},
3232
"dependencies": {
3333
"react": "16.6.3",
@@ -67,6 +67,8 @@
6767
"react-test-renderer": "16.6.3",
6868
"regenerator-runtime": "^0.13.1",
6969
"ts-jest": "^23.10.5",
70+
"tslint": "^5.12.1",
71+
"tslint-config-airbnb": "^5.11.1",
7072
"typescript": "^3.2.4"
7173
},
7274
"jest": {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* Add All Action constants here */
22

3-
const ActionTypes = {
3+
const ACTION_TYPES = {
44
// Splash Actions
5-
SPLASH_LAUNCHED: 'SPLASH_LAUNCHED'
5+
SPLASH_LAUNCHED: 'SPLASH_LAUNCHED',
66
};
77

8-
export default ActionTypes;
8+
export { ACTION_TYPES };

shared/redux/reducers/app.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import ActionTypes from '../constants/actionTypes';
1+
import { ACTION_TYPES } from '../constants/actionTypes';
22

33
const initialState = {
4-
isLoading: false
4+
isLoading: false,
55
};
66

7-
export default (state = initialState, action) => {
7+
export default (state = initialState, action: any) => {
88
switch (action.type) {
9-
case ActionTypes.SPLASH_LAUNCHED:
9+
case ACTION_TYPES.SPLASH_LAUNCHED:
1010
return {
11-
...state
11+
...state,
1212
};
1313
default:
1414
return state;

shared/redux/reducers/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import { combineReducers } from 'redux';
88
import app from './app';
99

1010
export default combineReducers({
11-
app
11+
app,
1212
});

0 commit comments

Comments
 (0)