Skip to content

Commit db14c30

Browse files
committed
Added eslint and prettier
1 parent 29de49c commit db14c30

File tree

15 files changed

+211
-18
lines changed

15 files changed

+211
-18
lines changed

.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "airbnb"
3+
}

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,12 @@
922922
"yesno": "^0.0.1",
923923
"zen-observable": "^0.6.1"
924924
},
925-
"devDependencies": {},
925+
"devDependencies": {
926+
"eslint-config-airbnb": "^16.1.0",
927+
"eslint-plugin-import": "^2.9.0",
928+
"eslint-plugin-jsx-a11y": "^6.0.3",
929+
"eslint-plugin-react": "^7.7.0"
930+
},
926931
"scripts": {
927932
"test": "echo \"Error: no test specified\" && exit 1"
928933
},

packages/gtfs-react-native/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"expo": "^25.0.0",
3030
"graphql": "^0.12.3",
3131
"graphql-tag": "^2.6.1",
32+
"prettier": "^1.11.1",
3233
"react": "16.2.0",
3334
"react-apollo": "^2.0.4",
3435
"react-native": "0.52.0",

packages/gtfs-react-native/yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -5381,6 +5381,10 @@ preserve@^0.2.0:
53815381
version "0.2.0"
53825382
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
53835383

5384+
prettier@^1.11.1:
5385+
version "1.11.1"
5386+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.11.1.tgz#61e43fc4cd44e68f2b0dfc2c38cd4bb0fccdcc75"
5387+
53845388
pretty-format@^21.2.1:
53855389
version "21.2.1"
53865390
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-21.2.1.tgz#ae5407f3cf21066cd011aa1ba5fce7b6a2eddb36"

packages/gtfs-react/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"graphql": "^0.12.3",
1515
"graphql-tag": "^2.6.1",
1616
"leaflet": "^1.3.1",
17+
"prettier": "^1.11.1",
1718
"react": "^16.2.0",
1819
"react-apollo": "^2.1.0-rc.5",
1920
"react-dom": "^16.2.0",

packages/gtfs-react/src/App.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { BrowserRouter as Router, Switch, Route, Redirect } from 'react-router-dom';
33

4+
import StopsContainer from './containers/StopsContainer';
45
import RoutesContainer from './containers/RoutesContainer';
56
import RouteContainer from './containers/RouteContainer';
67

@@ -9,6 +10,7 @@ import './App.css';
910
const App = () => (
1011
<Router>
1112
<Switch>
13+
<Route exact path="/stops" component={StopsContainer}/>
1214
<Route exact path="/routes" component={RoutesContainer}/>
1315
<Route exact path="/routes/:id" component={RouteContainer}/>
1416
<Redirect from={'/'} to={'/routes'}/>
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import React, { Fragment } from 'react';
1+
import React from 'react';
22
import { Map, Marker, TileLayer, Polyline } from 'react-leaflet';
33

44
const RouteMap = ({ shapes }) => {
55
const positions = shapes.map( shape => [shape.shape_pt_lat, shape.shape_pt_lon]);
6-
return <Fragment>
7-
<Map center={positions[0]} zoom={14} style={{ height: 400 }}>
8-
<TileLayer
9-
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
10-
attribution="&copy; <a href=&quot;http://osm.org/copyright&quot;>OpenStreetMap</a> contributors"
11-
/>
6+
return <Map center={positions[0]} zoom={14} style={{ height: 400 }}>
7+
<TileLayer
8+
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
9+
attribution="&copy; <a href=&quot;http://osm.org/copyright&quot;>OpenStreetMap</a> contributors"
10+
/>
1211

13-
{
14-
shapes.map( (shape) => (<Marker key={shape.shape_pt_sequence} position={[shape.shape_pt_lat, shape.shape_pt_lon]} />))
15-
}
16-
<Polyline positions={ positions } />
17-
</Map>
18-
</Fragment>;
12+
{
13+
shapes.map( (shape) => (<Marker key={shape.shape_pt_sequence} position={[shape.shape_pt_lat, shape.shape_pt_lon]} />))
14+
}
15+
<Polyline positions={ positions } />
16+
</Map>;
1917
}
2018

2119
export default RouteMap;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React, { Fragment } from 'react';
2+
import { Link } from 'react-router-dom';
3+
import List from 'antd/lib/list';
4+
5+
const Stop = ({ stop_id, stop_name }) => (
6+
<List.Item>
7+
<Link to={`/stops/${stop_id}`}>{stop_id} - {stop_name}</Link>
8+
</List.Item>
9+
)
10+
11+
const Stops = ({ stops }) => (
12+
<Fragment>
13+
<h3>Stops</h3>
14+
<List dataSource={stops} renderItem={Stop} bordered />
15+
</Fragment>
16+
);
17+
18+
export default Stops;

packages/gtfs-react/src/containers/RouteContainer.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Fragment } from 'react';
2-
import { gql } from 'apollo-boost'
2+
import { gql } from 'apollo-boost';
33
import { Query } from 'react-apollo';
44

55
import Route from '../components/Route';

packages/gtfs-react/src/containers/RoutesContainer.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import gql from 'graphql-tag'
1+
import { gql } from 'apollo-boost';
22
import { compose, graphql } from 'react-apollo';
33

44
import Routes from '../components/Routes';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { gql } from 'apollo-boost';
3+
import { Query } from 'react-apollo';
4+
5+
import Stops from '../components/Stops';
6+
7+
const GET_STOPS = gql`query Stops {
8+
stops {
9+
stop_id
10+
stop_name
11+
}
12+
}`;
13+
14+
const StopsContainer = () => {
15+
return (<Query query={GET_STOPS}>
16+
{({ loading, error, data }) => {
17+
if (loading) return "Loading...";
18+
if (error) return `Error! ${error.message}`;
19+
20+
return <Stops stops={data.stops} />
21+
}}
22+
</Query>)
23+
};
24+
25+
export default StopsContainer;

packages/gtfs-react/yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -5356,6 +5356,10 @@ preserve@^0.2.0:
53565356
version "0.2.0"
53575357
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
53585358

5359+
prettier@^1.11.1:
5360+
version "1.11.1"
5361+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.11.1.tgz#61e43fc4cd44e68f2b0dfc2c38cd4bb0fccdcc75"
5362+
53595363
pretty-bytes@^4.0.2:
53605364
version "4.0.2"
53615365
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"

packages/gtfs-server/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"gtfs": "^1.6.1",
2323
"mongoose": "^5.0.11",
2424
"nodemon": "^1.17.2",
25+
"prettier": "^1.11.1",
2526
"react-apollo": "^2.0.4"
2627
}
2728
}

packages/gtfs-server/yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,10 @@ prepend-http@^1.0.1:
18271827
version "1.0.4"
18281828
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
18291829

1830+
prettier@^1.11.1:
1831+
version "1.11.1"
1832+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.11.1.tgz#61e43fc4cd44e68f2b0dfc2c38cd4bb0fccdcc75"
1833+
18301834
process-nextick-args@~2.0.0:
18311835
version "2.0.0"
18321836
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"

0 commit comments

Comments
 (0)