Added eslint

This commit is contained in:
MaxOvs19 2023-05-31 11:24:46 +03:00
parent fc8fc33733
commit 9e242ddf5d
40 changed files with 224 additions and 536 deletions

21
.eslintrc.json Normal file
View File

@ -0,0 +1,21 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:react/recommended"],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["react"],
"rules": {
"no-console": "warn",
"react/prop-types": 0,
"no-undef": "warn",
"react/no-unescaped-entities": 0,
"no-extra-boolean-cast": "warn",
"react/react-in-jsx-scope": 0
}
}

606
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,8 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"css-loader": "6.7.3", "css-loader": "6.7.3",
"dotenv-webpack": "^7.0.3", "dotenv-webpack": "^7.0.3",
"eslint": "^8.41.0",
"eslint-plugin-react": "^7.32.2",
"html-webpack-plugin": "5.5.0", "html-webpack-plugin": "5.5.0",
"mini-css-extract-plugin": "^2.7.2", "mini-css-extract-plugin": "^2.7.2",
"node-sass": "8.0.0", "node-sass": "8.0.0",
@ -78,7 +80,8 @@
"build": "cross-env SERVE=true webpack -c config/webpack/prod.js", "build": "cross-env SERVE=true webpack -c config/webpack/prod.js",
"start": "webpack serve -c config/webpack/dev.js", "start": "webpack serve -c config/webpack/dev.js",
"analyze": "webpack --analyze -c config/webpack/analyze.js", "analyze": "webpack --analyze -c config/webpack/analyze.js",
"format": "prettier --write \"./**/*.{js,jsx}\"" "format": "prettier --write \"./**/*.{js,jsx}\"",
"lint": "npx eslint 'src/**/*.{js,jsx,ts,tsx}'"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [

View File

@ -7,7 +7,7 @@ import userIcon from "assets/icons/userIcon.svg";
import "./authHeader.scss"; import "./authHeader.scss";
export const AuthHeader = ({}) => { export const AuthHeader = () => {
return ( return (
<div className="auth-header"> <div className="auth-header">
<div className="auth-header__logo"> <div className="auth-header__logo">

View File

@ -13,7 +13,7 @@ import rectangle from "assets/images/rectangle_secondPage.png";
import ErrorBoundary from "../../hoc/ErrorBoundary"; import ErrorBoundary from "../../hoc/ErrorBoundary";
import "./description.scss"; import "./description.scss";
const Description = ({ onLoadMore, isLoadingMore }) => { const Description = ({ onLoadMore }) => {
const candidatesListArr = useSelector(selectProfiles); const candidatesListArr = useSelector(selectProfiles);
return ( return (

View File

@ -29,8 +29,10 @@ const Form = () => {
const handleModal = (status) => { const handleModal = (status) => {
SweetAlert.fire({ SweetAlert.fire({
text: text:
// eslint-disable-next-line no-constant-condition
status !== 200 || 201 ? "Какие-то неполадки =(" : "Форма отправлена", status !== 200 || 201 ? "Какие-то неполадки =(" : "Форма отправлена",
preConfirm: () => preConfirm: () =>
// eslint-disable-next-line no-constant-condition
status !== 200 || 201 status !== 200 || 201
? () => { ? () => {
setStatus(null); setStatus(null);

View File

@ -14,7 +14,7 @@ import mockWorker from "assets/images/mock/mokPerson.png";
import "./freeDevelopers.scss"; import "./freeDevelopers.scss";
export const FreeDevelopers = ({}) => { export const FreeDevelopers = () => {
return ( return (
<section className="free-dev"> <section className="free-dev">
<AuthHeader /> <AuthHeader />

View File

@ -60,7 +60,7 @@ export const ModalTiсket = ({
task_id: task.id, task_id: task.id,
status: 0, status: 0,
}, },
}).then((res) => { }).then(() => {
setActive(false); setActive(false);
dispatch(setProjectBoardFetch(projectId)); dispatch(setProjectBoardFetch(projectId));
}); });
@ -74,7 +74,7 @@ export const ModalTiсket = ({
title: inputsValue.title, title: inputsValue.title,
description: inputsValue.description, description: inputsValue.description,
}, },
}).then((res) => { }).then(() => {
dispatch(setProjectBoardFetch(projectId)); dispatch(setProjectBoardFetch(projectId));
}); });
} }
@ -106,7 +106,7 @@ export const ModalTiсket = ({
comment_id: commentId, comment_id: commentId,
status: 0, status: 0,
}, },
}).then((res) => { }).then(() => {
setComments((prevValue) => setComments((prevValue) =>
prevValue.filter((item) => item.id !== commentId) prevValue.filter((item) => item.id !== commentId)
); );
@ -120,7 +120,7 @@ export const ModalTiсket = ({
comment_id: commentId, comment_id: commentId,
text: commentsEditText[commentId], text: commentsEditText[commentId],
}, },
}).then((res) => {}); }).then(() => {});
} }
function taskExecutor(person) { function taskExecutor(person) {
@ -143,7 +143,7 @@ export const ModalTiсket = ({
task_id: task.id, task_id: task.id,
executor_id: 0, executor_id: 0,
}, },
}).then((res) => { }).then(() => {
setExecutor(null); setExecutor(null);
}); });
} }
@ -168,7 +168,7 @@ export const ModalTiсket = ({
task_id: task.id, task_id: task.id,
user_id: person.user_id, user_id: person.user_id,
}, },
}).then((res) => { }).then(() => {
setMembers(members.filter((item) => item.user_id !== person.user_id)); setMembers(members.filter((item) => item.user_id !== person.user_id));
}); });
} }

View File

@ -42,7 +42,7 @@ import watch from "assets/icons/watch.svg";
import "./ticketFullScreen.scss"; import "./ticketFullScreen.scss";
export const TicketFullScreen = ({}) => { export const TicketFullScreen = () => {
const [modalAddWorker, setModalAddWorker] = useState(false); const [modalAddWorker, setModalAddWorker] = useState(false);
const ticketId = useParams(); const ticketId = useParams();
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -93,7 +93,7 @@ export const TicketFullScreen = ({}) => {
task_id: ticketId.id, task_id: ticketId.id,
status: 0, status: 0,
}, },
}).then((res) => { }).then(() => {
navigate(`/tracker/project/${taskInfo.project_id}`); navigate(`/tracker/project/${taskInfo.project_id}`);
}); });
} }
@ -106,7 +106,7 @@ export const TicketFullScreen = ({}) => {
title: inputsValue.title, title: inputsValue.title,
description: inputsValue.description, description: inputsValue.description,
}, },
}).then((res) => {}); }).then(() => {});
} }
function createComment() { function createComment() {
@ -137,7 +137,7 @@ export const TicketFullScreen = ({}) => {
comment_id: commentId, comment_id: commentId,
status: 0, status: 0,
}, },
}).then((res) => { }).then(() => {
setComments((prevValue) => setComments((prevValue) =>
prevValue.filter((item) => item.id !== commentId) prevValue.filter((item) => item.id !== commentId)
); );
@ -151,7 +151,7 @@ export const TicketFullScreen = ({}) => {
comment_id: commentId, comment_id: commentId,
text: commentsEditText[commentId], text: commentsEditText[commentId],
}, },
}).then((res) => {}); }).then(() => {});
} }
function deletePerson(userId) { function deletePerson(userId) {
@ -161,7 +161,7 @@ export const TicketFullScreen = ({}) => {
project_id: projectBoard.id, project_id: projectBoard.id,
user_id: userId, user_id: userId,
}, },
}).then((res) => { }).then(() => {
dispatch(deletePersonOnProject(userId)); dispatch(deletePersonOnProject(userId));
}); });
} }

View File

@ -57,7 +57,7 @@ export const TrackerModal = ({
project_id: projectBoard.id, project_id: projectBoard.id,
title: valueColumn, title: valueColumn,
}, },
}).then((res) => { }).then(() => {
dispatch(setProjectBoardFetch(projectBoard.id)); dispatch(setProjectBoardFetch(projectBoard.id));
}); });
setValueColumn(""); setValueColumn("");
@ -80,7 +80,7 @@ export const TrackerModal = ({
column_id: selectedTab, column_id: selectedTab,
priority: priorityTask, priority: priorityTask,
}, },
}).then((res) => { }).then(() => {
dispatch(setProjectBoardFetch(projectBoard.id)); dispatch(setProjectBoardFetch(projectBoard.id));
}); });
@ -96,7 +96,7 @@ export const TrackerModal = ({
project_id: projectId, project_id: projectId,
name: projectName, name: projectName,
}, },
}).then((res) => { }).then(() => {
setActive(false); setActive(false);
dispatch(editProjectName({ id: projectId, name: projectName })); dispatch(editProjectName({ id: projectId, name: projectName }));
}); });
@ -109,7 +109,7 @@ export const TrackerModal = ({
column_id: columnId, column_id: columnId,
title: columnName, title: columnName,
}, },
}).then((res) => { }).then(() => {
setActive(false); setActive(false);
dispatch(editColumnName({ id: columnId, title: columnName })); dispatch(editColumnName({ id: columnId, title: columnName }));
}); });

View File

@ -23,6 +23,7 @@ import arrow from "assets/icons/arrows/arrowCalendar.png";
import calendarIcon from "assets/icons/calendar.svg"; import calendarIcon from "assets/icons/calendar.svg";
import rectangle from "assets/images/rectangle__calendar.png"; import rectangle from "assets/images/rectangle__calendar.png";
// eslint-disable-next-line react/display-name
export const ProfileCalendarComponent = React.memo( export const ProfileCalendarComponent = React.memo(
({ value, setValueHandler, reports, totalHours }) => { ({ value, setValueHandler, reports, totalHours }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();

View File

@ -47,7 +47,7 @@ export const ProjectTiket = ({ project, index }) => {
project_id: project.id, project_id: project.id,
status: 10, status: 10,
}, },
}).then((res) => { }).then(() => {
dispatch(deleteProject(project)); dispatch(deleteProject(project));
}); });
} }

View File

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { Redirect, Route } from "react-router-dom"; import { Route } from "react-router-dom";
import { selectAuth } from "@redux/outstaffingSlice"; import { selectAuth } from "@redux/outstaffingSlice";
@ -9,6 +9,7 @@ export const ProtectedRoute = ({ component: Component, ...rest }) => {
const existingToken = localStorage.getItem("auth_token"); const existingToken = localStorage.getItem("auth_token");
const expiresAt = localStorage.getItem("access_token_expired_at"); const expiresAt = localStorage.getItem("access_token_expired_at");
// eslint-disable-next-line no-unused-vars
const isTokenAlive = const isTokenAlive =
!isAuth && !isAuth &&
existingToken && existingToken &&

View File

@ -103,7 +103,7 @@ const ReportForm = () => {
created_at: getCreatedDate(startDate), created_at: getCreatedDate(startDate),
status: 1, status: 1,
}, },
}).then((res) => { }).then(() => {
setReportSuccess("Отчет отправлен"); setReportSuccess("Отчет отправлен");
setTimeout(() => { setTimeout(() => {
setReportSuccess(""); setReportSuccess("");

View File

@ -19,7 +19,7 @@ import { Loader } from "@components/Common/Loader/Loader";
import "./shortReport.scss"; import "./shortReport.scss";
export const ShortReport = ({}) => { export const ShortReport = () => {
const reportDate = useSelector(getReportDate); const reportDate = useSelector(getReportDate);
const sendReport = useSelector(getSendRequest); const sendReport = useSelector(getSendRequest);

View File

@ -1,12 +1,6 @@
import React from "react"; import React from "react";
import { useSelector } from "react-redux";
import { selectedTest } from "@redux/quizSlice";
export const GetOptionTask = ({ type, answer, handleChange, inputValue }) => { export const GetOptionTask = ({ type, answer, handleChange, inputValue }) => {
const id = localStorage.getItem("id");
const dataTest = useSelector(selectedTest);
switch (type) { switch (type) {
case "1": case "1":
return ( return (

View File

@ -5,8 +5,7 @@ import { selectUserInfo, setUserInfo } from "@redux/quizSlice";
import { urlForLocal } from "@utils/helper"; import { urlForLocal } from "@utils/helper";
import { apiRequest } from "@api/request"; // import { apiRequest } from "@api/request";
import "./quiz.scss"; import "./quiz.scss";
export const HeaderQuiz = ({ header }) => { export const HeaderQuiz = ({ header }) => {

View File

@ -10,14 +10,13 @@ import accempt from "assets/images/quiz/accempt.png";
import timer from "assets/images/quiz/timer.png"; import timer from "assets/images/quiz/timer.png";
export const QuizPassingInformation = ({ expiryTimestamp, setStartTest }) => { export const QuizPassingInformation = ({ expiryTimestamp, setStartTest }) => {
const { seconds, minutes, isRunning, start, pause, resume, restart } = const { seconds, minutes, isRunning, start, restart } = useTimer({
useTimer({ expiryTimestamp,
expiryTimestamp, autoStart: false,
autoStart: false, onExpire: () => {
onExpire: () => { console.warn("onExpire called");
console.warn("onExpire called"); },
}, });
});
const completedTest = useSelector(completedTestSelector); const completedTest = useSelector(completedTestSelector);
const startTesting = () => { const startTesting = () => {

View File

@ -1,15 +1,12 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { import {
answersSelector, answersSelector,
fetchGetAnswers, fetchGetAnswers, // fetchUserAnswerOne,
fetchUserAnswerOne, // fetchUserAnswersMany,
fetchUserAnswersMany,
questionsSelector, questionsSelector,
selectedTest, selectedTest, // setAnswers,
setAnswers,
setCompleteTest, setCompleteTest,
} from "@redux/quizSlice"; } from "@redux/quizSlice";
@ -18,12 +15,11 @@ import { apiRequest } from "@api/request";
import questionIcon from "assets/images/question.png"; import questionIcon from "assets/images/question.png";
import { GetOptionTask } from "./GetOptionTask"; import { GetOptionTask } from "./GetOptionTask";
import { HeaderQuiz } from "./HeaderQuiz"; // import { HeaderQuiz } from "./HeaderQuiz";
import { Progressbar } from "./ProgressbarQuiz"; // import { Progressbar } from "./ProgressbarQuiz";
import "./quiz.scss"; import "./quiz.scss";
export const TaskQuiz = () => { export const TaskQuiz = () => {
const navigate = useNavigate();
const dispatch = useDispatch(); const dispatch = useDispatch();
const answers = useSelector(answersSelector); const answers = useSelector(answersSelector);
@ -42,7 +38,6 @@ export const TaskQuiz = () => {
// .then(json => console.log(json)) // .then(json => console.log(json))
apiRequest(`/question/get-questions?uuid=${dataTest.uuid}`).then( apiRequest(`/question/get-questions?uuid=${dataTest.uuid}`).then(
(response) => { (response) => {
console.log(response);
dispatch(fetchGetAnswers(response[0].id)); dispatch(fetchGetAnswers(response[0].id));
setStripValue(((+index + 1) * 100) / response.length); setStripValue(((+index + 1) * 100) / response.length);
} }

View File

@ -17,7 +17,7 @@ import mockImgArticle from "assets/images/mock/mockImgArticle.png";
import "./article.scss"; import "./article.scss";
export const Article = ({}) => { export const Article = () => {
const [article] = useState([ const [article] = useState([
{ {
image: cardImg1, image: cardImg1,

View File

@ -16,7 +16,7 @@ import cardImg1 from "assets/images/mock/cardArticleItem.png";
import "./blog.scss"; import "./blog.scss";
export const Blog = ({}) => { export const Blog = () => {
const [article] = useState([ const [article] = useState([
{ {
image: cardImg1, image: cardImg1,

View File

@ -13,7 +13,7 @@ import "./FrequentlyAskedQuestion.scss";
export const FrequentlyAskedQuestion = () => { export const FrequentlyAskedQuestion = () => {
const params = useParams(); const params = useParams();
const navigate = useNavigate(); const navigate = useNavigate();
const [question, setQuestion] = useState({ const [question] = useState({
id: params.id, id: params.id,
title: "Это фриланс-платформа?", title: "Это фриланс-платформа?",
answer: answer:

View File

@ -117,7 +117,7 @@ export const PartnerAddRequest = () => {
return skill.id; return skill.id;
}), }),
}, },
}).then((res) => { }).then(() => {
navigate("/profile/requests"); navigate("/profile/requests");
}); });
} else { } else {
@ -135,7 +135,7 @@ export const PartnerAddRequest = () => {
return skill.id; return skill.id;
}), }),
}, },
}).then((res) => { }).then(() => {
navigate("/profile/requests"); navigate("/profile/requests");
}); });
} }
@ -206,7 +206,7 @@ export const PartnerAddRequest = () => {
{openSpecializationList && {openSpecializationList &&
Boolean(specializationList.length) && ( Boolean(specializationList.length) && (
<div className="form__block__dropDown"> <div className="form__block__dropDown">
{specializationList.map((specialization, index) => { {specializationList.map((specialization) => {
return ( return (
<p <p
key={specialization.id} key={specialization.id}

View File

@ -59,7 +59,7 @@ export const PartnerBid = () => {
request_id: requestId, request_id: requestId,
status: 0, status: 0,
}, },
}).then((res) => { }).then(() => {
navigate("/profile/requests"); navigate("/profile/requests");
}); });
}; };

View File

@ -152,7 +152,7 @@ export const ProjectTracker = () => {
project_id: projectBoard.id, project_id: projectBoard.id,
status: 0, status: 0,
}, },
}).then((res) => { }).then(() => {
dispatch(setProjectBoardFetch(projectBoard.id)); dispatch(setProjectBoardFetch(projectBoard.id));
}); });
} }
@ -164,7 +164,7 @@ export const ProjectTracker = () => {
project_id: projectBoard.id, project_id: projectBoard.id,
user_id: userId, user_id: userId,
}, },
}).then((res) => { }).then(() => {
dispatch(deletePersonOnProject(userId)); dispatch(deletePersonOnProject(userId));
}); });
} }
@ -338,7 +338,7 @@ export const ProjectTracker = () => {
<div <div
key={column.id} key={column.id}
onDragOver={(e) => dragOverHandler(e)} onDragOver={(e) => dragOverHandler(e)}
onDragEnter={(e) => dragEnterHandler(column.id)} onDragEnter={() => dragEnterHandler(column.id)}
onDrop={(e) => dragDropHandler(e, column.id)} onDrop={(e) => dragDropHandler(e, column.id)}
className={`tasks__board ${ className={`tasks__board ${
column.tasks.length >= 3 ? "tasks__board__more" : "" column.tasks.length >= 3 ? "tasks__board__more" : ""
@ -398,7 +398,7 @@ export const ProjectTracker = () => {
</div> </div>
</div> </div>
)} )}
{column.tasks.map((task, index) => { {column.tasks.map((task) => {
// if (index > 2) { // if (index > 2) {
// if (!column.open) { // if (!column.open) {
// return; // return;
@ -454,7 +454,7 @@ export const ProjectTracker = () => {
); );
})} })}
{Boolean(projectBoard?.columns) && {Boolean(projectBoard?.columns) &&
!Boolean(projectBoard.columns.length) && ( !projectBoard.columns.length && (
<div className="tasks__board__noItems"> <div className="tasks__board__noItems">
В проекте нет задач. В проекте нет задач.
</div> </div>

View File

@ -66,9 +66,9 @@ const SingleReportPage = () => {
<div className="single-report-page__marker"></div> <div className="single-report-page__marker"></div>
<h3>Какие задачи были выполнены?</h3> <h3>Какие задачи были выполнены?</h3>
</div> </div>
{tasks.map((task) => { {tasks.map((task, index) => {
return ( return (
<div className="single-report-page__tasks-item"> <div className="single-report-page__tasks-item" key={index}>
<TaskItem {...task} /> <TaskItem {...task} />
</div> </div>
); );

View File

@ -2,7 +2,7 @@ import React, { useState } from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { completedTestSelector, selectedTest } from "@redux/quizSlice"; import { completedTestSelector } from "@redux/quizSlice";
import { Footer } from "@components/Common/Footer/Footer"; import { Footer } from "@components/Common/Footer/Footer";
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
@ -14,11 +14,6 @@ import { QuizPassingInformation } from "@components/features/quiz/Quiz-passing-i
import { TaskQuiz } from "@components/features/quiz/Task"; import { TaskQuiz } from "@components/features/quiz/Task";
export const PassingTests = () => { export const PassingTests = () => {
//const selectedTest = useSelector(selectedTest)
if ("") {
}
const time = new Date(); const time = new Date();
time.setSeconds(time.getSeconds() + 600); //600 - кол-во секунд для прохождения теста time.setSeconds(time.getSeconds() + 600); //600 - кол-во секунд для прохождения теста

View File

@ -57,7 +57,7 @@ export const projectsTrackerSlice = createSlice({
task_id: action.payload.startWrapperIndex.task.id, task_id: action.payload.startWrapperIndex.task.id,
column_id: column.id, column_id: column.id,
}, },
}).then((res) => {}); }).then(() => {});
} }
if (column.id === action.payload.startWrapperIndex.index) { if (column.id === action.payload.startWrapperIndex.index) {
state.projectBoard.columns[index].tasks = column.tasks.filter( state.projectBoard.columns[index].tasks = column.tasks.filter(

View File

@ -117,7 +117,7 @@ export const quizSlice = createSlice({
setSelectedTest: (state, action) => { setSelectedTest: (state, action) => {
state.selectedTest = action.payload; state.selectedTest = action.payload;
}, },
setCompleteTest: (state, action) => { setCompleteTest: (state) => {
state.completedTest = true; state.completedTest = true;
}, },
}, },