From 78a61b934e614f9a24a2aed5c1291684278f06e3 Mon Sep 17 00:00:00 2001 From: Aarni Halinen Date: Sun, 28 Mar 2021 22:55:51 +0300 Subject: [PATCH] fix few lint warnings --- src/components/Widgets/MarkdownEditorWidget.tsx | 2 +- src/components/Widgets/SectionDividerWidget.tsx | 1 - .../SignupQuestionsWidget/OptionsWidget.tsx | 1 - src/models/Signup.ts | 2 +- src/pages/_document.tsx | 4 ++-- src/utils/auth.ts | 15 +++++---------- src/utils/regexes.ts | 1 + src/views/SignUpPage/SignUpPageView.tsx | 4 ++-- src/views/admin/AdminCreateCommon.tsx | 12 ++++++------ 9 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/components/Widgets/MarkdownEditorWidget.tsx b/src/components/Widgets/MarkdownEditorWidget.tsx index 1b843c6..b2b3554 100644 --- a/src/components/Widgets/MarkdownEditorWidget.tsx +++ b/src/components/Widgets/MarkdownEditorWidget.tsx @@ -5,7 +5,7 @@ import { WidgetProps } from "react-jsonschema-form"; import MarkdownStyles from "@views/common/MarkdownStyles"; type MarkdownEditorWidgetProps = Omit & { - options: any; + options: unknown; }; const Container = styled.div` diff --git a/src/components/Widgets/SectionDividerWidget.tsx b/src/components/Widgets/SectionDividerWidget.tsx index 4892c25..76c7165 100644 --- a/src/components/Widgets/SectionDividerWidget.tsx +++ b/src/components/Widgets/SectionDividerWidget.tsx @@ -13,7 +13,6 @@ const getIconByLabel = (label: string) => { if (label === "English") { return ; } - console.error(`No icon found for label: ${label}`); return null; }; diff --git a/src/components/Widgets/SignupQuestionsWidget/OptionsWidget.tsx b/src/components/Widgets/SignupQuestionsWidget/OptionsWidget.tsx index 098a5da..487c05b 100644 --- a/src/components/Widgets/SignupQuestionsWidget/OptionsWidget.tsx +++ b/src/components/Widgets/SignupQuestionsWidget/OptionsWidget.tsx @@ -46,7 +46,6 @@ class OptionsWidget extends React.Component { handleRequiredChange = (questions: Question[], index: number): React.ChangeEventHandler => (event) => { const { onChange } = this.props; const val: boolean = event.target.checked; - console.log(val); // eslint-disable-next-line no-param-reassign questions[index].required = val; onChange(questions); diff --git a/src/models/Signup.ts b/src/models/Signup.ts index c6588d3..6e301e1 100644 --- a/src/models/Signup.ts +++ b/src/models/Signup.ts @@ -20,7 +20,7 @@ export interface SignupForm { title?: string; type: string; required: string[]; - properties: any; + properties: unknown; minProperties?: number; }; } diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index dc3ef7f..19753e2 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -6,7 +6,7 @@ import { ServerStyleSheet } from "styled-components"; import Favicons from "@components/Favicons"; import HTMLLogo from "@components/HTMLLogo"; -export default class MyDocument extends Document { +export default class MyDocument extends Document<{ styleTags: unknown }> { static async getInitialProps(ctx: DocumentContext) { const sheet = new ServerStyleSheet(); const originalRenderPage = ctx.renderPage; @@ -30,7 +30,7 @@ export default class MyDocument extends Document { } render() { - const { styleTags } = this.props as any; + const { styleTags } = this.props; return ( diff --git a/src/utils/auth.ts b/src/utils/auth.ts index d0c5e85..875bf14 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -5,16 +5,11 @@ const tokenUrl = `${process.env.NEXT_PUBLIC_API_URL}/api-token-auth/`; const checkUrl = `${process.env.NEXT_PUBLIC_API_URL}/api-token-verify/`; export async function generateToken(username: string, password: string): Promise { - try { - const resp = await axios.post(tokenUrl, { - username, - password, - }); - return resp.data.token; - } catch (err) { - console.error(err); - throw err; - } + const resp = await axios.post(tokenUrl, { + username, + password, + }); + return resp.data.token; } export function setTokenCookie(token: string) { diff --git a/src/utils/regexes.ts b/src/utils/regexes.ts index b1b17f3..3a5f875 100644 --- a/src/utils/regexes.ts +++ b/src/utils/regexes.ts @@ -1,3 +1,4 @@ // HTML 5 email regex +// eslint-disable-next-line import/prefer-default-export export const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; // export const EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ diff --git a/src/views/SignUpPage/SignUpPageView.tsx b/src/views/SignUpPage/SignUpPageView.tsx index 07a90c9..51f6165 100644 --- a/src/views/SignUpPage/SignUpPageView.tsx +++ b/src/views/SignUpPage/SignUpPageView.tsx @@ -19,8 +19,8 @@ interface SignUpPageViewProps { signUpForm: SignupForm; formData: any; statusMessage: string; - onChange: (e: IChangeEvent, es?: ErrorSchema) => any; - onSubmit: (e: ISubmitEvent) => any; + onChange: (e: IChangeEvent, es?: ErrorSchema) => unknown; + onSubmit: (e: ISubmitEvent) => unknown; } const renderList = (signUpForm: SignupForm) => ( diff --git a/src/views/admin/AdminCreateCommon.tsx b/src/views/admin/AdminCreateCommon.tsx index 7b3284e..a7d4c21 100644 --- a/src/views/admin/AdminCreateCommon.tsx +++ b/src/views/admin/AdminCreateCommon.tsx @@ -38,14 +38,14 @@ type AdminCreateCommonProps = { title: string; formData?: FormTypes; schema: { - [name: string]: any; + [name: string]: unknown; }; UISchema: { - [name: string]: any; + [name: string]: unknown; }; - onChange?: (e: IChangeEvent, es?: ErrorSchema) => any; + onChange?: (e: IChangeEvent, es?: ErrorSchema) => unknown; onFocus: (id: string, value: string | number | boolean) => void; - onSubmit: (e: ISubmitEvent) => any; + onSubmit: (e: ISubmitEvent) => unknown; statusMessage: string; error: string; widgets: { @@ -65,9 +65,9 @@ const AdminCreateCommon: React.FC = ({ error, widgets, }) => { - const onError = (data: any) => { + const onError = (data: unknown) => { console.error("error, data:"); - console.log(data); + console.error(data); }; return (