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
This commit is contained in:
Fabricio Silva 2023-07-02 13:19:03 +01:00 committed by GitHub
parent 32ffc875b0
commit a5e05284d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 44 deletions

View file

@ -22,6 +22,13 @@ module.exports = {
indent: ["warn", 2], indent: ["warn", 2],
// Don't enforce any particular brace style // Don't enforce any particular brace style
curly: "off", 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 // Let's keep these off for now and
// maybe turn these back on sometime in the future // maybe turn these back on sometime in the future
"import/prefer-default-export": "off", "import/prefer-default-export": "off",
@ -57,7 +64,6 @@ module.exports = {
"@typescript-eslint/quotes": ["error", "double"], "@typescript-eslint/quotes": ["error", "double"],
semi: "off", semi: "off",
"@typescript-eslint/semi": ["warn", "always"], "@typescript-eslint/semi": ["warn", "always"],
// indent: "off",
indent: ["warn", 2], indent: ["warn", 2],
"@typescript-eslint/indent": "off", "@typescript-eslint/indent": "off",
"@typescript-eslint/comma-dangle": "warn", "@typescript-eslint/comma-dangle": "warn",
@ -65,6 +71,13 @@ module.exports = {
"@typescript-eslint/keyword-spacing": ["error"], "@typescript-eslint/keyword-spacing": ["error"],
"object-curly-spacing": "off", "object-curly-spacing": "off",
"@typescript-eslint/object-curly-spacing": ["warn", "always"], "@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. // We have quite some "Unexpected any. Specify a different type" warnings.
// This disables these warnings since they are false positives afaict. // This disables these warnings since they are false positives afaict.
"@typescript-eslint/no-explicit-any": "off" "@typescript-eslint/no-explicit-any": "off"

View file

@ -31,26 +31,26 @@ const RowItem = ({ label, value, title, emptyText }: RowItemProps) => {
); );
}; };
interface RowItemNumberProps { // interface RowItemNumberProps {
label: string; // label: string;
value?: string | number; // value?: string | number;
title?: string; // title?: string;
unit?: string; // unit?: string;
} // }
const RowItemNumber = ({ label, value, title, unit }: RowItemNumberProps) => { // const RowItemNumber = ({ label, value, title, unit }: RowItemNumberProps) => {
return ( // return (
<div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6"> // <div className="py-4 sm:py-5 sm:grid sm:grid-cols-4 sm:gap-4 sm:px-6">
<dt className="font-medium text-gray-500 dark:text-white" title={title}>{label}:</dt> // <dt className="font-medium text-gray-500 dark:text-white" title={title}>{label}:</dt>
<dd className="mt-1 text-gray-900 dark:text-white sm:mt-0 sm:col-span-2 break-all"> // <dd className="mt-1 text-gray-900 dark:text-white sm:mt-0 sm:col-span-2 break-all">
<span className="px-1 py-0.5 bg-gray-700 rounded shadow">{value}</span> // <span className="px-1 py-0.5 bg-gray-700 rounded shadow">{value}</span>
{unit && // {unit &&
<span className="ml-1 text-sm text-gray-800 dark:text-gray-400">{unit}</span> // <span className="ml-1 text-sm text-gray-800 dark:text-gray-400">{unit}</span>
} // }
</dd> // </dd>
</div> // </div>
); // );
}; // };
const RowItemVersion = ({ label, value, title, newUpdate }: RowItemProps) => { const RowItemVersion = ({ label, value, title, newUpdate }: RowItemProps) => {
if (!value) { if (!value) {

View file

@ -132,7 +132,7 @@ function FeedSettings() {
Last run <span className="sort-indicator">{sortedFeeds.getSortIndicator("last_run")}</span> Last run <span className="sort-indicator">{sortedFeeds.getSortIndicator("last_run")}</span>
</div> </div>
</li> </li>
{sortedFeeds.items.map((feed, idx) => ( {sortedFeeds.items.map((feed) => (
<ListItem key={feed.id} feed={feed}/> <ListItem key={feed.id} feed={feed}/>
))} ))}
</ol> </ol>

View file

@ -25,7 +25,7 @@ import { EmptySimple } from "@components/emptystates";
import { DeleteModal } from "@components/modals"; import { DeleteModal } from "@components/modals";
import Toast from "@components/notifications/Toast"; import Toast from "@components/notifications/Toast";
import { SettingsContext } from "@utils/Context"; import { SettingsContext } from "@utils/Context";
import { useForm } from "react-hook-form"; // import { useForm } from "react-hook-form";
export const ircKeys = { export const ircKeys = {
all: ["irc_networks"] as const, all: ["irc_networks"] as const,
@ -586,9 +586,9 @@ type IrcEvent = {
time: string; time: string;
}; };
type IrcMsg = { // type IrcMsg = {
msg: string; // msg: string;
}; // };
interface EventsProps { interface EventsProps {
network: IrcNetwork; network: IrcNetwork;
@ -606,27 +606,27 @@ export const Events = ({ network, channel }: EventsProps) => {
// messagesEndRef.current?.scrollIntoView({ behavior: "smooth", block: "end", inline: "end" }); // messagesEndRef.current?.scrollIntoView({ behavior: "smooth", block: "end", inline: "end" });
// }; // };
const { handleSubmit, register , resetField } = useForm<IrcMsg>({ // const { handleSubmit, register , resetField } = useForm<IrcMsg>({
defaultValues: { msg: "" }, // defaultValues: { msg: "" },
mode: "onBlur" // mode: "onBlur"
}); // });
const cmdMutation = useMutation({ // const cmdMutation = useMutation({
mutationFn: (data: SendIrcCmdRequest) => APIClient.irc.sendCmd(data), // mutationFn: (data: SendIrcCmdRequest) => APIClient.irc.sendCmd(data),
onSuccess: (_, variables) => { // onSuccess: (_, _variables) => {
resetField("msg"); // resetField("msg");
}, // },
onError: () => { // onError: () => {
toast.custom((t) => ( // toast.custom((t) => (
<Toast type="error" body="Error sending IRC cmd" t={t} /> // <Toast type="error" body="Error sending IRC cmd" t={t} />
)); // ));
} // }
}); // });
const onSubmit = (msg: IrcMsg) => { // const onSubmit = (msg: IrcMsg) => {
const payload = { network_id: network.id, nick: network.nick, server: network.server, channel: channel, msg: msg.msg }; // const payload = { network_id: network.id, nick: network.nick, server: network.server, channel: channel, msg: msg.msg };
cmdMutation.mutate(payload); // cmdMutation.mutate(payload);
}; // };
useEffect(() => { useEffect(() => {
// Following RFC4648 // Following RFC4648