ref(frontend): fix file or disable eslint rules

This commit is contained in:
이강준
2022-11-26 18:20:02 +09:00
parent f2329884f8
commit 568042fac0
19 changed files with 186 additions and 120 deletions
+4 -1
View File
@@ -1,3 +1,6 @@
{ {
"extends": "next/core-web-vitals" "extends": "next/core-web-vitals",
"rules": {
"react-hooks/exhaustive-deps": "off"
}
} }
+3 -2
View File
@@ -11,9 +11,11 @@ export default function RouteGuard({ children }) {
const router = useRouter(); const router = useRouter();
const [authorized, setAuthorized] = useState(false); const [authorized, setAuthorized] = useState(false);
useEffect(async () => { useEffect(() => {
// on initial load - run auth check // on initial load - run auth check
(async () => {
await authCheck(router.asPath); await authCheck(router.asPath);
})();
// on route change start - hide page content by setting authorized to false // on route change start - hide page content by setting authorized to false
// #TODO: add the loading page when not yet authorized. // #TODO: add the loading page when not yet authorized.
@@ -31,7 +33,6 @@ export default function RouteGuard({ children }) {
router.events.off("routeChangeComplete", authCheck); router.events.off("routeChangeComplete", authCheck);
// router.events.off("routeChangeError", onError); // router.events.off("routeChangeError", onError);
}; };
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
+1
View File
@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import Link from "next/link"; import Link from "next/link";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
@@ -1,8 +1,6 @@
import React from "react"; import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { import { faXmark } from "@fortawesome/free-solid-svg-icons";
faXmark,
} from "@fortawesome/free-solid-svg-icons";
export default function BottonRightPopup({ export default function BottonRightPopup({
buttonText, buttonText,
@@ -11,22 +9,34 @@ export default function BottonRightPopup({
emoji, emoji,
textLine1, textLine1,
textLine2, textLine2,
setCheckDocsPopUpVisible setCheckDocsPopUpVisible,
}) { }) {
return ( return (
<div class="z-50 drop-shadow-xl border-gray-600/50 border flex flex-col items-start bg-bunker max-w-xl text-gray-200 pt-3 pb-4 rounded-xl absolute bottom-0 right-0 mr-6 mb-6" role="alert"> <div
class="z-50 drop-shadow-xl border-gray-600/50 border flex flex-col items-start bg-bunker max-w-xl text-gray-200 pt-3 pb-4 rounded-xl absolute bottom-0 right-0 mr-6 mb-6"
role="alert"
>
<div className="flex flex-row items-center justify-between w-full border-b border-gray-600/70 pb-3 px-6"> <div className="flex flex-row items-center justify-between w-full border-b border-gray-600/70 pb-3 px-6">
<div className="font-bold text-xl mr-2 mt-0.5 flex flex-row"> <div className="font-bold text-xl mr-2 mt-0.5 flex flex-row">
<div>{titleText}</div> <div>{titleText}</div>
<div class="ml-2.5">{emoji}</div> <div class="ml-2.5">{emoji}</div>
</div> </div>
<button className="mt-1" onClick={() => setCheckDocsPopUpVisible(false)}> <button
<FontAwesomeIcon icon={faXmark} className="text-gray-400 text-2xl hover:text-red duration-200 cursor-pointer" /> className="mt-1"
onClick={() => setCheckDocsPopUpVisible(false)}
>
<FontAwesomeIcon
icon={faXmark}
className="text-gray-400 text-2xl hover:text-red duration-200 cursor-pointer"
/>
</button> </button>
</div> </div>
<div class="block sm:inline px-6 mt-4 mb-0.5 text-gray-300">{textLine1}</div> <div class="block sm:inline px-6 mt-4 mb-0.5 text-gray-300">
{textLine1}
</div>
<div class="block sm:inline mb-4 px-6">{textLine2}</div> <div class="block sm:inline mb-4 px-6">{textLine2}</div>
<div className="flex flex-row px-6 w-full"> <div className="flex flex-row px-6 w-full">
{/*eslint-disable-next-line react/jsx-no-target-blank */}
<a <a
class="font-bold p-2 bg-white/10 rounded-md w-full hover:bg-primary duration-200 hover:text-black flex justify-center" class="font-bold p-2 bg-white/10 rounded-md w-full hover:bg-primary duration-200 hover:text-black flex justify-center"
href={buttonLink} href={buttonLink}
+1 -1
View File
@@ -81,7 +81,7 @@ const UserTable = ({
]); ]);
}; };
useEffect(async () => { useEffect(() => {
setMyRole(userData.filter((user) => user.email == myUser)[0]?.role); setMyRole(userData.filter((user) => user.email == myUser)[0]?.role);
}, [userData, myUser]); }, [userData, myUser]);
+6 -3
View File
@@ -37,24 +37,27 @@ export default function Card({ card, changeSelectedCard, selected }) {
<div className="flex flex-row items-center justify-between w-full"> <div className="flex flex-row items-center justify-between w-full">
<div className="flex flex-row items-center"> <div className="flex flex-row items-center">
<p className="tracking-tighter mr-1 mt-0.5 flex"> <p className="tracking-tighter mr-1 mt-0.5 flex">
{"****".split("").map(() => ( {"****".split("").map((_, index) => (
<FontAwesomeIcon <FontAwesomeIcon
key={index}
className="text-xxxs mr-0.5" className="text-xxxs mr-0.5"
icon={faCircle} icon={faCircle}
/> />
))} ))}
</p> </p>
<p className="tracking-tighter mr-1 mt-0.5 flex"> <p className="tracking-tighter mr-1 mt-0.5 flex">
{"****".split("").map(() => ( {"****".split("").map((_, index) => (
<FontAwesomeIcon <FontAwesomeIcon
key={index}
className="text-xxxs mr-0.5" className="text-xxxs mr-0.5"
icon={faCircle} icon={faCircle}
/> />
))} ))}
</p> </p>
<p className="tracking-tighter mr-1 mt-0.5 flex"> <p className="tracking-tighter mr-1 mt-0.5 flex">
{"****".split("").map(() => ( {"****".split("").map((_, index) => (
<FontAwesomeIcon <FontAwesomeIcon
key={index}
className="text-xxxs mr-0.5" className="text-xxxs mr-0.5"
icon={faCircle} icon={faCircle}
/> />
@@ -1,27 +1,26 @@
import React from "react"; import React, { Fragment } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCircle } from "@fortawesome/free-solid-svg-icons"; import { faCircle } from "@fortawesome/free-solid-svg-icons";
import guidGenerator from "../utilities/randomId"; import guidGenerator from "../utilities/randomId";
/** /**
* This function splits the input of a dashboard field into the parts that are inside and outside of ${...} * This function splits the input of a dashboard field into the parts that are inside and outside of ${...}
* @param {string} text - the value of the input in the Dashboard Input Field * @param {string} text - the value of the input in the Dashboard Input Field
* @returns * @returns
*/ */
const findReferences = (text) => { const findReferences = (text) => {
var splitText = text.split('${'); var splitText = text.split("${");
let textArray = [splitText[0]]; let textArray = [splitText[0]];
for (var i = 1; i < splitText.length; i++) { for (var i = 1; i < splitText.length; i++) {
let insideBrackets = "${" + splitText[i].split('}')[0] let insideBrackets = "${" + splitText[i].split("}")[0];
if (splitText[i].includes('}')) { if (splitText[i].includes("}")) {
insideBrackets += "}" insideBrackets += "}";
} }
textArray.push(insideBrackets) textArray.push(insideBrackets);
textArray.push(splitText[i].split('}')[1]) textArray.push(splitText[i].split("}")[1]);
} }
return textArray; return textArray;
} };
/** /**
* This component renders the input fields on the dashboard * This component renders the input fields on the dashboard
@@ -33,7 +32,13 @@ const findReferences = (text) => {
* @param {boolean} obj.blurred - whether the input field should be blurred (behind the gray dots) or not; this can be turned on/off in the dashboard * @param {boolean} obj.blurred - whether the input field should be blurred (behind the gray dots) or not; this can be turned on/off in the dashboard
* @returns * @returns
*/ */
const DashboardInputField = ({index, onChangeHandler, type, value, blurred}) => { const DashboardInputField = ({
index,
onChangeHandler,
type,
value,
blurred,
}) => {
if (type === "varName") { if (type === "varName") {
return ( return (
<div className="flex-col w-full"> <div className="flex-col w-full">
@@ -74,25 +79,51 @@ const DashboardInputField = ({index, onChangeHandler, type, value, blurred}) =>
: "" : ""
} flex flex-row font-mono absolute z-0 ph-no-capture bg-bunker-800 rounded-md text-gray-400 text-md px-2 py-1.5 w-full min-w-16 outline-none focus:ring-4 focus:ring-primary/50 duration-100`} } flex flex-row font-mono absolute z-0 ph-no-capture bg-bunker-800 rounded-md text-gray-400 text-md px-2 py-1.5 w-full min-w-16 outline-none focus:ring-4 focus:ring-primary/50 duration-100`}
> >
{findReferences(value).map((text, id) => {findReferences(value).map((texts, id) => {
id % 2 == 0 || text.length <= 2 if (id % 2 == 0 || texts.length <= 2) {
? <span className="ph-no-capture">{text}</span> return (
: <span className="ph-no-capture text-yellow"> <span className="ph-no-capture" key={id}>
{text.slice(0, 2)} {texts}
<span className="ph-no-capture text-yellow-200/80">
{text.slice(2, text.length - 1)}
</span> </span>
{text.slice(text.length - 1, text.length) == "}" );
? <span className="ph-no-capture text-yellow">{text.slice(text.length - 1, text.length)} </span> }
: <span className="ph-no-capture text-yellow-400">{text.slice(text.length - 1, text.length)} </span>} return (
</span>)} <span
className="ph-no-capture text-yellow"
key={id}
>
{texts.slice(0, 2)}
<span className="ph-no-capture text-yellow-200/80">
{texts.slice(2, texts.length - 1)}
</span>
{texts.slice(
texts.length - 1,
texts.length
) == "}" ? (
<span className="ph-no-capture text-yellow">
{texts.slice(
texts.length - 1,
texts.length
)}{" "}
</span>
) : (
<span className="ph-no-capture text-yellow-400">
{texts.slice(
texts.length - 1,
texts.length
)}{" "}
</span>
)}
</span>
);
})}
</div> </div>
{blurred && ( {blurred && (
<div className="z-20 peer pr-2 bg-bunker-800 group-hover:hidden peer-hover:hidden peer-focus:hidden peer-active:invisible absolute h-9 w-fit max-w-xl rounded-md flex items-center text-gray-400/50 text-clip overflow-hidden"> <div className="z-20 peer pr-2 bg-bunker-800 group-hover:hidden peer-hover:hidden peer-focus:hidden peer-active:invisible absolute h-9 w-fit max-w-xl rounded-md flex items-center text-gray-400/50 text-clip overflow-hidden">
<p className="ml-2"></p> <p className="ml-2"></p>
{value {value
.split("") .split("")
.slice(0,42) .slice(0, 42)
.map(() => ( .map(() => (
<FontAwesomeIcon <FontAwesomeIcon
key={guidGenerator()} key={guidGenerator()}
@@ -1,3 +1,5 @@
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable react/jsx-key */
import React, { useState, Fragment, useEffect } from "react"; import React, { useState, Fragment, useEffect } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
@@ -106,6 +108,7 @@ export default function Navbar({ onButtonPressed }) {
> >
<Menu.Items className="absolute right-0 mt-0.5 w-64 origin-top-right rounded-md bg-bunker border border-mineshaft-700 shadow-lg ring-1 ring-black z-20 ring-opacity-5 focus:outline-none px-2 py-1.5"> <Menu.Items className="absolute right-0 mt-0.5 w-64 origin-top-right rounded-md bg-bunker border border-mineshaft-700 shadow-lg ring-1 ring-black z-20 ring-opacity-5 focus:outline-none px-2 py-1.5">
{supportOptions.map((option) => ( {supportOptions.map((option) => (
// eslint-disable-next-line react/jsx-no-target-blank
<a <a
key={guidGenerator()} key={guidGenerator()}
target="_blank" target="_blank"
+4 -1
View File
@@ -15,7 +15,8 @@ export default function NavHeader({ pageName, isProjectRelated }) {
const [workspaceName, setWorkspaceName] = useState(""); const [workspaceName, setWorkspaceName] = useState("");
const router = useRouter(); const router = useRouter();
useEffect(async () => { useEffect(() => {
(async () => {
let org = await getOrganization({ let org = await getOrganization({
orgId: localStorage.getItem("orgData.id"), orgId: localStorage.getItem("orgData.id"),
}); });
@@ -24,6 +25,8 @@ export default function NavHeader({ pageName, isProjectRelated }) {
workspaceId: router.query.id, workspaceId: router.query.id,
}); });
setWorkspaceName(workspace.name); setWorkspaceName(workspace.name);
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
return ( return (
+6 -2
View File
@@ -10,11 +10,14 @@ export default function DashboardRedirect() {
/** /**
* Here we forward to the default workspace if a user opens this url * Here we forward to the default workspace if a user opens this url
*/ */
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(async () => { useEffect(async () => {
let userWorkspace; let userWorkspace;
try { try {
if (localStorage.getItem("projectData.id")) { if (localStorage.getItem("projectData.id")) {
router.push("/dashboard/" + localStorage.getItem("projectData.id")); router.push(
"/dashboard/" + localStorage.getItem("projectData.id")
);
} else { } else {
const userWorkspaces = await getWorkspaces(); const userWorkspaces = await getWorkspaces();
userWorkspace = userWorkspaces[0]._id; userWorkspace = userWorkspaces[0]._id;
@@ -23,9 +26,10 @@ export default function DashboardRedirect() {
} catch (error) { } catch (error) {
console.log("Error - Not logged in yet"); console.log("Error - Not logged in yet");
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
return <div></div> return <div></div>;
} }
DashboardRedirect.requireAuth = true; DashboardRedirect.requireAuth = true;
+6 -2
View File
@@ -201,7 +201,8 @@ export default function Dashboard() {
); );
}; };
useEffect(async () => { useEffect(() => {
(async () => {
try { try {
let userWorkspaces = await getWorkspaces(); let userWorkspaces = await getWorkspaces();
const listWorkspaces = userWorkspaces.map( const listWorkspaces = userWorkspaces.map(
@@ -231,7 +232,8 @@ export default function Dashboard() {
const user = await getUser(); const user = await getUser();
setIsNew( setIsNew(
(Date.parse(new Date()) - Date.parse(user.createdAt)) / 60000 < (Date.parse(new Date()) - Date.parse(user.createdAt)) /
60000 <
3 3
? true ? true
: false : false
@@ -245,6 +247,8 @@ export default function Dashboard() {
console.log("Error", error); console.log("Error", error);
setData([]); setData([]);
} }
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [env]); }, [env]);
const addRow = () => { const addRow = () => {
+8 -5
View File
@@ -4,7 +4,6 @@ import { useRouter } from "next/router";
const queryString = require("query-string"); const queryString = require("query-string");
import AuthorizeIntegration from "./api/integrations/authorizeIntegration"; import AuthorizeIntegration from "./api/integrations/authorizeIntegration";
export default function Heroku() { export default function Heroku() {
const router = useRouter(); const router = useRouter();
const parsedUrl = queryString.parse(router.asPath.split("?")[1]); const parsedUrl = queryString.parse(router.asPath.split("?")[1]);
@@ -14,22 +13,26 @@ export default function Heroku() {
/** /**
* Here we forward to the default workspace if a user opens this url * Here we forward to the default workspace if a user opens this url
*/ */
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(async () => { useEffect(async () => {
try { try {
if (state == localStorage.getItem("latestCSRFToken")) { if (state == localStorage.getItem("latestCSRFToken")) {
await AuthorizeIntegration({ await AuthorizeIntegration({
workspaceId: localStorage.getItem("projectData.id"), workspaceId: localStorage.getItem("projectData.id"),
code, code,
integration: "heroku" integration: "heroku",
}) });
router.push("/integrations/" + localStorage.getItem("projectData.id")); router.push(
"/integrations/" + localStorage.getItem("projectData.id")
);
} }
} catch (error) { } catch (error) {
console.log("Error - Not logged in yet"); console.log("Error - Not logged in yet");
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
return <div></div> return <div></div>;
} }
Heroku.requireAuth = true; Heroku.requireAuth = true;
+3 -5
View File
@@ -4,12 +4,10 @@ import { useRouter } from "next/router";
export default function Home() { export default function Home() {
const router = useRouter(); const router = useRouter();
useEffect(async () => { useEffect(() => {
router.push("/login"); router.push("/login");
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
return ( return <div className="bg-bunker-800 w-screen"></div>;
<div className="bg-bunker-800 w-screen">
</div>
);
} }
+2 -2
View File
@@ -251,8 +251,8 @@ export default function Integrations() {
<div className="flex flex-col max-w-5xl justify-center bg-white/5 p-6 rounded-md mx-6 mt-8"> <div className="flex flex-col max-w-5xl justify-center bg-white/5 p-6 rounded-md mx-6 mt-8">
<div className="relative px-4 flex flex-col text-gray-400 items-center justify-center"> <div className="relative px-4 flex flex-col text-gray-400 items-center justify-center">
<div className="mb-1"> <div className="mb-1">
You don't have any integrations set up yet. You {"don't"} have any integrations set up
When you do, they will appear here. yet. When you do, they will appear here.
</div> </div>
<div className=""> <div className="">
To start, click on any of the options below. To start, click on any of the options below.
+2 -2
View File
@@ -13,8 +13,8 @@ export default function Activity() {
<p className="mt-2 mb-1 text-xl">Your invite has expired. </p> <p className="mt-2 mb-1 text-xl">Your invite has expired. </p>
<p className="text-xl">Ask the administrator for a new one.</p> <p className="text-xl">Ask the administrator for a new one.</p>
<p className="text-md mt-8 text-gray-600 max-w-sm text-center"> <p className="text-md mt-8 text-gray-600 max-w-sm text-center">
Note: If it still doesn't work, please reach out to us at Note: If it still {"doesn't work"}, please reach out to us
support@infisical.com at support@infisical.com
</p> </p>
</div> </div>
</div> </div>
+2 -2
View File
@@ -70,8 +70,8 @@ export default function SettingsBilling() {
Usage & Billing Usage & Billing
</p> </p>
<p className="font-normal mr-4 text-gray-400 text-base"> <p className="font-normal mr-4 text-gray-400 text-base">
View and manage your organization's subscription View and manage your {"organization's"}{" "}
here. subscription here.
</p> </p>
</div> </div>
</div> </div>
+1
View File
@@ -165,6 +165,7 @@ export default function SettingsBasic() {
For more guidance, including code For more guidance, including code
snipets for various languages and snipets for various languages and
frameworks, see{" "} frameworks, see{" "}
{/* eslint-disable-next-line react/jsx-no-target-blank */}
<a <a
href="https://infisical.com/docs/getting-started/introduction" href="https://infisical.com/docs/getting-started/introduction"
target="_blank" target="_blank"
+3 -3
View File
@@ -253,7 +253,7 @@ export default function SignUp() {
const step1 = ( const step1 = (
<div className="bg-bunker w-full max-w-md mx-auto h-7/12 py-8 md:px-6 mx-1 mb-48 md:mb-16 rounded-xl drop-shadow-xl"> <div className="bg-bunker w-full max-w-md mx-auto h-7/12 py-8 md:px-6 mx-1 mb-48 md:mb-16 rounded-xl drop-shadow-xl">
<p className="text-4xl font-semibold flex justify-center text-transparent bg-clip-text bg-gradient-to-br from-sky-400 to-primary"> <p className="text-4xl font-semibold flex justify-center text-transparent bg-clip-text bg-gradient-to-br from-sky-400 to-primary">
Let's get started {"Let'"}s get started
</p> </p>
<div className="flex flex-col items-center justify-center w-full md:pb-2 max-h-24 max-w-md mx-auto pt-2"> <div className="flex flex-col items-center justify-center w-full md:pb-2 max-h-24 max-w-md mx-auto pt-2">
<Link href="/login"> <Link href="/login">
@@ -300,7 +300,7 @@ export default function SignUp() {
const step2 = ( const step2 = (
<div className="bg-bunker w-max mx-auto h-7/12 pt-10 pb-4 px-8 rounded-xl drop-shadow-xl mb-64 md:mb-16"> <div className="bg-bunker w-max mx-auto h-7/12 pt-10 pb-4 px-8 rounded-xl drop-shadow-xl mb-64 md:mb-16">
<p className="text-l flex justify-center text-gray-400"> <p className="text-l flex justify-center text-gray-400">
We've sent a verification email to{" "} {"We've"} sent a verification email to{" "}
</p> </p>
<p className="text-l flex justify-center font-semibold my-2 text-gray-400"> <p className="text-l flex justify-center font-semibold my-2 text-gray-400">
{email}{" "} {email}{" "}
@@ -326,7 +326,7 @@ export default function SignUp() {
{codeError && ( {codeError && (
<Error text="Oops. Your code is wrong. Please try again." /> <Error text="Oops. Your code is wrong. Please try again." />
)} )}
<div className="flex max-w-min flex-col items-center justify-center md:p-2 max-h-24 max-w-md mx-auto text-lg px-4 mt-4 mb-2"> <div className="flex flex-col items-center justify-center md:p-2 max-h-24 max-w-md mx-auto text-lg px-4 mt-4 mb-2">
<Button <Button
text="Verify" text="Verify"
onButtonPressed={incrementStep} onButtonPressed={incrementStep}
+1
View File
@@ -85,6 +85,7 @@ export default function Users() {
const [userList, setUserList] = useState(); const [userList, setUserList] = useState();
const [orgUserList, setOrgUserList] = useState([]); const [orgUserList, setOrgUserList] = useState([]);
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(async () => { useEffect(async () => {
const user = await getUser(); const user = await getUser();
setPersonalEmail(user.email); setPersonalEmail(user.email);