Skip to content

Commit fa8586b

Browse files
authored
Fix docs, prettier, typo in README and apply format (#11)
* chore(devDependencies): Add eslint-plugin-prettier and pin versions * chore(docs): Add packages versions and fix typo on Contributing section * chore(prettier): Add scripts and extensions for prettier * chore(eslintrc): Extends from prettier * chore(README): Add scripts to prettier bin * refactor(App): Format files and update features list * chore: Remove .gitignore and refactor test * fix(lint): Remove prettier/react
1 parent 740a11a commit fa8586b

File tree

8 files changed

+62
-53
lines changed

8 files changed

+62
-53
lines changed

.eslintrc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
"jest": true,
55
"react-native/react-native": true
66
},
7-
"extends": ["airbnb", "plugin:react/recommended"],
7+
"extends": ["airbnb", "plugin:react/recommended", "prettier"],
88
"globals": {
99
"__DEV__": false
1010
},
1111
"parser": "babel-eslint",
12-
"plugins": [
13-
"react",
14-
"react-native",
15-
"prettier"
16-
],
12+
"plugins": ["react", "react-native", "prettier"],
1713
"rules": {
1814
"arrow-parens": ["error", "as-needed"],
1915
"class-methods-use-this": "off",

.gitignore

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

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ To inject custom scripts and remove unnecessary files.
2626

2727
### Includes
2828

29-
- [x] ESlint (extends Airnbn)
30-
- [x] Lint Staged
29+
- [x] ESlint (extends Airbnb) v4.19.1
30+
- [x] Lint Staged v7.3.0
31+
- [x] Prettier v1.14.3
3132

3233
### Custom Scripts
3334

@@ -37,6 +38,8 @@ To inject custom scripts and remove unnecessary files.
3738
- [x] `ios:install` - Run in Release mode
3839
- [x] `project:clean` - Clean project
3940
- [x] `precommit` - Run tasks before commit
41+
- [x] `prettier:check` - Check for unformatted files
42+
- [x] `prettier:all` - Format files
4043
- [x] `lint` - Run lint
4144
- [x] `start` - Start Metro Bundler
4245
- [x] `start:clean` - Start Metro Bundler without cache
@@ -51,7 +54,7 @@ To inject custom scripts and remove unnecessary files.
5154

5255
### Contributing
5356

54-
Clone this repo with `git clone https://github.com/lucianomlima/react-native-template-basic react-native-template-basic-app` cause npm needs project dir name to be equal project name in `package.json`.
57+
Clone this repo with `git clone https://github.com/lucianomlima/react-native-template-basic react-native-template-basic-app` cause npm needs project dir name to be equal to project name in `package.json`.
5558

5659
To execute the project with your changes, you can use the absolute path of cloned repo with `react-native-cli`:
5760

devDependencies.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
2-
"@babel/core": "^7.0.0-beta",
3-
"@babel/runtime": "^7.0.0-beta",
4-
"babel-core": "^7.0.0-bridge.0",
5-
"babel-eslint": "^8.2.2",
6-
"babel-jest": "^23.4.2",
7-
"eslint": "^4.19.1",
8-
"eslint-config-airbnb": "^17.0.0",
9-
"eslint-plugin-import": "^2.12.0",
10-
"eslint-plugin-jsx-a11y": "^6.0.3",
11-
"eslint-plugin-react": "^7.9.1",
12-
"eslint-plugin-react-native": "^3.2.1",
13-
"lint-staged": "^7.3.0",
2+
"@babel/core": "7.1.2",
3+
"@babel/runtime": "7.1.2",
4+
"babel-core": "7.0.0-bridge.0",
5+
"babel-eslint": "8.2.6",
6+
"eslint": "4.19.1",
7+
"eslint-config-airbnb": "17.1.0",
8+
"eslint-config-prettier": "3.1.0",
9+
"eslint-plugin-import": "2.14.0",
10+
"eslint-plugin-jsx-a11y": "6.1.2",
11+
"eslint-plugin-prettier": "3.0.0",
12+
"eslint-plugin-react": "7.11.1",
13+
"eslint-plugin-react-native": "3.5.0",
14+
"lint-staged": "7.3.0",
1415
"prettier": "1.14.3"
1516
}

extension.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
}
77
},
88
"lint-staged": {
9-
"*.js": ["prettier --write", "yarn lint", "yarn test", "git add"]
9+
"*.js": [
10+
"prettier --write",
11+
"yarn lint",
12+
"yarn test",
13+
"git add"
14+
]
15+
},
16+
"prettier": {
17+
"printWidth": 100,
18+
"singleQuote": true,
19+
"trailingComma": "es5"
1020
}
1121
}

scripts.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"ios:install": "react-native run-ios --configuration Release",
77
"project:clean": "rm -Rf $TMPDIR/react-* node_modules && watchman watch-del-all && yarn cache clean && cd android && ./gradlew clean && cd .. && yarn",
88
"precommit": "lint-staged",
9+
"prettier:check": "prettier -l index.js src/**/*.js",
10+
"prettier:all": "prettier --insert-pragma --write index.js src/**/*.js",
911
"lint": "eslint --ext .js src/** ",
1012
"start": "node node_modules/react-native/local-cli/cli.js start",
1113
"start:clean": "yarn start --reset-cache",

src/App/__tests__/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React from 'react';
1+
/** @format */
2+
23
import renderer from 'react-test-renderer';
34

45
import App from '..';
56

67
test('should render properly', () => {
7-
const tree = renderer.create(<App />).toJSON();
8+
const tree = renderer.create(App).toJSON();
89
expect(tree).toMatchSnapshot();
910
});

src/App/index.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,13 @@
11
/**
22
* React Native Basic App
33
* https://github.com/facebook/react-native
4+
*
5+
* @format
46
*/
57

6-
import React, { Component } from 'react';
8+
import React from 'react';
79
import { Platform, StyleSheet, Text, View } from 'react-native';
810

9-
const instructions = Platform.select({
10-
ios: 'Press Cmd+R to reload,\nCmd+D or shake for dev menu',
11-
android:
12-
'Double tap R on your keyboard to reload,\n' +
13-
'Shake or press menu button for dev menu',
14-
});
15-
16-
type Props = {};
17-
export default class App extends Component<Props> {
18-
render() {
19-
return (
20-
<View style={styles.container}>
21-
<Text style={styles.welcome}>Welcome to React Native!</Text>
22-
<Text style={styles.instructions}>Your App is ready and you already have:</Text>
23-
<View style={styles.featuresList}>
24-
<Text style={styles.feature}>{'\u2705 ESLint'}</Text>
25-
<Text style={styles.feature}>{'\u2705 Custom Scripts'}</Text>
26-
</View>
27-
<Text style={styles.instructions}>To get started, edit App.js</Text>
28-
<Text style={styles.instructions}>{instructions}</Text>
29-
</View>
30-
);
31-
}
32-
}
33-
3411
const styles = StyleSheet.create({
3512
container: {
3613
alignItems: 'center',
@@ -57,3 +34,25 @@ const styles = StyleSheet.create({
5734
marginVertical: 5,
5835
},
5936
});
37+
38+
const instructions = Platform.select({
39+
ios: 'Press Cmd+R to reload,\nCmd+D or shake for dev menu',
40+
android: 'Double tap R on your keyboard to reload,\nShake or press menu button for dev menu',
41+
});
42+
43+
const App = (
44+
<View style={styles.container}>
45+
<Text style={styles.welcome}>Welcome to React Native!</Text>
46+
<Text style={styles.instructions}>Your App is ready and you already have:</Text>
47+
<View style={styles.featuresList}>
48+
<Text style={styles.feature}>{'\u2705 ESLint'}</Text>
49+
<Text style={styles.feature}>{'\u2705 Prettier'}</Text>
50+
<Text style={styles.feature}>{'\u2705 Lint Staged'}</Text>
51+
<Text style={styles.feature}>{'\u2705 Custom Scripts'}</Text>
52+
</View>
53+
<Text style={styles.instructions}>To get started, edit App.js</Text>
54+
<Text style={styles.instructions}>{instructions}</Text>
55+
</View>
56+
);
57+
58+
export default App;

0 commit comments

Comments
 (0)