Browse Source

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

pull/73/head
Clement G 3 years ago
parent
commit
8ef1d13f22
  1. 6
      .eslintrc.json
  2. 23
      package.json
  3. 2
      src/AppContext.jsx
  4. 3
      src/Errors.js
  5. 3
      src/components/CopyField.jsx
  6. 1
      src/components/banner/Helloasso.jsx
  7. 1
      src/components/banner/Paypal.jsx
  8. 1
      src/components/form/ButtonWithConfirm.jsx
  9. 1
      src/components/form/HelpButton.jsx
  10. 1
      src/components/form/ModalConfirm.jsx
  11. 1
      src/components/layouts/Footer.jsx
  12. 1
      src/components/layouts/Header.jsx
  13. 1
      src/components/layouts/LanguageSelector.jsx
  14. 1
      src/components/loader/index.jsx
  15. 8
      src/components/views/CreateElection.jsx
  16. 3
      src/components/views/CreateSuccess.jsx
  17. 1
      src/components/views/Home.jsx
  18. 7
      src/components/views/Result.jsx
  19. 1
      src/components/views/UnknownElection.jsx
  20. 5
      src/components/views/UnknownView.jsx
  21. 7
      src/components/views/Vote.jsx
  22. 1
      src/components/views/VoteSuccess.jsx
  23. 4
      src/errorCode.js
  24. 3
      src/serviceWorker.jsx
  25. 758
      yarn.lock

6
.eslintrc.json

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

23
package.json

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

2
src/AppContext.jsx

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

3
src/Errors.js

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

3
src/components/CopyField.jsx

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

1
src/components/banner/Helloasso.jsx

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

1
src/components/banner/Paypal.jsx

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

1
src/components/form/ButtonWithConfirm.jsx

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

1
src/components/form/HelpButton.jsx

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

1
src/components/form/ModalConfirm.jsx

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

1
src/components/layouts/Footer.jsx

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

1
src/components/layouts/Header.jsx

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

1
src/components/layouts/LanguageSelector.jsx

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

1
src/components/loader/index.jsx

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

8
src/components/views/CreateElection.jsx

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

3
src/components/views/CreateSuccess.jsx

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

1
src/components/views/Home.jsx

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

7
src/components/views/Result.jsx

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

1
src/components/views/UnknownElection.jsx

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

5
src/components/views/UnknownView.jsx

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

7
src/components/views/Vote.jsx

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

1
src/components/views/VoteSuccess.jsx

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

4
src/errorCode.js

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

3
src/serviceWorker.jsx

@ -21,8 +21,10 @@ const isLocalhost = Boolean(
);
export function register(config) {
// eslint-disable-next-line no-undef
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
// 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);
if (publicUrl.origin !== window.location.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", () => {
// eslint-disable-next-line no-undef
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {

758
yarn.lock
File diff suppressed because it is too large
View File

Loading…
Cancel
Save