Skip to content

Commit

Permalink
fix(eslint): --fix or ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Sep 6, 2023
1 parent e68e159 commit e68ef29
Show file tree
Hide file tree
Showing 83 changed files with 267 additions and 271 deletions.
2 changes: 2 additions & 0 deletions cypress/e2e/branch-select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("Info pages", () => {
it("can select a branch", () => {
cy.getBySel("branchSelect").click();
cy.getBySel("branchOption").should("have.length", 4);
// eslint-disable-next-line cypress/unsafe-to-chain-command
cy.getBySel("branchOption")
.eq(0)
.click()
Expand All @@ -29,6 +30,7 @@ describe("Info pages", () => {
});

cy.getBySel("branchSelect").click();
// eslint-disable-next-line cypress/unsafe-to-chain-command
cy.getBySel("branchOption")
.eq(1)
.click()
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/register.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe("Register", () => {
);

cy.get("#postalCode").clear();
// eslint-disable-next-line cypress/unsafe-to-chain-command
cy.get("#postalCode").type("0977").blur();
cy.getBySel("postal-city-preview").should("contain", "Oslo");
cy.getBySel("submit-button").should("not.be.disabled");
Expand Down Expand Up @@ -144,6 +145,7 @@ describe("Register", () => {

it("cannot register when passord is invalid", () => {
cy.get("#password").clear();
// eslint-disable-next-line cypress/unsafe-to-chain-command
cy.get("#password").type("pass").blur();
cy.getBySel("error-message").should("be.visible");
cy.getBySel("submit-button").should("be.disabled");
Expand Down
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,11 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^48.0.1",
"husky": ">=6",
"lint-staged": ">=10",
"prettier": "^3.0.3",
"pretty-quick": "^3.1.3",
"typescript": "^4.9.4"
},
"browserslist": [
"defaults",
"not IE 11"
],
"lint-staged": {
"*.{js,ts,tsx,md,json,yml,css}": "yarn prettier:check"
}
]
}
4 changes: 2 additions & 2 deletions src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosError, AxiosResponse } from "axios";

import { apiPath, getHeaders } from "./apiRequest";
import { fetchNewTokens } from "./token";
import { apiPath, getHeaders } from "api/apiRequest";
import { fetchNewTokens } from "api/token";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const get = async <T = any>(
Expand Down
4 changes: 2 additions & 2 deletions src/api/apiRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getAccessToken, haveAccessToken } from "./token";
import BL_CONFIG from "../utils/bl-config";
import { getAccessToken, haveAccessToken } from "api/token";
import BL_CONFIG from "utils/bl-config";

export const apiPath = (collection: string, query?: string) => {
const path = BL_CONFIG.api.basePath;
Expand Down
3 changes: 1 addition & 2 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { haveAccessToken, removeTokens, getAccessTokenBody } from "api/token";
import { UserPermission } from "utils/types";

import { haveAccessToken, removeTokens, getAccessTokenBody } from "./token";

export const isLoggedIn = () => haveAccessToken();

export const logout = () => removeTokens();
Expand Down
6 changes: 3 additions & 3 deletions src/api/login.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { add } from "./api";
import { parseTokensFromResponseDataAndStore } from "./token";
import BL_CONFIG from "../utils/bl-config";
import { add } from "api/api";
import { parseTokensFromResponseDataAndStore } from "api/token";
import BL_CONFIG from "utils/bl-config";

export const login = async (username: string, password: string) => {
const apiResponse = await add(BL_CONFIG.login.local.url, {
Expand Down
5 changes: 2 additions & 3 deletions src/api/token.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import axios from "axios";
import { decodeToken } from "react-jwt";

import { add, get, remove } from "api/storage";
import BL_CONFIG from "utils/bl-config";
import { AccessToken } from "utils/types";

import { add, get, remove } from "./storage";
import BL_CONFIG from "../utils/bl-config";

const accessTokenName = BL_CONFIG.token.accessToken;
const refreshTokenName = BL_CONFIG.token.refreshToken;

Expand Down
7 changes: 3 additions & 4 deletions src/components/BranchSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import useSWR, { SWRResponse } from "swr";

import { fetcher } from "api/requests";
import { add, get } from "api/storage";
import { setCart, setDeliveryMethod } from "redux/cart";
import { useAppSelector, useAppDispatch } from "redux/hooks";
import { selectBranch, setSelectedBranch } from "redux/selectedBranch";
import { setSelectedCustomerItemActions } from "redux/selectedCustomerItemActions";
import { setSelectedSubjects } from "redux/selectedSubjects";
import BL_CONFIG from "utils/bl-config";

import { setCart, setDeliveryMethod } from "../redux/cart";
import { setSelectedCustomerItemActions } from "../redux/selectedCustomerItemActions";
import { setSelectedSubjects } from "../redux/selectedSubjects";

export const branchListUrl = `${BL_CONFIG.api.basePath}branches?og=name&active=true&sort=name`;

const BranchSelect = ({ isNav }: { isNav?: boolean }) => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/CustomerItemOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ import moment from "moment";
import { useRouter } from "next/router";
import React, { useState } from "react";

import { setCart } from "../redux/cart";
import { useAppDispatch, useAppSelector } from "../redux/hooks";
import { setCart } from "redux/cart";
import { useAppDispatch, useAppSelector } from "redux/hooks";
import {
CustomerItemAction,
selectCustomerItemActions,
setSelectedCustomerItemActions,
} from "../redux/selectedCustomerItemActions";
} from "redux/selectedCustomerItemActions";
import {
generateCartItemsFromCustomerItemActions,
getExtendTime,
} from "../utils/cartUtils";
} from "utils/cartUtils";

const calculateMaxDeadline = (): string => {
const now = moment();
Expand Down
6 changes: 3 additions & 3 deletions src/components/DynamicLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Link as MuiLink, LinkProps as MuiLinkProps } from "@mui/material";
import NextLink, { LinkProps as NextLinkProps } from "next/link";
import { ForwardedRef, forwardRef, useEffect, useState } from "react";

import { isLoggedIn } from "../api/auth";
import { getAccessToken, getRefreshToken } from "../api/token";
import BL_CONFIG from "../utils/bl-config";
import { isLoggedIn } from "api/auth";
import { getAccessToken, getRefreshToken } from "api/token";
import BL_CONFIG from "utils/bl-config";

type CustomNextLinkProps = Omit<NextLinkProps, "href"> & {
_href: NextLinkProps["href"];
Expand Down
4 changes: 2 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import moment from "moment";
import Image from "next/image";
import React from "react";

import DynamicLink from "./DynamicLink";
import ContactInfo from "./info/ContactInfo";
import DynamicLink from "components/DynamicLink";
import ContactInfo from "components/info/ContactInfo";

export default function Footer() {
return (
Expand Down
8 changes: 4 additions & 4 deletions src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import Typography from "@mui/material/Typography";
import Image from "next/image";
import React from "react";

import BranchSelect from "./BranchSelect";
import DynamicLink from "./DynamicLink";
import DropDownMenu from "./SideMenuDrawer";
import BL_CONFIG from "../utils/bl-config";
import BranchSelect from "components/BranchSelect";
import DynamicLink from "components/DynamicLink";
import DropDownMenu from "components/SideMenuDrawer";
import BL_CONFIG from "utils/bl-config";

interface TabLinkProps {
title: string;
Expand Down
16 changes: 10 additions & 6 deletions src/components/OrderHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Button from "@mui/material/Button";
import moment from "moment";
import React, { useState } from "react";

import { get } from "../api/api";
import { get } from "api/api";

// fetchPayments(orders);
// types are from a business POV
Expand Down Expand Up @@ -63,11 +63,13 @@ const OrderHistory = ({ orders }: { orders: Order[] }) => {
const data = await get(`orders/${orderId}/receipt`);
const receiptData = data.data.data[0];
const byteCharacters = atob(receiptData.content);
const byteNumbers: number[] = Array.from({ length: byteCharacters.length });
const byteNumbers = Array.from({ length: byteCharacters.length });
for (let index = 0; index < byteNumbers.length; index++) {
byteNumbers[index] = byteCharacters.codePointAt(index) as number;
byteNumbers[index] = byteCharacters.codePointAt(index);
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const blob = new Blob([new Uint8Array(byteNumbers)], {
type: "application/pdf",
});
Expand Down Expand Up @@ -259,15 +261,17 @@ const OrderHistory = ({ orders }: { orders: Order[] }) => {
</TableCell>
</TableRow>
)}
{/** @ts-ignore*/}

{/** eslint-disable-next-line @typescript-eslint/ban-ts-comment
@ts-ignore */}
{orderItem.info?.["amountLeftToPay"] && (
<TableRow>
<TableCell align="center">
<b>Betal senere</b>
</TableCell>
<TableCell align="center">
{}
{/** @ts-ignore*/}
{/** eslint-disable-next-line @typescript-eslint/ban-ts-comment
@ts-ignore */}
{orderItem.info["amountLeftToPay"]} kr
</TableCell>
</TableRow>
Expand Down
5 changes: 2 additions & 3 deletions src/components/SideMenuDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import { useRouter } from "next/router";
import React, { useState, KeyboardEvent, MouseEvent, ReactNode } from "react";

import { isLoggedIn, logout } from "api/auth";

import DynamicLink from "./DynamicLink";
import BL_CONFIG from "../utils/bl-config";
import DynamicLink from "components/DynamicLink";
import BL_CONFIG from "utils/bl-config";

interface DrawerLinkProps {
title: string;
Expand Down
12 changes: 6 additions & 6 deletions src/components/SubjectSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import Typography from "@mui/material/Typography";
import { useRouter } from "next/router";
import React, { useState } from "react";

import FixedSuccessButton from "./FixedSuccessButton";
import { setCart } from "../redux/cart";
import { useAppDispatch, useAppSelector } from "../redux/hooks";
import { selectBranch } from "../redux/selectedBranch";
import { selectSubjects, setSelectedSubjects } from "../redux/selectedSubjects";
import { generateCartItemsFromSubjects } from "../utils/cartUtils";
import FixedSuccessButton from "components/FixedSuccessButton";
import { setCart } from "redux/cart";
import { useAppDispatch, useAppSelector } from "redux/hooks";
import { selectBranch } from "redux/selectedBranch";
import { selectSubjects, setSelectedSubjects } from "redux/selectedSubjects";
import { generateCartItemsFromSubjects } from "utils/cartUtils";

const SubjectCheckbox = ({ subject }: { subject: string }) => {
const dispatch = useAppDispatch();
Expand Down
14 changes: 7 additions & 7 deletions src/components/cart/Cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { useRouter } from "next/router";

import BackButton from "./BackButton";
import CartTableHeader from "./CartTableHeader";
import CartTableRow from "./CartTableRow";
import { isLoggedIn } from "../../api/auth";
import { selectCartItems } from "../../redux/cart";
import { useAppSelector } from "../../redux/hooks";
import FixedSuccessButton from "../FixedSuccessButton";
import { isLoggedIn } from "api/auth";
import BackButton from "components/cart/BackButton";
import CartTableHeader from "components/cart/CartTableHeader";
import CartTableRow from "components/cart/CartTableRow";
import FixedSuccessButton from "components/FixedSuccessButton";
import { selectCartItems } from "redux/cart";
import { useAppSelector } from "redux/hooks";

const Cart = () => {
const cartItems = useAppSelector(selectCartItems);
Expand Down
11 changes: 6 additions & 5 deletions src/components/cart/CartTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { BranchItem, OrderItemType } from "@boklisten/bl-model";
import { TableCell, TableRow, Tooltip } from "@mui/material";
import moment from "moment";

import RemoveCartItemButton from "./RemoveCartItemButton";
import SelectDeadline from "./SelectDeadline";
import { CartItem } from "../../redux/cart";
import { useAppSelector } from "../../redux/hooks";
import { selectSubjects } from "../../redux/selectedSubjects";
import RemoveCartItemButton from "components/cart/RemoveCartItemButton";
import SelectDeadline from "components/cart/SelectDeadline";
import { CartItem } from "redux/cart";
import { useAppSelector } from "redux/hooks";
import { selectSubjects } from "redux/selectedSubjects";

const getReadableOrderType = (orderItemType: OrderItemType) =>
orderItemType === "extend" ? "forlenging" : "utkjøp";
Expand All @@ -18,6 +18,7 @@ const CartTableRow = ({ cartItem }: { cartItem: CartItem }) => {
selectedSubjects.includes(category),
) ?? [];

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
/* @ts-ignore */
const amountLeftToPay = cartItem.orderItem.info?.amountLeftToPay ?? 0;

Expand Down
4 changes: 2 additions & 2 deletions src/components/cart/RemoveCartItemButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import CancelIcon from "@mui/icons-material/Cancel";
import { IconButton } from "@mui/material";

import { CartItem, removeCartItem } from "../../redux/cart";
import { useAppDispatch } from "../../redux/hooks";
import { CartItem, removeCartItem } from "redux/cart";
import { useAppDispatch } from "redux/hooks";

const RemoveCartItemButton = ({ cartItem }: { cartItem: CartItem }) => {
const dispatch = useAppDispatch();
Expand Down
6 changes: 3 additions & 3 deletions src/components/cart/SelectDeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Branch, Period } from "@boklisten/bl-model";
import { FormControl, InputLabel, MenuItem, Select } from "@mui/material";
import moment from "moment";

import { CartItem, updatePeriod } from "../../redux/cart";
import { useAppDispatch } from "../../redux/hooks";
import { CartItem, updatePeriod } from "redux/cart";
import { useAppDispatch } from "redux/hooks";
import {
getOrderItemTypeFromBranch,
getPartlyPaymentPeriodDate,
getRentPeriodDate,
} from "../../utils/cartUtils";
} from "utils/cartUtils";

const getDeadline = (period: Period, branch: Branch) => {
const deadline =
Expand Down
4 changes: 2 additions & 2 deletions src/components/checkout/BranchDelivery.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Typography from "@mui/material/Typography";
import { Dispatch, SetStateAction, useEffect } from "react";

import { selectCartItems, setDeliveryPrice } from "../../redux/cart";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { selectCartItems, setDeliveryPrice } from "redux/cart";
import { useAppDispatch, useAppSelector } from "redux/hooks";

const BranchDelivery = ({
setWait,
Expand Down
12 changes: 6 additions & 6 deletions src/components/checkout/CheckoutStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { UserDetail } from "@boklisten/bl-model";
import { Alert } from "@mui/material";
import { Dispatch, SetStateAction, useEffect, useState } from "react";

import { CheckoutSteps } from "./CheckoutStepper";
import DeliveryStep from "./DeliveryStep";
import PaymentStep from "./PaymentStep";
import TermsAndConditionsStep from "./TermsAndConditionsStep";
import { get } from "../../api/api";
import { getAccessTokenBody } from "../../api/token";
import { get } from "api/api";
import { getAccessTokenBody } from "api/token";
import { CheckoutSteps } from "components/checkout/CheckoutStepper";
import DeliveryStep from "components/checkout/DeliveryStep";
import PaymentStep from "components/checkout/PaymentStep";
import TermsAndConditionsStep from "components/checkout/TermsAndConditionsStep";

const CheckoutStep = ({
step,
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkout/CheckoutStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import { useState } from "react";

import CheckoutStep from "./CheckoutStep";
import CheckoutStep from "components/checkout/CheckoutStep";

export type CheckoutSteps = "tos" | "payment" | "delivery" | undefined;

Expand Down
8 changes: 4 additions & 4 deletions src/components/checkout/DeliveryStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import Tab from "@mui/material/Tab";
import Tabs from "@mui/material/Tabs";
import { Dispatch, SetStateAction, useEffect, useState } from "react";

import BranchDelivery from "./BranchDelivery";
import PostalDelivery from "./PostalDelivery";
import BranchDelivery from "components/checkout/BranchDelivery";
import PostalDelivery from "components/checkout/PostalDelivery";
import {
selectCartItems,
selectDeliveryMethod,
setDeliveryMethod,
} from "../../redux/cart";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
} from "redux/cart";
import { useAppDispatch, useAppSelector } from "redux/hooks";

type DeliveryMethods = {
byMail: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/components/checkout/PaymentStep.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DibsPayment from "./DibsPayment";
import PaymentSummary from "./PaymentSummary";
import DibsPayment from "components/checkout/DibsPayment";
import PaymentSummary from "components/checkout/PaymentSummary";

const PaymentStep = () => {
return (
Expand Down
Loading

0 comments on commit e68ef29

Please sign in to comment.