From a5e05284d029e953153d48fa325bbc4471652378 Mon Sep 17 00:00:00 2001 From: Fabricio Silva Date: Sun, 2 Jul 2023 13:19:03 +0100 Subject: [PATCH] chore(web): add ignore pattern to eslint for the unused-vars rule (#965) * allow eslint ununsed vars and params if starts with _ * comment rests of unused code on Irc.tsx * fix some eslint warn about unused code --- web/.eslintrc.js | 15 +++++++- web/src/screens/settings/Application.tsx | 38 ++++++++++---------- web/src/screens/settings/Feed.tsx | 2 +- web/src/screens/settings/Irc.tsx | 46 ++++++++++++------------ 4 files changed, 57 insertions(+), 44 deletions(-) diff --git a/web/.eslintrc.js b/web/.eslintrc.js index 078f8b1..e19530a 100644 --- a/web/.eslintrc.js +++ b/web/.eslintrc.js @@ -22,6 +22,13 @@ module.exports = { indent: ["warn", 2], // Don't enforce any particular brace style curly: "off", + // Allow only vars starting with _ to be ununsed vars + "no-unused-vars": ["warn", { + "varsIgnorePattern": "^_", + "argsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_", + "ignoreRestSiblings": true + }], // Let's keep these off for now and // maybe turn these back on sometime in the future "import/prefer-default-export": "off", @@ -57,7 +64,6 @@ module.exports = { "@typescript-eslint/quotes": ["error", "double"], semi: "off", "@typescript-eslint/semi": ["warn", "always"], - // indent: "off", indent: ["warn", 2], "@typescript-eslint/indent": "off", "@typescript-eslint/comma-dangle": "warn", @@ -65,6 +71,13 @@ module.exports = { "@typescript-eslint/keyword-spacing": ["error"], "object-curly-spacing": "off", "@typescript-eslint/object-curly-spacing": ["warn", "always"], + // Allow only vars starting with _ to be ununsed vars + "@typescript-eslint/no-unused-vars": ["warn", { + "varsIgnorePattern": "^_", + "argsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_", + "ignoreRestSiblings": true + }], // We have quite some "Unexpected any. Specify a different type" warnings. // This disables these warnings since they are false positives afaict. "@typescript-eslint/no-explicit-any": "off" diff --git a/web/src/screens/settings/Application.tsx b/web/src/screens/settings/Application.tsx index 60e42a4..ce9c3dc 100644 --- a/web/src/screens/settings/Application.tsx +++ b/web/src/screens/settings/Application.tsx @@ -31,26 +31,26 @@ const RowItem = ({ label, value, title, emptyText }: RowItemProps) => { ); }; -interface RowItemNumberProps { - label: string; - value?: string | number; - title?: string; - unit?: string; -} +// interface RowItemNumberProps { +// label: string; +// value?: string | number; +// title?: string; +// unit?: string; +// } -const RowItemNumber = ({ label, value, title, unit }: RowItemNumberProps) => { - return ( -
-
{label}:
-
- {value} - {unit && - {unit} - } -
-
- ); -}; +// const RowItemNumber = ({ label, value, title, unit }: RowItemNumberProps) => { +// return ( +//
+//
{label}:
+//
+// {value} +// {unit && +// {unit} +// } +//
+//
+// ); +// }; const RowItemVersion = ({ label, value, title, newUpdate }: RowItemProps) => { if (!value) { diff --git a/web/src/screens/settings/Feed.tsx b/web/src/screens/settings/Feed.tsx index 138a035..449da1a 100644 --- a/web/src/screens/settings/Feed.tsx +++ b/web/src/screens/settings/Feed.tsx @@ -132,7 +132,7 @@ function FeedSettings() { Last run {sortedFeeds.getSortIndicator("last_run")} - {sortedFeeds.items.map((feed, idx) => ( + {sortedFeeds.items.map((feed) => ( ))} diff --git a/web/src/screens/settings/Irc.tsx b/web/src/screens/settings/Irc.tsx index 86e4a3f..7d4fbf8 100644 --- a/web/src/screens/settings/Irc.tsx +++ b/web/src/screens/settings/Irc.tsx @@ -25,7 +25,7 @@ import { EmptySimple } from "@components/emptystates"; import { DeleteModal } from "@components/modals"; import Toast from "@components/notifications/Toast"; import { SettingsContext } from "@utils/Context"; -import { useForm } from "react-hook-form"; +// import { useForm } from "react-hook-form"; export const ircKeys = { all: ["irc_networks"] as const, @@ -586,9 +586,9 @@ type IrcEvent = { time: string; }; -type IrcMsg = { - msg: string; -}; +// type IrcMsg = { +// msg: string; +// }; interface EventsProps { network: IrcNetwork; @@ -606,27 +606,27 @@ export const Events = ({ network, channel }: EventsProps) => { // messagesEndRef.current?.scrollIntoView({ behavior: "smooth", block: "end", inline: "end" }); // }; - const { handleSubmit, register , resetField } = useForm({ - defaultValues: { msg: "" }, - mode: "onBlur" - }); + // const { handleSubmit, register , resetField } = useForm({ + // defaultValues: { msg: "" }, + // mode: "onBlur" + // }); - const cmdMutation = useMutation({ - mutationFn: (data: SendIrcCmdRequest) => APIClient.irc.sendCmd(data), - onSuccess: (_, variables) => { - resetField("msg"); - }, - onError: () => { - toast.custom((t) => ( - - )); - } - }); + // const cmdMutation = useMutation({ + // mutationFn: (data: SendIrcCmdRequest) => APIClient.irc.sendCmd(data), + // onSuccess: (_, _variables) => { + // resetField("msg"); + // }, + // onError: () => { + // toast.custom((t) => ( + // + // )); + // } + // }); - const onSubmit = (msg: IrcMsg) => { - const payload = { network_id: network.id, nick: network.nick, server: network.server, channel: channel, msg: msg.msg }; - cmdMutation.mutate(payload); - }; + // const onSubmit = (msg: IrcMsg) => { + // const payload = { network_id: network.id, nick: network.nick, server: network.server, channel: channel, msg: msg.msg }; + // cmdMutation.mutate(payload); + // }; useEffect(() => { // Following RFC4648