From 8f8234cbd10f184304e6345a12b3cbad03512226 Mon Sep 17 00:00:00 2001
From: Florent Chehab
Date: Tue, 23 Apr 2019 20:52:13 +0200
Subject: [PATCH] linting(front): activated react/jsx-indent-props
* Activated react/jsx-indent-props
* Reformatted code accordingly
Not that many changes were required actualy :)
Fixes #102
---
frontend/.eslintrc.js | 2 +-
.../src/components/form/renderFieldsMixIn.js | 63 ++++++++++---------
.../recommendation/Recommendation.js | 29 ++++-----
.../editors/UniversityGeneralEditor.js | 37 ++++++-----
4 files changed, 65 insertions(+), 66 deletions(-)
diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js
index 973615c1..980d1d95 100644
--- a/frontend/.eslintrc.js
+++ b/frontend/.eslintrc.js
@@ -42,7 +42,7 @@ module.exports = {
"always"
],
"react/no-unescaped-entities": "off", // that one doesn't improve code readability
- // "react/jsx-indent-props": [2, "first"],
+ "react/jsx-indent-props": [2, "first"],
"react/jsx-indent": [2, 2],
"react/prop-types": "error",
"react/no-deprecated": "error",
diff --git a/frontend/src/components/form/renderFieldsMixIn.js b/frontend/src/components/form/renderFieldsMixIn.js
index 5a697c67..e3b7b6ad 100644
--- a/frontend/src/components/form/renderFieldsMixIn.js
+++ b/frontend/src/components/form/renderFieldsMixIn.js
@@ -17,7 +17,7 @@ import TextField from "./fields/TextField";
import MultiSelectField from "./fields/MultiSelectField";
import NumberField from "./fields/NumberField";
-import { getLatestReadDataFromStore } from "../../redux/api/utils";
+import {getLatestReadDataFromStore} from "../../redux/api/utils";
export default {
/**
@@ -27,7 +27,7 @@ export default {
* @returns
*/
customizeProps(props) {
- return Object.assign(props, { ...this.getReferenceAndValue(props.fieldMapping) });
+ return Object.assign(props, {...this.getReferenceAndValue(props.fieldMapping)});
},
renderObjModerationLevelField() {
@@ -39,34 +39,34 @@ export default {
<>
Niveau de modération supplémentaire souhaité
+ {...this.getReferenceAndValue("obj_moderation_level")}
+ required={true}
+ options={possibleObjModeration} />
>
);
} else {
return (
- Votre statut ne vous permet pas modifier le niveau local de modération pour ce module.
+
+ Votre statut ne vous permet pas modifier le niveau local de modération pour ce module.
+
);
}
},
renderImportanceLevelField() {
const options = [
- { "label": "Normal", "value": "-" },
- { "label": "Important", "value": "+" },
- { "label": "Très important", "value": "++" },
+ {"label": "Normal", "value": "-"},
+ {"label": "Important", "value": "+"},
+ {"label": "Très important", "value": "++"},
];
return (
<>
Qualification de l'importance de l'information présentée
+ {...this.getReferenceAndValue("importance_level")}
+ required={true}
+ options={options} />
>
);
},
@@ -74,8 +74,7 @@ export default {
renderUsefulLinksField() {
return (
+ {...this.getReferenceAndValue("useful_links")} />
);
},
@@ -113,32 +112,34 @@ export default {
},
renderUniversitiesField() {
- const { outsideData } = this.props,
+ const {outsideData} = this.props,
universities = outsideData.universities.map(
- (univ) => { return { label: univ.name, value: univ.id, disabled: false }; }
+ (univ) => {
+ return {label: univ.name, value: univ.id, disabled: false};
+ }
);
return (
+ {...this.getReferenceAndValue("universities")}
+ required={true}
+ options={universities} />
);
},
renderCountriesField() {
- const { outsideData } = this.props,
+ const {outsideData} = this.props,
countries = outsideData.countries.map(
- (country) => { return { label: country.name, value: country.id, disabled: false }; }
+ (country) => {
+ return {label: country.name, value: country.id, disabled: false};
+ }
);
return (
+ {...this.getReferenceAndValue("countries")}
+ required={true}
+ options={countries} />
);
},
@@ -151,9 +152,11 @@ export default {
},
renderCurrencyField(props) {
- const { outsideData } = this.props;
+ const {outsideData} = this.props;
const currencies = outsideData.currencies.map(
- (c) => { return { label: c.code, value: c.code, disabled: false }; }
+ (c) => {
+ return {label: c.code, value: c.code, disabled: false};
+ }
);
return this.renderSelectField({
diff --git a/frontend/src/components/recommendation/Recommendation.js b/frontend/src/components/recommendation/Recommendation.js
index 0484af38..59129f3f 100644
--- a/frontend/src/components/recommendation/Recommendation.js
+++ b/frontend/src/components/recommendation/Recommendation.js
@@ -2,17 +2,16 @@ import React from "react";
import PropTypes from "prop-types";
import withStyles from "@material-ui/core/styles/withStyles";
-import { Paper } from "@material-ui/core";
+import {Paper} from "@material-ui/core";
import Button from "@material-ui/core/Button";
import AddIcon from "@material-ui/icons/Add";
-// import {compose} from "redux";
-// import getActions from "../../redux/api/getActions";
-// import {connect} from "react-redux";
-
import TextBlock from "../recommendation/TextBlock";
import UnivBlock from "../recommendation/UnivBlock";
import RecommendationEditor from "../recommendation/RecommendationEditor";
import CustomComponentForAPI from "../common/CustomComponentForAPI";
+// import {compose} from "redux";
+// import getActions from "../../redux/api/getActions";
+// import {connect} from "react-redux";
// import editorStyle from "../university/editors/common/editorStyle.js";
@@ -69,7 +68,7 @@ class Recommendation extends CustomComponentForAPI {
recommendationModelData = list;
return (
-
+
{list.name}
@@ -77,17 +76,17 @@ class Recommendation extends CustomComponentForAPI {
{list.public ? "Liste publique" : "liste privée"} créée par : {list.user}
-
+
- {list.content.map((el, idx) =>
)}
+ {list.content.map((el, idx) =>
)}
this.closeEditorPanel()}
- rawModelData={recommendationModelData}/>
+ closeEditorPanel={() => this.closeEditorPanel()}
+ rawModelData={recommendationModelData}/>
);
}
@@ -98,9 +97,7 @@ Recommendation.propTypes = {
list: PropTypes.object.isRequired,
};
-Recommendation.defaultProps = {
-
-};
+Recommendation.defaultProps = {};
const styles = theme => ({
root: {
@@ -119,4 +116,4 @@ const styles = theme => ({
},
});
-export default withStyles(styles, { withTheme: true })(Recommendation);
+export default withStyles(styles, {withTheme: true})(Recommendation);
diff --git a/frontend/src/components/university/editors/UniversityGeneralEditor.js b/frontend/src/components/university/editors/UniversityGeneralEditor.js
index 05c98586..31dfb491 100644
--- a/frontend/src/components/university/editors/UniversityGeneralEditor.js
+++ b/frontend/src/components/university/editors/UniversityGeneralEditor.js
@@ -1,7 +1,7 @@
import React from "react";
import withStyles from "@material-ui/core/styles/withStyles";
import compose from "recompose/compose";
-import { connect } from "react-redux";
+import {connect} from "react-redux";
import Editor from "../../editor/Editor";
import Form from "../../form/Form";
@@ -9,7 +9,7 @@ import editorStyle from "../../editor/editorStyle";
import getMapStateToPropsForEditor from "../../editor/getMapStateToPropsForEditor";
import getMapDispatchToPropsForEditor from "../../editor/getMapDispatchToPropsForEditor";
-import { withSnackbar } from "notistack";
+import {withSnackbar} from "notistack";
import TextField from "../../form/fields/TextField";
@@ -23,25 +23,24 @@ class UniversityGeneralForm extends Form {
return (
<>
+ {...this.getReferenceAndValue("name")}
+ required={true}
+ maxLength={200}/>
+
+ {...this.getReferenceAndValue("acronym")}
+ maxLength={20}/>
+
+ {...this.getReferenceAndValue("website")}
+ maxLength={300}
+ isUrl={true}/>
+
+ {...this.getReferenceAndValue("logo")}
+ maxLength={300}
+ isUrl={true}
+ urlExtensions={["jpg", "png", "svg"]}/>
>
);
}
@@ -60,7 +59,7 @@ class UniversityGeneralEditor extends Editor {
export default compose(
withSnackbar,
- withStyles(styles, { withTheme: true }),
+ withStyles(styles, {withTheme: true}),
connect(
getMapStateToPropsForEditor("universities"),
getMapDispatchToPropsForEditor("universities")
--
2.22.0