Skip to content

Commit cd27198

Browse files
author
Christopher J. Brody
committed
[WIP] yarn lint task WITH A TEMPORARY TRICK
NOTE that this has a trick to use eslint-config-standard-jsx to quickly get a very basic working set of eslint rules working with React that is up-to-date. TODO: we need a new eslint config package that is designed to gives us the basic set of working eslint rules without using this kind of a trick.
1 parent be596f6 commit cd27198

File tree

9 files changed

+350
-18
lines changed

9 files changed

+350
-18
lines changed

.eslintrc.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
extends:
2+
- eslint:recommended
3+
- plugin:react/recommended
4+
- standard-jsx
5+
6+
rules:
7+
react/jsx-indent: off
8+
react/jsx-indent-props: off
9+
10+
settings:
11+
react:
12+
version: detect

App.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-env jasmine */
2+
13
import React from 'react';
24
import App from './App';
35

@@ -6,4 +8,4 @@ import renderer from 'react-test-renderer';
68
it('renders without crashing', () => {
79
const rendered = renderer.create(<App />).toJSON();
810
expect(rendered).toBeTruthy();
9-
});
11+
});

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ A full list of the scripts defined in `package.json` is shown below.
3333
| ------------------- | ------------------------------------------------------- |
3434
| `yarn web` | Start CRA Development Build |
3535
| `yarn build-web` | Create production build for web |
36+
| `yarn lint` | Check results of eslint with very basic rules |
3637
| `yarn start-expo` | Start the Expo packager |
3738
| `yarn start-native` | Start the native packager (not supported) |
3839
| `yarn eject-native` | Eject from Expo |

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"scripts": {
1414
"web": "react-scripts start",
1515
"build-web": "react-scripts build",
16+
"lint": "eslint *.js src/**/*.js",
1617
"start-expo": "expo start",
1718
"start-native": "react-native-scripts start",
1819
"eject-native": "react-native-scripts eject",
@@ -28,6 +29,10 @@
2829
"babel-plugin-transform-object-rest-spread": "^6.26.0",
2930
"babel-plugin-transform-react-jsx-source": "^6.22.0",
3031
"babel-preset-expo": "^4.0.0",
32+
"eslint": "^5.16.0",
33+
"eslint-config-standard-jsx": "^6.0.2",
34+
"eslint-plugin-import": "^2.16.0",
35+
"eslint-plugin-react": "^7.12.4",
3136
"flow-bin": "^0.66.0",
3237
"react-art": "16.5.1",
3338
"react-native-scripts": "^1.13.1",

src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-env amd */
2+
13
import React from "react";
24
import { View, Text, Animated, StyleSheet } from "react-native";
35

src/App.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* eslint-env browser */
2+
/* eslint-env jasmine */
3+
14
import React from 'react';
25
import ReactDOM from 'react-dom';
36
import App from './App';

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-env browser */
2+
13
import React from 'react';
24
import ReactDOM from 'react-dom';
35

src/registerServiceWorker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/* eslint-env browser */
2+
/* eslint-env node */
3+
/* eslint no-console: off */
4+
15
// In production, we register a service worker to serve assets from local cache.
26

37
// This lets the app load faster on subsequent visits in production, and gives

0 commit comments

Comments
 (0)