Skip to content

Commit

Permalink
fix all eslint problems
Browse files Browse the repository at this point in the history
  • Loading branch information
tibuurcio committed Jan 16, 2024
1 parent 8fdc4db commit 9a30d24
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 39 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ module.exports = {
extraFileExtensions: [".md", ".css"],
},
plugins: ["react", "react-hooks"],
rules: {},
ignorePatterns: [".eslintrc.js"],
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
},
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"wait-on": "7.2.0"
},
"scripts": {
"start": "npm run storybook",
"storybook": "storybook dev -p 6006",
"test-storybook": "test-storybook",
"test-storybook:ci": "concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"npm run build-storybook --quiet && NODE_NO_WARNINGS=1 npx http-server storybook-static --port 6006 --silent\" \"wait-on tcp:127.0.0.1:6006 && npm run test-storybook\"",
Expand All @@ -65,7 +66,7 @@
},
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
"npm lint --fix",
"npm run lint --fix",
"prettier --write"
],
"*.{json,yml,md}": [
Expand Down
5 changes: 2 additions & 3 deletions src/components/data-display/List/List.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from "react";
import { List as AntList , type ListProps as AntListProps } from "antd";

import { List as AntList, type ListProps as AntListProps } from "antd";

export interface IListProps<T> extends AntListProps<T> {}

export const List = <T extends any>(props: IListProps<T>) => (
export const List = <T,>(props: IListProps<T>) => (
<>
<AntList {...props} />
</>
Expand Down
14 changes: 9 additions & 5 deletions src/components/data-entry/AutoComplete/AutoComplete.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, { useState } from "react";

import { AutoComplete , type IAutoCompleteProps } from "src/components/data-entry/AutoComplete/AutoComplete";

import { type Meta , type StoryObj } from "@storybook/react";
import {
AutoComplete,
type IAutoCompleteProps,
} from "src/components/data-entry/AutoComplete/AutoComplete";

import { type Meta, type StoryObj } from "@storybook/react";

const meta: Meta<typeof AutoComplete> = {
title: "Aquarium/Data Entry/AutoComplete",
Expand All @@ -30,13 +32,15 @@ const PrimaryTemplate = (args: IAutoCompleteProps) => {
const [value, setValue] = useState<IAutoCompleteProps["value"]>("");
const [options, setOptions] = useState<IAutoCompleteProps["options"]>([]);

const onSearch = (text: string) => { setOptions(getPanelValue(text)); };
const onSearch = (text: string) => {
setOptions(getPanelValue(text));
};
const onSelect = (value: string) => {
console.log("you selected value: " + value);
};

const getPanelValue = (searchText: string): IAutoCompleteProps["options"] => {
if (!searchText) return [];
if (searchText === "") return [];
return baseOptions.filter((o) =>
o.label.toLowerCase().includes(searchText.toLowerCase()),
);
Expand Down
11 changes: 7 additions & 4 deletions src/components/data-entry/Input/Input.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Input } from "src/components/data-entry/Input/Input";
import { type Meta , type StoryObj } from "@storybook/react";

import { type Meta, type StoryObj } from "@storybook/react";

const meta: Meta<typeof Input> = {
title: "Aquarium/Data Entry/Input",
Expand All @@ -26,8 +25,12 @@ const meta: Meta<typeof Input> = {
suffix: undefined,
type: "text",
value: "",
onChange: (e) => { console.log("Input changed: " + e.target.value); },
onPressEnter: (e) => { console.log("Enter key pressed: " + e); },
onChange: (e) => {
console.log("Input changed: " + e.target.value);
},
onPressEnter: (e) => {
console.log("Enter key pressed: " + String(e));
},
},

argTypes: {
Expand Down
16 changes: 11 additions & 5 deletions src/components/data-entry/InputNumber/InputNumber.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Meta , type StoryObj } from "@storybook/react";
import { type Meta, type StoryObj } from "@storybook/react";

import { InputNumber } from "src/components/data-entry/InputNumber/InputNumber";

Expand Down Expand Up @@ -30,9 +30,15 @@ const meta: Meta<typeof InputNumber> = {
step: 1,
stringMode: false,
value: undefined,
onChange: (value) => { alert("InputNumber changed: " + value); },
onPressEnter: (e) => { console.log("Enter key pressed:", e); },
onStep: (value, info) => { console.log("Step:", value, info); },
onChange: (value) => {
alert("InputNumber changed: " + value);
},
onPressEnter: (e) => {
console.log("Enter key pressed:", e);
},
onStep: (value, info) => {
console.log("Step:", value, info);
},
},

argTypes: {
Expand Down Expand Up @@ -133,7 +139,7 @@ export const MinMaxConstraints: Story = {
},
};

export const Step0_5: Story = {
export const Step05: Story = {
args: {
step: 0.5,
},
Expand Down
22 changes: 14 additions & 8 deletions src/components/feedback/LoadingModal/LoadingModal.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { useState } from "react";

import { type Meta , type StoryObj } from "@storybook/react";
import { type Meta, type StoryObj } from "@storybook/react";

import { Button } from "src/components/general/Button/Button";
import { LoadingModal , type ILoadingModalProps } from "src/components/feedback/LoadingModal/LoadingModal";

import {
LoadingModal,
type ILoadingModalProps,
} from "src/components/feedback/LoadingModal/LoadingModal";

const meta: Meta<typeof LoadingModal> = {
title: "Aquarium/Feedback/Loading Modal",
Expand Down Expand Up @@ -57,24 +59,28 @@ const PrimaryTemplate = (args: ILoadingModalProps<unknown>) =>
BaseTemplate(
args,
async () =>
await new Promise<boolean>((resolve, reject) => {
setTimeout(() => { resolve(true); }, 1000);
await new Promise<boolean>((resolve, _reject) => {
setTimeout(() => {
resolve(true);
}, 1000);
}),
);

const ErrorTemplate = (args: ILoadingModalProps<unknown>) =>
BaseTemplate(
args,
async () =>
await new Promise<boolean>((resolve, reject) => {
setTimeout(() => { reject(true); }, 1000);
await new Promise<boolean>((_resolve, reject) => {
setTimeout(() => {
reject(new Error());
}, 1000);
}),
);

export const Primary: Story = {
render: PrimaryTemplate,
};

export const Error: Story = {
export const ErrorState: Story = {
render: ErrorTemplate,
};
5 changes: 3 additions & 2 deletions src/components/feedback/LoadingModal/LoadingModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useInitData } from "src/hooks/useInitData";
import { type IModalProps , Modal } from "src/components/feedback/Modal/Modal";
import { type IModalProps, Modal } from "src/components/feedback/Modal/Modal";
import { Skeleton } from "src/components/feedback/Skeleton/Skeleton";

import { Result } from "src/components/feedback/Result/Result";
Expand All @@ -13,7 +13,8 @@ export interface ILoadingModalProps<Data>

export function LoadingModal<Data>(props: ILoadingModalProps<Data>) {
const [isInitLoading, isInitError, initData] = useInitData(props.fetchData);
if (initData) debugger;
// eslint-disable-next-line no-debugger
if (initData !== undefined) debugger;

return (
<>
Expand Down
7 changes: 3 additions & 4 deletions src/components/feedback/Message/Message.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import { message , type MessageArgsProps as AntMessageArgsProps } from "antd";

import { message, type MessageArgsProps as AntMessageArgsProps } from "antd";

export interface IMessageProps extends AntMessageArgsProps {
children: React.ReactNode;
Expand All @@ -9,8 +8,8 @@ export interface IMessageProps extends AntMessageArgsProps {
export const Message = (props: IMessageProps) => {
const [messageApi, contextHolder] = message.useMessage();

const open = (): void => {
messageApi.open({ ...props });
const open = () => {
void messageApi.open({ ...props });
};

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/Flex/Flex.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { type Meta , type StoryObj } from "@storybook/react";
import { type Meta, type StoryObj } from "@storybook/react";

import { Flex } from "src/components/layout/Flex/Flex";

Expand All @@ -22,7 +22,7 @@ const meta: Meta<typeof Flex> = {
style={{
width: 20,
height: 54,
backgroundColor: i % 2 ? "#1677ff" : "#1677ffbf",
backgroundColor: i % 2 === 0 ? "#1677ff" : "#1677ffbf",
}}
/>
))}
Expand Down
3 changes: 2 additions & 1 deletion src/components/layout/Grid/Grid.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import { Grid as AntGrid } from "antd";
// import { Grid as AntGrid } from "antd";
// import { GridProps as AntGridProps } from "antd";

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface IGridProps /* extends AntGridProps */ {}

export const Grid = (props: IGridProps) => {
Expand Down
6 changes: 4 additions & 2 deletions src/components/navigation/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import { Dropdown as AntDropdown , type DropdownProps as AntDropdownProps } from "antd";

import {
Dropdown as AntDropdown,
type DropdownProps as AntDropdownProps,
} from "antd";

export interface IDropdownProps extends AntDropdownProps {}

Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useMount.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useEffect } from "react";

export const useMount = (mount: () => void) => { useEffect(mount, []); };
export const useMount = (mount: () => void) => {
useEffect(mount, []);
};

0 comments on commit 9a30d24

Please sign in to comment.