From 1a68a67bf8fbfe0b34884910626ce94c73189446 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sat, 13 Apr 2019 13:59:58 +0200 Subject: [PATCH] Lint code --- .eslintrc.js | 26 ++- package.json | 12 +- src/Components/App.js | 26 +-- src/Components/Header.js | 32 ++-- src/Components/Map.js | 84 +++++++--- src/Components/Vegetables.js | 74 +++++++-- src/Routes/Home.js | 82 ++++++---- src/Routes/Map.js | 43 +++-- src/Routes/Search.js | 52 ++++-- src/Routes/Vegetable.js | 249 +++++++++++++++++------------ src/Routes/Vegetables.js | 57 +++++-- src/StrToSlug.js | 2 +- yarn.lock | 299 +++++++++++++++++++++++++++++++++-- 13 files changed, 795 insertions(+), 243 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0505610..760224b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,24 @@ module.exports = { - "extends": "airbnb", - "env": { - "browser": true + env: { + browser: true, + es6: true, + }, + extends: 'airbnb', + globals: { + Atomics: 'readonly', + SharedArrayBuffer: 'readonly', + }, + parserOptions: { + ecmaFeatures: { + jsx: true, }, -}; \ No newline at end of file + ecmaVersion: 2018, + sourceType: 'module', + }, + plugins: [ + 'react', + ], + rules: { + 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }], + }, +}; diff --git a/package.json b/package.json index 62737b6..4852537 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "dependencies": { "axios": "^0.18.0", "bootstrap": "^4.1.3", - "history": "^4.7.2", + "history": "^4.9.0", + "prop-types": "^15.7.2", "react": "^16.6.1", "react-dom": "^16.6.1", "react-icons": "^3.2.2", @@ -28,5 +29,12 @@ "not dead", "not ie <= 11", "not op_mini all" - ] + ], + "devDependencies": { + "eslint": "^5.16.0", + "eslint-config-airbnb": "^17.1.0", + "eslint-plugin-import": "^2.16.0", + "eslint-plugin-jsx-a11y": "^6.2.1", + "eslint-plugin-react": "^7.12.4" + } } diff --git a/src/Components/App.js b/src/Components/App.js index 614d2c8..526ce6b 100644 --- a/src/Components/App.js +++ b/src/Components/App.js @@ -1,9 +1,9 @@ import React, { Component, Fragment } from 'react'; -import Header from './Header'; import { BrowserRouter as Router, Route, Switch, } from 'react-router-dom'; +import Header from './Header'; import Map from '../Routes/Map'; import Search from '../Routes/Search'; import Home from '../Routes/Home'; @@ -11,17 +11,7 @@ import Vegetables from '../Routes/Vegetables'; import Vegetable from '../Routes/Vegetable'; class App extends Component { - constructor(props) { - super(props) - - this.state = { - background: 1 - } - - this.changeBackground = this.changeBackground.bind(this); - } - - changeBackground(background) { + static changeBackground(background) { document.body.style.background = `url('/background/${background}.jpg') no-repeat fixed`; document.body.style.backgroundSize = 'cover'; document.body.style.backgroundPosition = 'center center'; @@ -30,33 +20,33 @@ class App extends Component { render() { return ( -
+
} + render={props => } /> } + render={props => } /> } + render={props => } /> } + render={props => } /> } + render={props => } /> diff --git a/src/Components/Header.js b/src/Components/Header.js index ebf7d16..9c5fbd2 100644 --- a/src/Components/Header.js +++ b/src/Components/Header.js @@ -24,9 +24,9 @@ import { NotificationContainer, NotificationManager, } from 'react-notifications'; +import { createBrowserHistory } from 'history'; import Api from './Api'; import strToSlug from '../StrToSlug'; -import { createBrowserHistory } from 'history'; import '../css/Header.css'; @@ -50,12 +50,6 @@ export default class Header extends React.Component { this.getVegetablesTypes(); } - toggle() { - this.setState({ - isOpen: !this.state.isOpen, - }); - } - getVegetablesTypes() { Api.get('types') .then((res) => { @@ -68,20 +62,33 @@ export default class Header extends React.Component { }); } + toggle() { + const { + isOpen, + } = this.state; + + this.setState({ + isOpen: !isOpen, + }); + } + handleChange(event) { this.setState({ search: event.target.value }); } - handleSubmit(event) { + handleSubmit() { const { - search + search, } = this.state; + history.push(`/recherche/${search}`); } render() { const { search, + isOpen, + types, } = this.state; return ( @@ -90,7 +97,7 @@ export default class Header extends React.Component { RodiVert - +