diff --git a/.eslintrc b/.eslintrc index ca3f6e5..adfde78 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,7 +1,8 @@ { "extends": [ "airbnb", - "prettier" + "prettier", + "prettier/react" ], "parser": "babel-eslint", "parserOptions": { @@ -45,9 +46,18 @@ "no-underscore-dangle": 0, "consistent-return": 0, "react/display-name": 1, + "react/no-unknown-property": 0, "react/react-in-jsx-scope": 0, "react/forbid-prop-types": 0, "react/no-unescaped-entities": 0, + "import/no-unresolved": 0, + "prefer-destructuring": 0, + "react/no-typos": 0, + "react/prefer-stateless-function": [0, + { + "ignorePureComponents": "true" + } + ], "jsx-a11y/accessible-emoji": 0, "react/jsx-filename-extension": [ 1, @@ -82,7 +92,7 @@ } ], "prettier/prettier": [ - "error", + "warn", { "trailingComma": "es5", "singleQuote": true, diff --git a/package.json b/package.json index 939f6cc..9cbb80d 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,22 @@ }, "devDependencies": { "eslint": "^4.15.0", + "eslint-config-airbnb": "^16.1.0", + "eslint-config-prettier": "^2.9.0", "eslint-config-synacor": "^2.0.4", "eslint-plugin-html": "^4.0.1", + "eslint-plugin-import": "^2.8.0", + "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-prettier": "^2.4.0", + "eslint-plugin-react": "^7.5.1", "if-env": "^1.0.0", "node-sass": "^4.7.2", "preact-cli": "^2.1.0", + "prettier": "^1.10.2", "sass-loader": "^6.0.6" }, "dependencies": { + "firebase": "^4.8.2", "preact": "^8.2.7", "preact-compat": "^3.17.0", "preact-router": "^2.6.0", diff --git a/src/base.js b/src/base.js index 2e4924c..123a1c0 100644 --- a/src/base.js +++ b/src/base.js @@ -1,7 +1,8 @@ import Rebase from 're-base'; +import fireApp from './base2'; + require('firebase/auth'); require('firebase/database'); -import fireApp from './base2'; const base = Rebase.createClass(fireApp.database()); export default base; diff --git a/src/base2.js b/src/base2.js index 157af3f..223180d 100644 --- a/src/base2.js +++ b/src/base2.js @@ -1,11 +1,12 @@ import firebase from 'firebase/app'; + require('firebase/auth'); require('firebase/database'); const fireApp = firebase.initializeApp({ - apiKey: "AIzaSyA1FJ3bLQnN1fstX3ZjHrH7564qvFi-ahI", - authDomain: "uva-reactnativeapp.firebaseapp.com", - databaseURL: "https://uva-reactnativeapp.firebaseio.com" + apiKey: 'AIzaSyA1FJ3bLQnN1fstX3ZjHrH7564qvFi-ahI', + authDomain: 'uva-reactnativeapp.firebaseapp.com', + databaseURL: 'https://uva-reactnativeapp.firebaseio.com', }); -export default fireApp; \ No newline at end of file +export default fireApp; diff --git a/src/components/app.js b/src/components/app.js index 7520963..e10e165 100644 --- a/src/components/app.js +++ b/src/components/app.js @@ -1,4 +1,4 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import { Router } from 'preact-router'; // Import Routes @@ -15,7 +15,7 @@ export default class App extends Component { super(); this.state = { - uid: 'hl8tgg53mkQIUmIh6D8SUsReTGD2' + uid: 'hl8tgg53mkQIUmIh6D8SUsReTGD2', }; } handleRoute = e => { diff --git a/src/components/header/index.js b/src/components/header/index.js index 73a710d..57bee3c 100644 --- a/src/components/header/index.js +++ b/src/components/header/index.js @@ -1,4 +1,4 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import { Link } from 'preact-router/match'; import style from './style'; @@ -8,9 +8,15 @@ export default class Header extends Component {

Preact App

); diff --git a/src/components/item/index.js b/src/components/item/index.js index cd4c32e..b9bcc00 100644 --- a/src/components/item/index.js +++ b/src/components/item/index.js @@ -1,4 +1,5 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; +import { PropTypes } from 'preact-compat'; import { Link } from 'preact-router/match'; import style from './style'; @@ -13,4 +14,8 @@ export default class Item extends Component { ); } -} \ No newline at end of file +} + +Item.propTypes = { + details: PropTypes.object.isRequired, +}; diff --git a/src/routes/Media/index.js b/src/routes/Media/index.js index 56a9472..08f2a60 100644 --- a/src/routes/Media/index.js +++ b/src/routes/Media/index.js @@ -1,4 +1,4 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import style from './style'; export default class Media extends Component { diff --git a/src/routes/account/index.js b/src/routes/account/index.js index 63a35ef..2b5cd5c 100644 --- a/src/routes/account/index.js +++ b/src/routes/account/index.js @@ -1,4 +1,4 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import style from './style'; export default class Account extends Component { diff --git a/src/routes/add/index.js b/src/routes/add/index.js index e9df746..9bc0786 100644 --- a/src/routes/add/index.js +++ b/src/routes/add/index.js @@ -1,4 +1,4 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import style from './style'; export default class Add extends Component { diff --git a/src/routes/addMedia/index.js b/src/routes/addMedia/index.js index 22510bf..f9e6832 100644 --- a/src/routes/addMedia/index.js +++ b/src/routes/addMedia/index.js @@ -1,4 +1,4 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import style from './style'; export default class AddMedia extends Component { diff --git a/src/routes/home/index.js b/src/routes/home/index.js index faa7a11..bf5eabe 100644 --- a/src/routes/home/index.js +++ b/src/routes/home/index.js @@ -1,4 +1,4 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import style from './style'; export default class Home extends Component { diff --git a/src/routes/login/index.js b/src/routes/login/index.js index 83cfb55..f97c3b2 100644 --- a/src/routes/login/index.js +++ b/src/routes/login/index.js @@ -1,4 +1,4 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import style from './style'; export default class Login extends Component { diff --git a/src/routes/measurement/index.js b/src/routes/measurement/index.js index c2ee74c..d6a0faf 100644 --- a/src/routes/measurement/index.js +++ b/src/routes/measurement/index.js @@ -1,4 +1,5 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; +import { PropTypes } from 'preact-compat'; import Header from '../../components/header'; import style from './style'; import base from '../../base'; @@ -8,14 +9,14 @@ export default class Measurement extends Component { super(props); this.state = { - measurement: {} + measurement: {}, }; } componentWillMount(nextProps) { this.ref = base.bindToState(`/${this.props.uid}/mes/${this.props.measurementId}`, { context: this, - state: 'measurement' + state: 'measurement', }); } @@ -28,43 +29,49 @@ export default class Measurement extends Component { return (
- {measurement.longitude && + {measurement.longitude && (

Longitude

{measurement.longitude}

- } - {measurement.latitude && + )} + {measurement.latitude && (

Latitude

{measurement.latitude}

- } - {measurement.date && + )} + {measurement.date && (

Date

{measurement.date}

- } - {measurement.acidity && + )} + {measurement.acidity && (

Acidity (pH)

{measurement.acidity}

- } - {measurement.salinity && + )} + {measurement.salinity && (

Salinity (PSU)

{measurement.salinity}

- } - {measurement.tempature && + )} + {measurement.tempature && (

Tempature

{measurement.tempature}

- } + )}
); } } + +Measurement.propTypes = { + uid: PropTypes.string.isRequired, + head: PropTypes.string.isRequired, + measurementId: PropTypes.string.isRequired, +}; diff --git a/src/routes/overview/index.js b/src/routes/overview/index.js index d2a577a..3457f2a 100644 --- a/src/routes/overview/index.js +++ b/src/routes/overview/index.js @@ -1,5 +1,6 @@ -import { h, Component } from 'preact'; +import { Component } from 'preact'; import { Link } from 'preact-router/match'; +import { PropTypes } from 'preact-compat'; import style from './style'; // Import Components @@ -14,14 +15,14 @@ export default class Overview extends Component { super(props); this.state = { - measurements: {} + measurements: {}, }; } componentWillMount(nextProps) { this.ref = base.syncState(`/${this.props.uid}/mes/`, { context: this, - state: 'measurements' + state: 'measurements', }); } @@ -72,3 +73,7 @@ export default class Overview extends Component { ); } } + +Overview.propTypes = { + uid: PropTypes.string.isRequired, +}; diff --git a/src/routes/profile/index.js b/src/routes/profile/index.js deleted file mode 100644 index 566f7a6..0000000 --- a/src/routes/profile/index.js +++ /dev/null @@ -1,47 +0,0 @@ -import { h, Component } from 'preact'; -import style from './style'; - -export default class Profile extends Component { - state = { - time: Date.now(), - count: 10 - }; - - // gets called when this route is navigated to - componentDidMount() { - // start a timer for the clock: - this.timer = setInterval(this.updateTime, 1000); - } - - // gets called just before navigating away from the route - componentWillUnmount() { - clearInterval(this.timer); - } - - // update the current time - updateTime = () => { - this.setState({ time: Date.now() }); - }; - - increment = () => { - this.setState({ count: this.state.count+1 }); - }; - - // Note: `user` comes from the URL, courtesy of our router - render({ user }, { time, count }) { - return ( -
-

Profile: {user}

-

This is the user profile for a user named { user }.

- -
Current time: {new Date(time).toLocaleString()}
- -

- - {' '} - Clicked {count} times. -

-
- ); - } -} diff --git a/src/routes/profile/style.scss b/src/routes/profile/style.scss deleted file mode 100644 index 4c85cc9..0000000 --- a/src/routes/profile/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -.profile { - padding: 56px 20px; - min-height: 100%; - width: 100%; -}