From 4f23b8a9ddc65b92e0e8cfc0e428695eeadd7497 Mon Sep 17 00:00:00 2001 From: Mayank Aggarwal Date: Sun, 20 Mar 2022 01:11:57 +0530 Subject: [PATCH 1/3] lint fix --- .eslintrc.json | 36 ++++ package.json | 8 +- src/components/Alert/Alert.component.jsx | 2 +- .../AuthForm/AuthForm.component.jsx | 2 +- src/components/Footer/Footer.component.jsx | 6 +- src/components/Header/Header.component.jsx | 18 +- .../LayoutWrapper/LayoutWrapper.component.jsx | 2 +- .../SideBarWidget/SideBarWidget.component.jsx | 2 +- .../SideBarWidget/SideBarWidgetData.js | 4 +- .../TagsWidget/TagsWidget.component.jsx | 2 +- .../TagsWidget/TagsWidgetItem.component.jsx | 4 +- .../SideBar/SideBar.component.jsx | 4 +- .../LayoutWrapper/SideBar/SideBarData.js | 1 + .../MobileSideBar/MobileSideBar.component.jsx | 178 +++++++++--------- .../Pagination/Pagination.component.jsx | 4 +- .../AllTagsPage/AllTagsPage.component.jsx | 2 +- .../AllUsersPage/AllUsersPage.component.jsx | 2 +- src/pages/HomePage/HomePage.component.jsx | 8 +- src/pages/Login/Login.component.jsx | 2 +- src/pages/NotFound/NotFound.component.jsx | 2 +- .../AnswerItem/AnswerItem.component.jsx | 18 +- .../CommentCell/CommentCell.component.jsx | 18 +- .../PostCell/PostCell.component.jsx | 20 +- src/pages/PostForm/PostForm.component.jsx | 2 +- .../ExternalUserDetails.component.jsx | 8 +- .../ProfilePage/ProfilePage.component.jsx | 8 +- .../UserActivity/UserActivity.component.jsx | 4 +- .../AvatarCard/AvatarCard.component.jsx | 4 +- .../ContentCard/ContentCard.component.jsx | 4 +- .../UserSection/UserSection.component.jsx | 6 +- .../QuestionsPage/QuestionsPage.component.jsx | 2 +- src/pages/Register/Register.component.jsx | 2 +- src/redux/alert/alert.reducer.js | 12 +- src/redux/answers/answers.actions.js | 2 +- src/redux/answers/answers.reducer.js | 52 ++--- src/redux/auth/auth.actions.js | 6 +- src/redux/auth/auth.reducer.js | 58 +++--- src/redux/comments/comments.actions.js | 2 +- src/redux/comments/comments.reducer.js | 56 +++--- src/redux/posts/posts.actions.js | 2 +- src/redux/posts/posts.reducer.js | 68 +++---- src/redux/tags/tags.actions.js | 2 +- src/redux/tags/tags.reducer.js | 46 ++--- src/redux/users/users.actions.js | 2 +- src/redux/users/users.reducer.js | 42 ++--- src/services/handleSorting.js | 52 ++--- src/services/htmlSubstring.js | 58 +++--- src/services/injectEllipsis.js | 16 +- yarn.lock | 160 ++++++---------- 49 files changed, 513 insertions(+), 508 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..f5a3873 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended" + ], + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": [ + "react" + ], + "rules": { + "react/display-name": "off", + "react/prop-types": "off", + "indent": ["error", 2], + "no-unused-vars": 1, + "no-multi-assign": 0, + "no-return-await": 0, + "no-undef": 0, + "linebreak-style": 0, + "no-console": 0, + "consistent-return": 0, + "no-param-reassign": 0, + "no-await-in-loop": 0, + "no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"], + "quotes": ["error", "single", { "allowTemplateLiterals": true }] + } +} diff --git a/package.json b/package.json index 2bb16c9..d0c895f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "lint": "eslint .", + "lint:fix": "eslint --fix" }, "eslintConfig": { "extends": "react-app" @@ -52,5 +54,9 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "eslint": "^8.11.0", + "eslint-plugin-react": "^7.29.4" } } diff --git a/src/components/Alert/Alert.component.jsx b/src/components/Alert/Alert.component.jsx index 3a2c56d..a559b8a 100644 --- a/src/components/Alert/Alert.component.jsx +++ b/src/components/Alert/Alert.component.jsx @@ -21,7 +21,7 @@ const Alert = ({ alerts }) => { ) } } - ) + ) } Alert.propTypes = { diff --git a/src/components/AuthForm/AuthForm.component.jsx b/src/components/AuthForm/AuthForm.component.jsx index 1bc6fcd..134fb61 100644 --- a/src/components/AuthForm/AuthForm.component.jsx +++ b/src/components/AuthForm/AuthForm.component.jsx @@ -41,7 +41,7 @@ const AuthForm = ({register, login, action}) => { const logInLink = ( - Don't have an account?{' '} + Don't have an account?{' '} Sign up diff --git a/src/components/Footer/Footer.component.jsx b/src/components/Footer/Footer.component.jsx index e71c914..d3f9cfb 100644 --- a/src/components/Footer/Footer.component.jsx +++ b/src/components/Footer/Footer.component.jsx @@ -1,7 +1,7 @@ -import React, { Fragment } from "react"; +import React, { Fragment } from 'react'; -import {ReactComponent as GitHub} from "../../assets/GitHub.svg"; -import {ReactComponent as Database} from "../../assets/Database.svg"; +import {ReactComponent as GitHub} from '../../assets/GitHub.svg'; +import {ReactComponent as Database} from '../../assets/Database.svg'; import './Footer.styles.scss'; diff --git a/src/components/Header/Header.component.jsx b/src/components/Header/Header.component.jsx index 08581d9..87ba070 100644 --- a/src/components/Header/Header.component.jsx +++ b/src/components/Header/Header.component.jsx @@ -75,15 +75,15 @@ const Header = ({auth: {isAuthenticated, loading, user}, logout}) => { className='small-search-form' autoComplete='off' > - - + + ); } diff --git a/src/components/LayoutWrapper/LayoutWrapper.component.jsx b/src/components/LayoutWrapper/LayoutWrapper.component.jsx index 92d1902..d9e960b 100644 --- a/src/components/LayoutWrapper/LayoutWrapper.component.jsx +++ b/src/components/LayoutWrapper/LayoutWrapper.component.jsx @@ -2,7 +2,7 @@ import React, {Fragment} from 'react'; import SideBar from './SideBar/SideBar.component'; import RightSideBar from './RightSideBar/RightSideBar.component'; -import Footer from "../Footer/Footer.component"; +import Footer from '../Footer/Footer.component'; const LayoutWrapper = ({component: Component}) => { return class DefaultLayoutWrapper extends React.Component { diff --git a/src/components/LayoutWrapper/RightSideBar/SideBarWidget/SideBarWidget.component.jsx b/src/components/LayoutWrapper/RightSideBar/SideBarWidget/SideBarWidget.component.jsx index 959c542..3cba50f 100644 --- a/src/components/LayoutWrapper/RightSideBar/SideBarWidget/SideBarWidget.component.jsx +++ b/src/components/LayoutWrapper/RightSideBar/SideBarWidget/SideBarWidget.component.jsx @@ -1,7 +1,7 @@ import React, {Fragment} from 'react'; import {Link} from 'react-router-dom'; -import { SideBarWidgetData } from "./SideBarWidgetData"; +import { SideBarWidgetData } from './SideBarWidgetData'; import './SideBarWidget.styles.scss'; diff --git a/src/components/LayoutWrapper/RightSideBar/SideBarWidget/SideBarWidgetData.js b/src/components/LayoutWrapper/RightSideBar/SideBarWidget/SideBarWidgetData.js index 52beb62..93e3983 100644 --- a/src/components/LayoutWrapper/RightSideBar/SideBarWidget/SideBarWidgetData.js +++ b/src/components/LayoutWrapper/RightSideBar/SideBarWidget/SideBarWidgetData.js @@ -1,6 +1,6 @@ -import React from "react"; +import React from 'react'; -import {ReactComponent as EditLogo} from "../../../../assets/Edit.svg"; +import {ReactComponent as EditLogo} from '../../../../assets/Edit.svg'; export const SideBarWidgetData = [ { diff --git a/src/components/LayoutWrapper/RightSideBar/TagsWidget/TagsWidget.component.jsx b/src/components/LayoutWrapper/RightSideBar/TagsWidget/TagsWidget.component.jsx index 1ad789a..f018615 100644 --- a/src/components/LayoutWrapper/RightSideBar/TagsWidget/TagsWidget.component.jsx +++ b/src/components/LayoutWrapper/RightSideBar/TagsWidget/TagsWidget.component.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import {Link} from 'react-router-dom'; import {getTags} from '../../../../redux/tags/tags.actions'; -import TagsWidgetItem from "./TagsWidgetItem.component"; +import TagsWidgetItem from './TagsWidgetItem.component'; import './TagsWidget.styles.scss'; diff --git a/src/components/LayoutWrapper/RightSideBar/TagsWidget/TagsWidgetItem.component.jsx b/src/components/LayoutWrapper/RightSideBar/TagsWidget/TagsWidgetItem.component.jsx index ec6695a..c64fe55 100644 --- a/src/components/LayoutWrapper/RightSideBar/TagsWidget/TagsWidgetItem.component.jsx +++ b/src/components/LayoutWrapper/RightSideBar/TagsWidget/TagsWidgetItem.component.jsx @@ -1,6 +1,6 @@ -import React, {Fragment} from "react"; +import React, {Fragment} from 'react'; -import TagBadge from "../../../TagBadge/TagBadge.component"; +import TagBadge from '../../../TagBadge/TagBadge.component'; import './TagsWidgetItem.styles.scss'; diff --git a/src/components/LayoutWrapper/SideBar/SideBar.component.jsx b/src/components/LayoutWrapper/SideBar/SideBar.component.jsx index 3c0972d..88a8082 100644 --- a/src/components/LayoutWrapper/SideBar/SideBar.component.jsx +++ b/src/components/LayoutWrapper/SideBar/SideBar.component.jsx @@ -1,7 +1,7 @@ import React from 'react'; -import SideBarItem from "./SideBarItem.component"; -import { SideBarData } from "./SideBarData"; +import SideBarItem from './SideBarItem.component'; +import { SideBarData } from './SideBarData'; import './SideBar.styles.scss'; diff --git a/src/components/LayoutWrapper/SideBar/SideBarData.js b/src/components/LayoutWrapper/SideBar/SideBarData.js index deabf8b..09d9448 100644 --- a/src/components/LayoutWrapper/SideBar/SideBarData.js +++ b/src/components/LayoutWrapper/SideBar/SideBarData.js @@ -3,6 +3,7 @@ import { ReactComponent as GlobalIcon } from '../../../assets/Globe.svg'; export const SideBarData = [ { link: '/questions', + // eslint-disable-next-line react/react-in-jsx-scope icon: , text: 'Stack Overflow', }, diff --git a/src/components/MobileSideBar/MobileSideBar.component.jsx b/src/components/MobileSideBar/MobileSideBar.component.jsx index d9e101d..4941484 100644 --- a/src/components/MobileSideBar/MobileSideBar.component.jsx +++ b/src/components/MobileSideBar/MobileSideBar.component.jsx @@ -1,111 +1,111 @@ -import React, { useState } from "react"; -import { NavLink } from "react-router-dom"; +import React, { useState } from 'react'; +import { NavLink } from 'react-router-dom'; -import { ReactComponent as Hamburger } from "../../assets/LogoGlyphMd.svg"; -import { ReactComponent as Stack } from "../../assets/LogoMd.svg"; -import { ReactComponent as GlobalIcon } from "../../assets/Globe.svg"; +import { ReactComponent as Hamburger } from '../../assets/LogoGlyphMd.svg'; +import { ReactComponent as Stack } from '../../assets/LogoMd.svg'; +import { ReactComponent as GlobalIcon } from '../../assets/Globe.svg'; -import "./MobileSideBar.styles.scss"; +import './MobileSideBar.styles.scss'; const SidebarUI = ({ isOpen, ...rest }) => { - const classes = ["Sidebar", isOpen ? "is-open" : ""]; + const classes = ['Sidebar', isOpen ? 'is-open' : '']; - return ( -
- ); + return ( +
+ ); }; SidebarUI.Overlay = (props) =>
; -SidebarUI.Content = ({ width = "20rem", isRight = false, ...rest }) => { - const classes = ["SidebarContent", isRight ? "is-right" : ""]; - const style = { - width, - height: "100%", - top: 0, - right: isRight ? `-${width}` : "auto", - left: !isRight ? `-${width}` : "auto", - }; +SidebarUI.Content = ({ width = '20rem', isRight = false, ...rest }) => { + const classes = ['SidebarContent', isRight ? 'is-right' : '']; + const style = { + width, + height: '100%', + top: 0, + right: isRight ? `-${width}` : 'auto', + left: !isRight ? `-${width}` : 'auto', + }; - return
; + return
; }; const MobileSideBar = (props) => { - const [isOpen, setIsOpen] = useState(false); + const [isOpen, setIsOpen] = useState(false); - function openSidebar(isOp = true) { - setIsOpen(isOp); - } + function openSidebar(isOp = true) { + setIsOpen(isOp); + } - const { hasOverlay, isRight } = props; + const { hasOverlay, isRight } = props; - return ( - - + return ( + + - openSidebar(false)} - > -
- -
-
-
- -

Home

-
+ openSidebar(false)} + > +
+ +
+
+
+ +

Home

+
-
-

PUBLIC

- -

- +

+

PUBLIC

+ +

+ Stack Overflow -

-
- -

Tags

-
- -

Users

-
- -

Jobs

-
-
-
-

TEAMS

-
-
-
- - {hasOverlay ? ( - openSidebar(false)} /> - ) : false} - - ); +

+ + +

Tags

+
+ +

Users

+
+ +

Jobs

+
+
+
+

TEAMS

+
+
+
+
+ {hasOverlay ? ( + openSidebar(false)} /> + ) : false} +
+ ); }; export default MobileSideBar; diff --git a/src/components/Pagination/Pagination.component.jsx b/src/components/Pagination/Pagination.component.jsx index 66327ee..30abeb6 100644 --- a/src/components/Pagination/Pagination.component.jsx +++ b/src/components/Pagination/Pagination.component.jsx @@ -1,5 +1,5 @@ -import React, { Fragment } from "react"; -import { Pagination as MuiPagination, PaginationItem } from "@mui/material"; +import React, { Fragment } from 'react'; +import { Pagination as MuiPagination, PaginationItem } from '@mui/material'; const Pagination = ({ page, diff --git a/src/pages/AllTagsPage/AllTagsPage.component.jsx b/src/pages/AllTagsPage/AllTagsPage.component.jsx index e56e1a8..e0fd9ba 100644 --- a/src/pages/AllTagsPage/AllTagsPage.component.jsx +++ b/src/pages/AllTagsPage/AllTagsPage.component.jsx @@ -8,7 +8,7 @@ import TagPanel from './TagPanel/TagPanel.component'; import Spinner from '../../components/Spinner/Spinner.component'; import SearchBox from '../../components/SearchBox/SearchBox.component'; import ButtonGroup from '../../components/ButtonGroup/ButtonGroup.component'; -import Pagination from "../../components/Pagination/Pagination.component"; +import Pagination from '../../components/Pagination/Pagination.component'; import './AllTagsPage.styles.scss'; diff --git a/src/pages/AllUsersPage/AllUsersPage.component.jsx b/src/pages/AllUsersPage/AllUsersPage.component.jsx index 2532b3e..53cf33d 100644 --- a/src/pages/AllUsersPage/AllUsersPage.component.jsx +++ b/src/pages/AllUsersPage/AllUsersPage.component.jsx @@ -8,7 +8,7 @@ import UserPanel from './UserPanel/UserPanel.component'; import Spinner from '../../components/Spinner/Spinner.component'; import SearchBox from '../../components/SearchBox/SearchBox.component'; import ButtonGroup from '../../components/ButtonGroup/ButtonGroup.component'; -import Pagination from "../../components/Pagination/Pagination.component"; +import Pagination from '../../components/Pagination/Pagination.component'; import './AllUsersPage.styles.scss'; diff --git a/src/pages/HomePage/HomePage.component.jsx b/src/pages/HomePage/HomePage.component.jsx index eaf32e1..68f461a 100644 --- a/src/pages/HomePage/HomePage.component.jsx +++ b/src/pages/HomePage/HomePage.component.jsx @@ -6,8 +6,8 @@ import {getPosts} from '../../redux/posts/posts.actions'; import LinkButton from '../../components/LinkButton/LinkButton.component'; import PostItem from '../../components/PostItem/PostItem.component'; import Spinner from '../../components/Spinner/Spinner.component'; -import handleSorting from "../../services/handleSorting"; -import Pagination from "../../components/Pagination/Pagination.component"; +import handleSorting from '../../services/handleSorting'; +import Pagination from '../../components/Pagination/Pagination.component'; import './HomePage.styles.scss'; @@ -47,8 +47,8 @@ const HomePage = ({getPosts, post: {posts, loading}}) => { .sort(handleSorting('Top')) .slice((page - 1) * itemsPerPage, (page - 1) * itemsPerPage + itemsPerPage) .map((post, index) => ( - - ))} + + ))}
{ if (isAuthenticated) { diff --git a/src/pages/NotFound/NotFound.component.jsx b/src/pages/NotFound/NotFound.component.jsx index 617cf9c..54feb94 100644 --- a/src/pages/NotFound/NotFound.component.jsx +++ b/src/pages/NotFound/NotFound.component.jsx @@ -35,7 +35,7 @@ const NotFound = () => {
Whoops!
- It seems like we couldn't find the page you were looking for + It seems like we couldn't find the page you were looking for
diff --git a/src/pages/Post/AnswerSection/AnswerItem/AnswerItem.component.jsx b/src/pages/Post/AnswerSection/AnswerItem/AnswerItem.component.jsx index 2761a57..a3cd63a 100644 --- a/src/pages/Post/AnswerSection/AnswerItem/AnswerItem.component.jsx +++ b/src/pages/Post/AnswerSection/AnswerItem/AnswerItem.component.jsx @@ -59,16 +59,16 @@ const AnswerItem = ({ {!auth.loading && auth.isAuthenticated && user_id === auth.user.id && ( - deleteAnswer(id)} - to={`/questions/${post.id}`} - > + deleteAnswer(id)} + to={`/questions/${post.id}`} + > delete - - )} + + )}
deleteComment(comment.id)} - to={`/questions/${post.id}`} - > + deleteComment(comment.id)} + to={`/questions/${post.id}`} + > delete - - )} + + )}
)) diff --git a/src/pages/Post/QuestionSection/PostCell/PostCell.component.jsx b/src/pages/Post/QuestionSection/PostCell/PostCell.component.jsx index 4af09b4..a2b6a55 100644 --- a/src/pages/Post/QuestionSection/PostCell/PostCell.component.jsx +++ b/src/pages/Post/QuestionSection/PostCell/PostCell.component.jsx @@ -19,7 +19,7 @@ const PostCell = ({ return (
-
+
{tags.map((tag, index) => ( @@ -46,16 +46,16 @@ const PostCell = ({ {!auth.loading && auth.isAuthenticated && user_id === auth.user.id && ( - deletePost(id)} - to='/questions' - > + deletePost(id)} + to='/questions' + > delete - - )} + + )}
alert.id !== action.payload); - default: - return state; + case SET_ALERT: + return [...state, action.payload]; + case REMOVE_ALERT: + return state.filter((alert) => alert.id !== action.payload); + default: + return state; } } diff --git a/src/redux/answers/answers.actions.js b/src/redux/answers/answers.actions.js index ac64f66..94899ff 100644 --- a/src/redux/answers/answers.actions.js +++ b/src/redux/answers/answers.actions.js @@ -7,7 +7,7 @@ import { import axios from 'axios'; import {setAlert} from '../alert/alert.actions'; -import config from "../../config"; +import config from '../../config'; export const getAnswers = (id) => async (dispatch) => { try { diff --git a/src/redux/answers/answers.reducer.js b/src/redux/answers/answers.reducer.js index 0936536..4054a87 100644 --- a/src/redux/answers/answers.reducer.js +++ b/src/redux/answers/answers.reducer.js @@ -13,31 +13,31 @@ const initialState = { export default function answers(state = initialState, action) { switch (action.type) { - case GET_ANSWERS: - return { - ...state, - answers: action.payload, - loading: false, - }; - case ADD_ANSWER: - return { - ...state, - answers: [...state.answers, action.payload], - loading: false, - }; - case DELETE_ANSWER: - return { - ...state, - answers: state.answers.filter((answer) => answer.id !== action.payload), - loading: false, - }; - case ANSWER_ERROR: - return { - ...state, - error: action.payload, - loading: false, - }; - default: - return state; + case GET_ANSWERS: + return { + ...state, + answers: action.payload, + loading: false, + }; + case ADD_ANSWER: + return { + ...state, + answers: [...state.answers, action.payload], + loading: false, + }; + case DELETE_ANSWER: + return { + ...state, + answers: state.answers.filter((answer) => answer.id !== action.payload), + loading: false, + }; + case ANSWER_ERROR: + return { + ...state, + error: action.payload, + loading: false, + }; + default: + return state; } } diff --git a/src/redux/auth/auth.actions.js b/src/redux/auth/auth.actions.js index fccdf2d..1e0466b 100644 --- a/src/redux/auth/auth.actions.js +++ b/src/redux/auth/auth.actions.js @@ -1,6 +1,6 @@ import axios from 'axios'; -import config from "../../config"; +import config from '../../config'; import setAuthToken from './auth.utils'; import {setAlert} from '../alert/alert.actions'; import { @@ -37,7 +37,7 @@ export const register = ({username, password}) => async (dispatch) => { const config_headers = { headers: { 'Content-Type': 'application/json', - Accept: "application/json", + Accept: 'application/json', }, }; @@ -68,7 +68,7 @@ export const login = ({username, password}) => async (dispatch) => { const config_headers = { headers: { 'Content-Type': 'application/json', - Accept: "application/json", + Accept: 'application/json', }, }; diff --git a/src/redux/auth/auth.reducer.js b/src/redux/auth/auth.reducer.js index ec3ac3c..82a3163 100644 --- a/src/redux/auth/auth.reducer.js +++ b/src/redux/auth/auth.reducer.js @@ -17,35 +17,35 @@ const initialState = { export default function auth(state = initialState, action) { switch (action.type) { - case USER_LOADED: - return { - ...state, - user: action.payload, - isAuthenticated: true, - loading: false, - }; + case USER_LOADED: + return { + ...state, + user: action.payload, + isAuthenticated: true, + loading: false, + }; - case REGISTER_SUCCESS: - case LOGIN_SUCCESS: - localStorage.setItem('token', action.payload.token); - return { - ...state, - ...action.payload, - isAuthenticated: true, - loading: false, - }; - case REGISTER_FAIL: - case AUTH_ERROR: - case LOGIN_FAIL: - case LOGOUT: - localStorage.removeItem('token'); - return { - ...state, - token: null, - isAuthenticated: false, - loading: false, - }; - default: - return state; + case REGISTER_SUCCESS: + case LOGIN_SUCCESS: + localStorage.setItem('token', action.payload.token); + return { + ...state, + ...action.payload, + isAuthenticated: true, + loading: false, + }; + case REGISTER_FAIL: + case AUTH_ERROR: + case LOGIN_FAIL: + case LOGOUT: + localStorage.removeItem('token'); + return { + ...state, + token: null, + isAuthenticated: false, + loading: false, + }; + default: + return state; } } diff --git a/src/redux/comments/comments.actions.js b/src/redux/comments/comments.actions.js index 3027c58..33fdd9c 100644 --- a/src/redux/comments/comments.actions.js +++ b/src/redux/comments/comments.actions.js @@ -1,6 +1,6 @@ import axios from 'axios'; -import config from "../../config"; +import config from '../../config'; import {setAlert} from '../alert/alert.actions'; import { GET_COMMENTS, diff --git a/src/redux/comments/comments.reducer.js b/src/redux/comments/comments.reducer.js index 73f6c38..a7a75dc 100644 --- a/src/redux/comments/comments.reducer.js +++ b/src/redux/comments/comments.reducer.js @@ -13,33 +13,33 @@ const initialState = { export default function comments(state = initialState, action) { switch (action.type) { - case GET_COMMENTS: - return { - ...state, - comments: action.payload, - loading: false, - }; - case ADD_COMMENT: - return { - ...state, - comments: [action.payload, ...state.comments], - loading: false, - }; - case DELETE_COMMENT: - return { - ...state, - comments: state.comments.filter( - (answer) => answer.id !== action.payload - ), - loading: false, - }; - case COMMENT_ERROR: - return { - ...state, - error: action.payload, - loading: false, - }; - default: - return state; + case GET_COMMENTS: + return { + ...state, + comments: action.payload, + loading: false, + }; + case ADD_COMMENT: + return { + ...state, + comments: [action.payload, ...state.comments], + loading: false, + }; + case DELETE_COMMENT: + return { + ...state, + comments: state.comments.filter( + (answer) => answer.id !== action.payload + ), + loading: false, + }; + case COMMENT_ERROR: + return { + ...state, + error: action.payload, + loading: false, + }; + default: + return state; } } diff --git a/src/redux/posts/posts.actions.js b/src/redux/posts/posts.actions.js index 19183b8..5656bb9 100644 --- a/src/redux/posts/posts.actions.js +++ b/src/redux/posts/posts.actions.js @@ -1,6 +1,6 @@ import axios from 'axios'; -import config from "../../config"; +import config from '../../config'; import {setAlert} from '../alert/alert.actions'; import { GET_POSTS, diff --git a/src/redux/posts/posts.reducer.js b/src/redux/posts/posts.reducer.js index 2344631..20c9a92 100644 --- a/src/redux/posts/posts.reducer.js +++ b/src/redux/posts/posts.reducer.js @@ -17,39 +17,39 @@ const initialState = { export default function posts(state = initialState, action) { switch (action.type) { - case GET_POSTS: - case GET_TOP_POSTS: - case GET_TAG_POSTS: - return { - ...state, - posts: action.payload, - loading: false, - }; - case GET_POST: - return { - ...state, - post: action.payload, - loading: false, - }; - case ADD_POST: - return { - ...state, - posts: [action.payload, ...state.posts], - loading: false, - }; - case DELETE_POST: - return { - ...state, - posts: state.posts.filter((post) => post.id !== action.payload), - loading: false, - }; - case POST_ERROR: - return { - ...state, - error: action.payload, - loading: false, - }; - default: - return state; + case GET_POSTS: + case GET_TOP_POSTS: + case GET_TAG_POSTS: + return { + ...state, + posts: action.payload, + loading: false, + }; + case GET_POST: + return { + ...state, + post: action.payload, + loading: false, + }; + case ADD_POST: + return { + ...state, + posts: [action.payload, ...state.posts], + loading: false, + }; + case DELETE_POST: + return { + ...state, + posts: state.posts.filter((post) => post.id !== action.payload), + loading: false, + }; + case POST_ERROR: + return { + ...state, + error: action.payload, + loading: false, + }; + default: + return state; } } diff --git a/src/redux/tags/tags.actions.js b/src/redux/tags/tags.actions.js index 0105154..b579d0a 100644 --- a/src/redux/tags/tags.actions.js +++ b/src/redux/tags/tags.actions.js @@ -1,7 +1,7 @@ import {GET_TAG, GET_TAGS, TAG_ERROR} from './tags.types'; import axios from 'axios'; import {setAlert} from '../alert/alert.actions'; -import config from "../../config"; +import config from '../../config'; export const getTag = (tagName) => async (dispatch) => { try { diff --git a/src/redux/tags/tags.reducer.js b/src/redux/tags/tags.reducer.js index 75cca68..8555d09 100644 --- a/src/redux/tags/tags.reducer.js +++ b/src/redux/tags/tags.reducer.js @@ -10,28 +10,28 @@ const initialState = { export default function tags(state = initialState, action) { switch (action.type) { - case GET_TAG: - return { - ...state, - tag: action.payload, - loading: false, - redirect: false, - }; - case GET_TAGS: - return { - ...state, - tags: action.payload, - loading: false, - redirect: false, - }; - case TAG_ERROR: - return { - ...state, - error: action.payload, - loading: false, - redirect: true, - }; - default: - return state; + case GET_TAG: + return { + ...state, + tag: action.payload, + loading: false, + redirect: false, + }; + case GET_TAGS: + return { + ...state, + tags: action.payload, + loading: false, + redirect: false, + }; + case TAG_ERROR: + return { + ...state, + error: action.payload, + loading: false, + redirect: true, + }; + default: + return state; } } diff --git a/src/redux/users/users.actions.js b/src/redux/users/users.actions.js index 49103e8..6bda77a 100644 --- a/src/redux/users/users.actions.js +++ b/src/redux/users/users.actions.js @@ -1,6 +1,6 @@ import axios from 'axios'; -import config from "../../config"; +import config from '../../config'; import {GET_USERS, GET_USER, USER_ERROR} from './users.types'; // Get users diff --git a/src/redux/users/users.reducer.js b/src/redux/users/users.reducer.js index 8494411..07e2550 100644 --- a/src/redux/users/users.reducer.js +++ b/src/redux/users/users.reducer.js @@ -1,4 +1,4 @@ -import {GET_USERS, GET_USER, USER_ERROR} from './users.types'; +import { GET_USERS, GET_USER, USER_ERROR } from './users.types'; const initialState = { users: [], @@ -9,25 +9,25 @@ const initialState = { export default function users(state = initialState, action) { switch (action.type) { - case GET_USERS: - return { - ...state, - users: action.payload, - loading: false, - }; - case GET_USER: - return { - ...state, - user: action.payload, - loading: false, - }; - case USER_ERROR: - return { - ...state, - error: action.payload, - loading: false, - }; - default: - return state; + case GET_USERS: + return { + ...state, + users: action.payload, + loading: false, + }; + case GET_USER: + return { + ...state, + user: action.payload, + loading: false, + }; + case USER_ERROR: + return { + ...state, + error: action.payload, + loading: false, + }; + default: + return state; } } diff --git a/src/services/handleSorting.js b/src/services/handleSorting.js index 0dd65c8..acd2b1a 100644 --- a/src/services/handleSorting.js +++ b/src/services/handleSorting.js @@ -8,32 +8,32 @@ const handleSorting = (sortType, page = '') => { } switch (temp) { - case 'Newest': - return (a, b) => new Date(b.created_at) - new Date(a.created_at); - case 'New': - return (a, b) => new Date(b.created_at) - new Date(a.created_at); - case 'New Users': - return (a, b) => new Date(b.created_at) - new Date(a.created_at); - case 'Top': - return (a, b) => - b.answer_count + b.comment_count - (a.answer_count + a.comment_count); - case 'Active': - return (a, b) => - b.posts_count + b.tags_count - (a.posts_count + a.tags_count); - case 'Views': - return (a, b) => b.views - a.views; - case 'Oldest': - return (a, b) => new Date(a.created_at) - new Date(b.created_at); - case 'Popular': - return (a, b) => b.posts_count - a.posts_count; - case 'Name': - return (a, b) => a.tagname.localeCompare(b.tagname); - case 'Username': - return (a, b) => a.username.localeCompare(b.username); - case 'Popular users': - return (a, b) => b.views - a.views; - default: - break; + case 'Newest': + return (a, b) => new Date(b.created_at) - new Date(a.created_at); + case 'New': + return (a, b) => new Date(b.created_at) - new Date(a.created_at); + case 'New Users': + return (a, b) => new Date(b.created_at) - new Date(a.created_at); + case 'Top': + return (a, b) => + b.answer_count + b.comment_count - (a.answer_count + a.comment_count); + case 'Active': + return (a, b) => + b.posts_count + b.tags_count - (a.posts_count + a.tags_count); + case 'Views': + return (a, b) => b.views - a.views; + case 'Oldest': + return (a, b) => new Date(a.created_at) - new Date(b.created_at); + case 'Popular': + return (a, b) => b.posts_count - a.posts_count; + case 'Name': + return (a, b) => a.tagname.localeCompare(b.tagname); + case 'Username': + return (a, b) => a.username.localeCompare(b.username); + case 'Popular users': + return (a, b) => b.views - a.views; + default: + break; } }; diff --git a/src/services/htmlSubstring.js b/src/services/htmlSubstring.js index faa75e1..8be357b 100644 --- a/src/services/htmlSubstring.js +++ b/src/services/htmlSubstring.js @@ -1,40 +1,40 @@ // http://jsfiddle.net/danmana/5mNNU/ const htmlSubstring = (s, n) => { - var m, r = /<([^>\s]*)[^>]*>/g, - stack = [], - lasti = 0, - result = ''; + var m, r = /<([^>\s]*)[^>]*>/g, + stack = [], + lasti = 0, + result = ''; - //for each tag, while we don't have enough characters - while ((m = r.exec(s)) && n) { - //get the text substring between the last tag and this one - var temp = s.substring(lasti, m.index).substr(0, n); - //append to the result and count the number of characters added - result += temp; - n -= temp.length; - lasti = r.lastIndex; + //for each tag, while we don't have enough characters + while ((m = r.exec(s)) && n) { + //get the text substring between the last tag and this one + var temp = s.substring(lasti, m.index).substr(0, n); + //append to the result and count the number of characters added + result += temp; + n -= temp.length; + lasti = r.lastIndex; - if (n) { - result += m[0]; - if (m[1].indexOf('/') === 0) { - //if this is a closing tag, than pop the stack (does not account for bad html) - stack.pop(); - } else if (m[1].lastIndexOf('/') !== m[1].length - 1) { - //if this is not a self closing tag than push it in the stack - stack.push(m[1]); - } - } + if (n) { + result += m[0]; + if (m[1].indexOf('/') === 0) { + //if this is a closing tag, than pop the stack (does not account for bad html) + stack.pop(); + } else if (m[1].lastIndexOf('/') !== m[1].length - 1) { + //if this is not a self closing tag than push it in the stack + stack.push(m[1]); + } } + } - //add the remainder of the string, if needed (there are no more tags in here) - result += s.substr(lasti, n); + //add the remainder of the string, if needed (there are no more tags in here) + result += s.substr(lasti, n); - //fix the unclosed tags - while (stack.length) { - result += ''; - } + //fix the unclosed tags + while (stack.length) { + result += ''; + } - return result; + return result; } diff --git a/src/services/injectEllipsis.js b/src/services/injectEllipsis.js index 725f511..d8bb44e 100644 --- a/src/services/injectEllipsis.js +++ b/src/services/injectEllipsis.js @@ -1,13 +1,13 @@ const injectEllipsis = (html) => { - const re = /<\/p>/g - const str = html; - let lastMatchIndex; - let match; - while ((match = re.exec(str)) != null) { - lastMatchIndex = match.index; - } + const re = /<\/p>/g + const str = html; + let lastMatchIndex; + let match; + while ((match = re.exec(str)) != null) { + lastMatchIndex = match.index; + } - return html.substring(0, lastMatchIndex) + "..." + html.substring(lastMatchIndex) + return html.substring(0, lastMatchIndex) + '...' + html.substring(lastMatchIndex) } export default injectEllipsis; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index c326ad2..abf7470 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1167,16 +1167,16 @@ "resolved" "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz" "version" "0.2.5" -"@eslint/eslintrc@^1.0.5": - "integrity" "sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==" - "resolved" "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.0.5.tgz" - "version" "1.0.5" +"@eslint/eslintrc@^1.2.1": + "integrity" "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==" + "resolved" "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz" + "version" "1.2.1" dependencies: "ajv" "^6.12.4" "debug" "^4.3.2" - "espree" "^9.2.0" + "espree" "^9.3.1" "globals" "^13.9.0" - "ignore" "^4.0.6" + "ignore" "^5.2.0" "import-fresh" "^3.2.1" "js-yaml" "^4.1.0" "minimatch" "^3.0.4" @@ -2307,7 +2307,7 @@ "resolved" "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz" "version" "7.2.0" -"acorn@^6.0.0 || ^7.0.0 || ^8.0.0", "acorn@^8", "acorn@^8.2.4", "acorn@^8.4.1", "acorn@^8.5.0", "acorn@^8.6.0": +"acorn@^6.0.0 || ^7.0.0 || ^8.0.0", "acorn@^8", "acorn@^8.2.4", "acorn@^8.4.1", "acorn@^8.5.0", "acorn@^8.7.0": "integrity" "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==" "resolved" "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz" "version" "8.7.0" @@ -2414,11 +2414,6 @@ "resolved" "https://registry.npmjs.org/alphanum-sort/-/alphanum-sort-1.0.2.tgz" "version" "1.0.2" -"ansi-colors@^4.1.1": - "integrity" "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" - "resolved" "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz" - "version" "4.1.1" - "ansi-escapes@^4.2.1", "ansi-escapes@^4.3.1": "integrity" "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==" "resolved" "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz" @@ -3962,13 +3957,6 @@ "graceful-fs" "^4.2.4" "tapable" "^2.2.0" -"enquirer@^2.3.5": - "integrity" "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==" - "resolved" "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz" - "version" "2.3.6" - dependencies: - "ansi-colors" "^4.1.1" - "entities@^2.0.0": "integrity" "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==" "resolved" "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz" @@ -4093,14 +4081,13 @@ "debug" "^3.2.7" "resolve" "^1.20.0" -"eslint-module-utils@^2.7.1": - "integrity" "sha512-fjoetBXQZq2tSTWZ9yWVl2KuFrTZZH3V+9iD1V1RfpDgxzJR+mPd/KZmMiA8gbPqdBzpNiEHOuT7IYEWxrH0zQ==" - "resolved" "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.1.tgz" - "version" "2.7.1" +"eslint-module-utils@^2.7.2": + "integrity" "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==" + "resolved" "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz" + "version" "2.7.3" dependencies: "debug" "^3.2.7" "find-up" "^2.1.0" - "pkg-dir" "^2.0.0" "eslint-plugin-flowtype@^8.0.3": "integrity" "sha512-dX8l6qUL6O+fYPtpNRideCFSpmWOUVx5QcaGLVqe/vlDiBSe4vYljDWDETwnyFzpl7By/WVIu6rcrniCgH9BqQ==" @@ -4111,23 +4098,23 @@ "string-natural-compare" "^3.0.1" "eslint-plugin-import@^2.25.3": - "integrity" "sha512-RzAVbby+72IB3iOEL8clzPLzL3wpDrlwjsTBAQXgyp5SeTqqY+0bFubwuo+y/HLhNZcXV4XqTBO4LGsfyHIDXg==" - "resolved" "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.3.tgz" - "version" "2.25.3" + "integrity" "sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA==" + "resolved" "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.4.tgz" + "version" "2.25.4" dependencies: "array-includes" "^3.1.4" "array.prototype.flat" "^1.2.5" "debug" "^2.6.9" "doctrine" "^2.1.0" "eslint-import-resolver-node" "^0.3.6" - "eslint-module-utils" "^2.7.1" + "eslint-module-utils" "^2.7.2" "has" "^1.0.3" "is-core-module" "^2.8.0" "is-glob" "^4.0.3" "minimatch" "^3.0.4" "object.values" "^1.1.5" "resolve" "^1.20.0" - "tsconfig-paths" "^3.11.0" + "tsconfig-paths" "^3.12.0" "eslint-plugin-jest@^25.3.0": "integrity" "sha512-qi7aduaU4/oWegWo0zH4kbJbx8+Be+ABTr72OnO68zTMcJeeSuyH1CduTGF4ATyNFgpE1zp0u10/gIhe+QDSfg==" @@ -4159,22 +4146,22 @@ "resolved" "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.3.0.tgz" "version" "4.3.0" -"eslint-plugin-react@^7.27.1": - "integrity" "sha512-IOlFIRHzWfEQQKcAD4iyYDndHwTQiCMcJVJjxempf203jnNLUnW34AXLrV33+nEXoifJE2ZEGmcjKPL8957eSw==" - "resolved" "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.28.0.tgz" - "version" "7.28.0" +"eslint-plugin-react@^7.27.1", "eslint-plugin-react@^7.29.4": + "integrity" "sha512-CVCXajliVh509PcZYRFyu/BoUEz452+jtQJq2b3Bae4v3xBUWPLCmtmBM+ZinG4MzwmxJgJ2M5rMqhqLVn7MtQ==" + "resolved" "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.29.4.tgz" + "version" "7.29.4" dependencies: "array-includes" "^3.1.4" "array.prototype.flatmap" "^1.2.5" "doctrine" "^2.1.0" "estraverse" "^5.3.0" "jsx-ast-utils" "^2.4.1 || ^3.0.0" - "minimatch" "^3.0.4" + "minimatch" "^3.1.2" "object.entries" "^1.1.5" "object.fromentries" "^2.0.5" "object.hasown" "^1.1.0" "object.values" "^1.1.5" - "prop-types" "^15.7.2" + "prop-types" "^15.8.1" "resolve" "^2.0.0-next.3" "semver" "^6.3.0" "string.prototype.matchall" "^4.0.6" @@ -4194,10 +4181,10 @@ "esrecurse" "^4.3.0" "estraverse" "^4.1.1" -"eslint-scope@^7.1.0": - "integrity" "sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg==" - "resolved" "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.0.tgz" - "version" "7.1.0" +"eslint-scope@^7.1.1": + "integrity" "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==" + "resolved" "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz" + "version" "7.1.1" dependencies: "esrecurse" "^4.3.0" "estraverse" "^5.2.0" @@ -4227,10 +4214,10 @@ "resolved" "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz" "version" "2.1.0" -"eslint-visitor-keys@^3.0.0", "eslint-visitor-keys@^3.1.0": - "integrity" "sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA==" - "resolved" "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.1.0.tgz" - "version" "3.1.0" +"eslint-visitor-keys@^3.0.0", "eslint-visitor-keys@^3.3.0": + "integrity" "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==" + "resolved" "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz" + "version" "3.3.0" "eslint-webpack-plugin@^3.1.1": "integrity" "sha512-xSucskTN9tOkfW7so4EaiFIkulWLXwCB/15H917lR6pTv0Zot6/fetFucmENRb7J5whVSFKIvwnrnsa78SG2yg==" @@ -4243,24 +4230,23 @@ "normalize-path" "^3.0.0" "schema-utils" "^3.1.1" -"eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8", "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8", "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0", "eslint@^6.0.0 || ^7.0.0 || ^8.0.0", "eslint@^7.0.0 || ^8.0.0", "eslint@^7.5.0 || ^8.0.0", "eslint@^8.0.0", "eslint@^8.1.0", "eslint@^8.3.0", "eslint@>= 6", "eslint@>=5": - "integrity" "sha512-tVGSkgNbOfiHyVte8bCM8OmX+xG9PzVG/B4UCF60zx7j61WIVY/AqJECDgpLD4DbbESD0e174gOg3ZlrX15GDg==" - "resolved" "https://registry.npmjs.org/eslint/-/eslint-8.5.0.tgz" - "version" "8.5.0" +"eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8", "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8", "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0", "eslint@^6.0.0 || ^7.0.0 || ^8.0.0", "eslint@^7.0.0 || ^8.0.0", "eslint@^7.5.0 || ^8.0.0", "eslint@^8.0.0", "eslint@^8.1.0", "eslint@^8.11.0", "eslint@^8.3.0", "eslint@>= 6", "eslint@>=5": + "integrity" "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==" + "resolved" "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz" + "version" "8.11.0" dependencies: - "@eslint/eslintrc" "^1.0.5" + "@eslint/eslintrc" "^1.2.1" "@humanwhocodes/config-array" "^0.9.2" "ajv" "^6.10.0" "chalk" "^4.0.0" "cross-spawn" "^7.0.2" "debug" "^4.3.2" "doctrine" "^3.0.0" - "enquirer" "^2.3.5" "escape-string-regexp" "^4.0.0" - "eslint-scope" "^7.1.0" + "eslint-scope" "^7.1.1" "eslint-utils" "^3.0.0" - "eslint-visitor-keys" "^3.1.0" - "espree" "^9.2.0" + "eslint-visitor-keys" "^3.3.0" + "espree" "^9.3.1" "esquery" "^1.4.0" "esutils" "^2.0.2" "fast-deep-equal" "^3.1.3" @@ -4268,7 +4254,7 @@ "functional-red-black-tree" "^1.0.1" "glob-parent" "^6.0.1" "globals" "^13.6.0" - "ignore" "^4.0.6" + "ignore" "^5.2.0" "import-fresh" "^3.0.0" "imurmurhash" "^0.1.4" "is-glob" "^4.0.0" @@ -4279,22 +4265,20 @@ "minimatch" "^3.0.4" "natural-compare" "^1.4.0" "optionator" "^0.9.1" - "progress" "^2.0.0" "regexpp" "^3.2.0" - "semver" "^7.2.1" "strip-ansi" "^6.0.1" "strip-json-comments" "^3.1.0" "text-table" "^0.2.0" "v8-compile-cache" "^2.0.3" -"espree@^9.2.0": - "integrity" "sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg==" - "resolved" "https://registry.npmjs.org/espree/-/espree-9.2.0.tgz" - "version" "9.2.0" +"espree@^9.3.1": + "integrity" "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==" + "resolved" "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz" + "version" "9.3.1" dependencies: - "acorn" "^8.6.0" + "acorn" "^8.7.0" "acorn-jsx" "^5.3.1" - "eslint-visitor-keys" "^3.1.0" + "eslint-visitor-keys" "^3.3.0" "esprima@^4.0.0", "esprima@^4.0.1": "integrity" "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" @@ -4810,9 +4794,9 @@ "type-fest" "^0.20.2" "globals@^13.9.0": - "integrity" "sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg==" - "resolved" "https://registry.npmjs.org/globals/-/globals-13.12.0.tgz" - "version" "13.12.0" + "integrity" "sha512-EQ7Q18AJlPwp3vUDL4mKA0KXrXyNIQyWon6T6XQiBQF0XHvRsiCSrWmmeATpUzdJN2HhWZU6Pdl0a9zdep5p6A==" + "resolved" "https://registry.npmjs.org/globals/-/globals-13.13.0.tgz" + "version" "13.13.0" dependencies: "type-fest" "^0.20.2" @@ -5078,17 +5062,7 @@ dependencies: "harmony-reflect" "^1.4.6" -"ignore@^4.0.6": - "integrity" "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==" - "resolved" "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz" - "version" "4.0.6" - -"ignore@^5.1.4": - "integrity" "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==" - "resolved" "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz" - "version" "5.2.0" - -"ignore@^5.1.8": +"ignore@^5.1.4", "ignore@^5.1.8", "ignore@^5.2.0": "integrity" "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==" "resolved" "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz" "version" "5.2.0" @@ -6325,6 +6299,13 @@ dependencies: "brace-expansion" "^1.1.7" +"minimatch@^3.1.2": + "integrity" "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==" + "resolved" "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz" + "version" "3.1.2" + dependencies: + "brace-expansion" "^1.1.7" + "minimist@^1.1.1", "minimist@^1.2.0", "minimist@^1.2.5": "integrity" "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" "resolved" "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz" @@ -6789,13 +6770,6 @@ "resolved" "https://registry.npmjs.org/pirates/-/pirates-4.0.4.tgz" "version" "4.0.4" -"pkg-dir@^2.0.0": - "integrity" "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=" - "resolved" "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz" - "version" "2.0.0" - dependencies: - "find-up" "^2.1.0" - "pkg-dir@^4.1.0": "integrity" "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==" "resolved" "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz" @@ -7380,11 +7354,6 @@ "resolved" "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz" "version" "2.0.1" -"progress@^2.0.0": - "integrity" "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" - "resolved" "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz" - "version" "2.0.3" - "promise@^7.1.1": "integrity" "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==" "resolved" "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz" @@ -7407,10 +7376,10 @@ "kleur" "^3.0.3" "sisteransi" "^1.0.5" -"prop-types@^15.0.0", "prop-types@^15.6.2", "prop-types@^15.7.2", "prop-types@^15.8.0": - "integrity" "sha512-fDGekdaHh65eI3lMi5OnErU6a8Ighg2KjcjQxO7m8VHyWjcPyj5kiOgV1LQDOOOgVy3+5FgjXvdSSX7B8/5/4g==" - "resolved" "https://registry.npmjs.org/prop-types/-/prop-types-15.8.0.tgz" - "version" "15.8.0" +"prop-types@^15.0.0", "prop-types@^15.6.2", "prop-types@^15.7.2", "prop-types@^15.8.0", "prop-types@^15.8.1": + "integrity" "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==" + "resolved" "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz" + "version" "15.8.1" dependencies: "loose-envify" "^1.4.0" "object-assign" "^4.1.1" @@ -8113,13 +8082,6 @@ "resolved" "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz" "version" "6.3.0" -"semver@^7.2.1": - "integrity" "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==" - "resolved" "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz" - "version" "7.3.5" - dependencies: - "lru-cache" "^6.0.0" - "semver@^7.3.2": "integrity" "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==" "resolved" "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz" @@ -8810,7 +8772,7 @@ "resolved" "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz" "version" "1.0.1" -"tsconfig-paths@^3.11.0": +"tsconfig-paths@^3.12.0": "integrity" "sha512-e5adrnOYT6zqVnWqZu7i/BQ3BnhzvGbjEjejFXO20lKIKpwTaupkCPgEfv4GZK1IBciJUEhYs3J3p75FdaTFVg==" "resolved" "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.12.0.tgz" "version" "3.12.0" From 5023a73d0427c3bfe62d37ce097ef88ce908f24a Mon Sep 17 00:00:00 2001 From: Mayank Aggarwal Date: Sun, 20 Mar 2022 01:13:32 +0530 Subject: [PATCH 2/3] feat: add eslint CI --- .github/workflows/lint-check.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/lint-check.yml diff --git a/.github/workflows/lint-check.yml b/.github/workflows/lint-check.yml new file mode 100644 index 0000000..dadb829 --- /dev/null +++ b/.github/workflows/lint-check.yml @@ -0,0 +1,19 @@ +name: Eslint Check + +on: + pull_request: + branches: [ master, main ] + +jobs: + build: + name: ESLint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '16' + - name: Install modules + run: npm i + - name: Run ESLint + run: npm run lint \ No newline at end of file From 3fc9b621e7957a4cdd02014efefe1e9f18f3cc7c Mon Sep 17 00:00:00 2001 From: Mayank Aggarwal Date: Sun, 20 Mar 2022 01:16:35 +0530 Subject: [PATCH 3/3] fix --- .github/workflows/lint-check.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/lint-check.yml b/.github/workflows/lint-check.yml index dadb829..24596ef 100644 --- a/.github/workflows/lint-check.yml +++ b/.github/workflows/lint-check.yml @@ -10,9 +10,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '16' - name: Install modules run: npm i - name: Run ESLint