feat(pettier) : update eslint package and fix some problems (ignore prop-type validations problems for now)

pull/73/head
Clement G 4 years ago
parent e6482a7962
commit 8ef1d13f22

@ -3,6 +3,7 @@
"browser": true, "browser": true,
"es6": true "es6": true
}, },
"parser": "babel-eslint",
"extends": [ "extends": [
"eslint:recommended", "eslint:recommended",
"plugin:react/recommended" "plugin:react/recommended"
@ -21,6 +22,11 @@
"plugins": [ "plugins": [
"react" "react"
], ],
"settings": {
"react": {
"version": "detect"
}
},
"rules": { "rules": {
} }
} }

@ -10,10 +10,10 @@
"@fortawesome/free-solid-svg-icons": "^5.9.0", "@fortawesome/free-solid-svg-icons": "^5.9.0",
"@fortawesome/react-fontawesome": "^0.1.4", "@fortawesome/react-fontawesome": "^0.1.4",
"@svgr/webpack": "4.1.0", "@svgr/webpack": "4.1.0",
"@typescript-eslint/eslint-plugin": "1.6.0", "@typescript-eslint/eslint-plugin": "2.29.0",
"@typescript-eslint/parser": "1.6.0", "@typescript-eslint/parser": "2.29.0",
"axios": "^0.19.0", "axios": "^0.19.0",
"babel-eslint": "10.0.1", "babel-eslint": "^10.1.0",
"babel-jest": "^24.8.0", "babel-jest": "^24.8.0",
"babel-loader": "8.0.5", "babel-loader": "8.0.5",
"babel-plugin-named-asset-import": "^0.3.2", "babel-plugin-named-asset-import": "^0.3.2",
@ -26,14 +26,14 @@
"dotenv-expand": "4.2.0", "dotenv-expand": "4.2.0",
"enzyme": "^3.9.0", "enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.13.1", "enzyme-adapter-react-16": "^1.13.1",
"eslint": "^5.16.0", "eslint": "^6.8.0",
"eslint-config-react-app": "^4.0.1", "eslint-config-react-app": "^5.2.1",
"eslint-loader": "2.1.2", "eslint-loader": "4.0.2",
"eslint-plugin-flowtype": "2.50.1", "eslint-plugin-flowtype": "4.7.0",
"eslint-plugin-import": "2.16.0", "eslint-plugin-import": "2.20.2",
"eslint-plugin-jsx-a11y": "6.2.1", "eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.12.4", "eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "^1.5.0", "eslint-plugin-react-hooks": "^3.0.0",
"file-loader": "3.0.1", "file-loader": "3.0.1",
"fs-extra": "7.0.1", "fs-extra": "7.0.1",
"global": "^4.4.0", "global": "^4.4.0",
@ -56,6 +56,7 @@
"postcss-normalize": "7.0.1", "postcss-normalize": "7.0.1",
"postcss-preset-env": "6.6.0", "postcss-preset-env": "6.6.0",
"postcss-safe-parser": "4.0.1", "postcss-safe-parser": "4.0.1",
"prop-types": "^15.7.2",
"query-string": "^6.12.0", "query-string": "^6.12.0",
"querystringify": "^2.0.0", "querystringify": "^2.0.0",
"react": "^16.8.6", "react": "^16.8.6",

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { createContext, Suspense } from "react"; import React, { createContext, Suspense } from "react";
import { BrowserRouter as Router } from "react-router-dom"; import { BrowserRouter as Router } from "react-router-dom";
import Loader from "./components/loader"; import Loader from "./components/loader";
@ -6,6 +7,7 @@ export const AppContext = createContext();
const AppContextProvider = ({ children }) => { const AppContextProvider = ({ children }) => {
const defaultState = { const defaultState = {
// eslint-disable-next-line no-undef
urlServer: process.env.REACT_APP_SERVER_URL, urlServer: process.env.REACT_APP_SERVER_URL,
routesServer: { routesServer: {
setElection: "election/", setElection: "election/",

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React from "react"; import React from "react";
import { Container, Row, Col } from "reactstrap"; import { Container, Row, Col } from "reactstrap";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
@ -13,7 +14,7 @@ export const UNKNOWN_TOKEN_ERROR = "E7";
export const USED_TOKEN_ERROR = "E8"; export const USED_TOKEN_ERROR = "E8";
export const WRONG_ELECTION_ERROR = "E9"; export const WRONG_ELECTION_ERROR = "E9";
export const redirectError = (errorMsg, history) => {}; export const redirectError = () => {};
export const errorMessage = (error, t) => { export const errorMessage = (error, t) => {
if (error.startsWith(UNKNOWN_ELECTION_ERROR)) { if (error.startsWith(UNKNOWN_ELECTION_ERROR)) {

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React from "react"; import React from "react";
import { Button } from "reactstrap"; import { Button } from "reactstrap";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
@ -8,7 +9,7 @@ const CopyField = props => {
event.target.focus(); event.target.focus();
event.target.select(); event.target.select();
}; };
const handleClickOnButton = event => { const handleClickOnButton = () => {
const input = ref.current; const input = ref.current;
input.focus(); input.focus();
input.select(); input.select();

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React from "react"; import React from "react";
import i18n from "../../i18n"; import i18n from "../../i18n";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React from "react"; import React from "react";
import i18n from "../../i18n"; import i18n from "../../i18n";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import ModalConfirm from "./ModalConfirm"; import ModalConfirm from "./ModalConfirm";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons"; import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap"; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { Collapse, Navbar, NavbarToggler, Nav, NavItem } from "reactstrap"; import { Collapse, Navbar, NavbarToggler, Nav, NavItem } from "reactstrap";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React from "react"; import React from "react";
import ReactFlagsSelect from "react-flags-select"; import ReactFlagsSelect from "react-flags-select";
import "react-flags-select/css/react-flags-select.css"; import "react-flags-select/css/react-flags-select.css";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React from "react"; import React from "react";
import logo from "./loader-pulse-2.gif"; import logo from "./loader-pulse-2.gif";
import "./style.css"; import "./style.css";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { Redirect, withRouter } from "react-router-dom"; import { Redirect, withRouter } from "react-router-dom";
import { import {
@ -116,7 +117,7 @@ const SortableCandidate = sortableElement(
<div key="modal-body"> <div key="modal-body">
{t("Are you sure to delete")}{" "} {t("Are you sure to delete")}{" "}
{candidate.label !== "" ? ( {candidate.label !== "" ? (
<b>"{candidate.label}"</b> <b>&quot;{candidate.label}&quot;</b>
) : ( ) : (
<span> <span>
{t("the row")} {sortIndex + 1} {t("the row")} {sortIndex + 1}
@ -228,7 +229,7 @@ class CreateElection extends Component {
editCandidateLabel = (event, index) => { editCandidateLabel = (event, index) => {
let candidates = this.state.candidates; let candidates = this.state.candidates;
candidates[index].label = event.currentTarget.value; candidates[index].label = event.currentTarget.value;
candidates.map((candidate, i) => { candidates.map((candidate) => {
return candidate.label; return candidate.label;
}); });
this.setState({ this.setState({
@ -337,7 +338,7 @@ class CreateElection extends Component {
electorEmails && electorEmails.length electorEmails && electorEmails.length
? `/link/${result.id}` ? `/link/${result.id}`
: `/links/${result.id}`; : `/links/${result.id}`;
this.setState(state => ({ this.setState(() => ({
redirectTo: nextPage, redirectTo: nextPage,
successCreate: true, successCreate: true,
waiting: false waiting: false
@ -832,4 +833,5 @@ class CreateElection extends Component {
); );
} }
} }
export default withTranslation()(withRouter(CreateElection)); export default withTranslation()(withRouter(CreateElection));

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { Col, Container, Row } from "reactstrap"; import { Col, Container, Row } from "reactstrap";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
@ -25,7 +26,7 @@ class CreateSuccess extends Component {
this.urlResultField = React.createRef(); this.urlResultField = React.createRef();
} }
handleClickOnCopyResult = event => { handleClickOnCopyResult = () => {
const input = this.urlResultField.current; const input = this.urlResultField.current;
input.focus(); input.focus();
input.select(); input.select();

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";
import { Container, Row, Col, Button, Input } from "reactstrap"; import { Container, Row, Col, Button, Input } from "reactstrap";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";
import { resolve } from "url"; import { resolve } from "url";
@ -40,7 +41,7 @@ class Result extends Component {
handleErrors = response => { handleErrors = response => {
if (!response.ok) { if (!response.ok) {
response.json().then(response => { response.json().then(response => {
this.setState(state => ({ this.setState(() => ({
errorMessage: errorMessage(response, this.props.t) errorMessage: errorMessage(response, this.props.t)
})); }));
}); });
@ -56,7 +57,7 @@ class Result extends Component {
profile: c.profile, profile: c.profile,
grade: c.grade grade: c.grade
})); }));
this.setState(state => ({ candidates: candidates })); this.setState(() => ({ candidates: candidates }));
return response; return response;
}; };
@ -71,7 +72,7 @@ class Result extends Component {
const colSizeGradeXs = Math.floor( const colSizeGradeXs = Math.floor(
(12 - this.state.colSizeCandidateXs) / numGrades (12 - this.state.colSizeCandidateXs) / numGrades
); );
this.setState(state => ({ this.setState(() => ({
title: response.title, title: response.title,
numGrades: numGrades, numGrades: numGrades,
colSizeGradeLg: colSizeGradeLg, colSizeGradeLg: colSizeGradeLg,

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { Col, Container, Row } from "reactstrap"; import { Col, Container, Row } from "reactstrap";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { Col, Container, Row } from "reactstrap"; import { Col, Container, Row } from "reactstrap";
import logoLine from "../../logos/logo-line-white.svg"; import logoLine from "../../logos/logo-line-white.svg";
@ -21,13 +22,13 @@ class UnknownView extends Component {
</Row> </Row>
<Row className="mt-4"> <Row className="mt-4">
<Col className="text-center"> <Col className="text-center">
<h2>Oups ! Cette page n'existe pas</h2> <h2>Ooops ! this page doesn&#39;t exist !</h2>
</Col> </Col>
</Row> </Row>
<Row className="mt-4"> <Row className="mt-4">
<Col className="text-center"> <Col className="text-center">
<Link to="/" className="btn btn-secondary"> <Link to="/" className="btn btn-secondary">
Revenir à l'accueil Go back to homepage
</Link> </Link>
</Col> </Col>
</Row> </Row>

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { Redirect } from "react-router-dom"; import { Redirect } from "react-router-dom";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";
@ -38,7 +39,7 @@ class Vote extends Component {
response.json().then(response => { response.json().then(response => {
console.log(response); console.log(response);
const { t } = this.props; const { t } = this.props;
this.setState(state => ({ this.setState(() => ({
errorMsg: errorMessage(response, t) errorMsg: errorMessage(response, t)
})); }));
}); });
@ -65,7 +66,7 @@ class Vote extends Component {
(12 - this.state.colSizeCandidateXs) / numGrades (12 - this.state.colSizeCandidateXs) / numGrades
); );
this.setState(state => ({ this.setState(() => ({
title: response.title, title: response.title,
candidates: candidates, candidates: candidates,
numGrades: numGrades, numGrades: numGrades,
@ -159,7 +160,7 @@ class Vote extends Component {
body: JSON.stringify(payload) body: JSON.stringify(payload)
}) })
.then(this.handleErrors) .then(this.handleErrors)
.then(result => .then(() =>
this.setState({ redirectTo: "/vote-success/" + electionSlug }) this.setState({ redirectTo: "/vote-success/" + electionSlug })
) )
.catch(error => error); .catch(error => error);

@ -1,3 +1,4 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react"; import React, { Component } from "react";
import { Col, Container, Row } from "reactstrap"; import { Col, Container, Row } from "reactstrap";
import { withTranslation } from "react-i18next"; import { withTranslation } from "react-i18next";

@ -1,4 +1,4 @@
import React from "react"; /* eslint react/prop-types: 0 */
export const UNKNOWN_ELECTION_ERROR = "E1"; export const UNKNOWN_ELECTION_ERROR = "E1";
export const ONGOING_ELECTION_ERROR = "E2"; export const ONGOING_ELECTION_ERROR = "E2";
@ -10,7 +10,7 @@ export const UNKNOWN_TOKEN_ERROR = "E7";
export const USED_TOKEN_ERROR = "E8"; export const USED_TOKEN_ERROR = "E8";
export const WRONG_ELECTION_ERROR = "E9"; export const WRONG_ELECTION_ERROR = "E9";
export const redirectError = (errorMsg, history) => {}; export const redirectError = () => {};
export const errorMessage = (error, t) => { export const errorMessage = (error, t) => {
if (error.startsWith(UNKNOWN_ELECTION_ERROR)) { if (error.startsWith(UNKNOWN_ELECTION_ERROR)) {

@ -21,8 +21,10 @@ const isLocalhost = Boolean(
); );
export function register(config) { export function register(config) {
// eslint-disable-next-line no-undef
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
// The URL constructor is available in all browsers that support SW. // The URL constructor is available in all browsers that support SW.
// eslint-disable-next-line no-undef
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) { if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin // Our service worker won't work if PUBLIC_URL is on a different origin
@ -32,6 +34,7 @@ export function register(config) {
} }
window.addEventListener("load", () => { window.addEventListener("load", () => {
// eslint-disable-next-line no-undef
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) { if (isLocalhost) {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save