chore: restrict usage of variables shorther than 3 characters (#255)

* chore: restrict usage of variables shorther than 3 characters

* chore: change highlighting to warning
This commit is contained in:
Meier Lukas
2024-03-20 20:58:24 +01:00
committed by GitHub
parent 361700b239
commit 92a8db718c
4 changed files with 18 additions and 6 deletions

View File

@@ -65,11 +65,11 @@ export const AccessSettingsContent = ({ board, initialPermissions }: Props) => {
const { openModal } = useModalAction(UserSelectModal); const { openModal } = useModalAction(UserSelectModal);
const handleSubmit = useCallback( const handleSubmit = useCallback(
(v: FormType) => { (values: FormType) => {
mutate( mutate(
{ {
id: board.id, id: board.id,
permissions: v.permissions, permissions: values.permissions,
}, },
{ {
onSuccess: () => { onSuccess: () => {
@@ -250,8 +250,8 @@ export const UserSelectModal = createModal<InnerProps>(
const t = useI18n(); const t = useI18n();
const { data: users } = clientApi.user.selectable.useQuery(); const { data: users } = clientApi.user.selectable.useQuery();
const form = useForm<UserSelectFormType>(); const form = useForm<UserSelectFormType>();
const handleSubmit = (v: UserSelectFormType) => { const handleSubmit = (values: UserSelectFormType) => {
const currentUser = users?.find((user) => user.id === v.userId); const currentUser = users?.find((user) => user.id === values.userId);
if (!currentUser) return; if (!currentUser) return;
innerProps.onSelect({ innerProps.onSelect({
id: currentUser.id, id: currentUser.id,

View File

@@ -45,6 +45,7 @@ export const ColorSettingsContent = ({ board }: Props) => {
const theme = useMantineTheme(); const theme = useMantineTheme();
const { mutate: savePartialSettings, isPending } = const { mutate: savePartialSettings, isPending } =
useSavePartialSettingsMutation(board); useSavePartialSettingsMutation(board);
return ( return (
<form <form
onSubmit={form.onSubmit((values) => { onSubmit={form.onSubmit((values) => {

View File

@@ -3,7 +3,7 @@
import type { RefObject } from "react"; import type { RefObject } from "react";
import { useElementSize } from "@mantine/hooks"; import { useElementSize } from "@mantine/hooks";
import cx from "clsx"; import combineClasses from "clsx";
import { useAtomValue } from "jotai"; import { useAtomValue } from "jotai";
import { useConfirmModal, useModalAction } from "@homarr/modals"; import { useConfirmModal, useModalAction } from "@homarr/modals";
@@ -60,7 +60,10 @@ export const SectionContent = ({ items, refs }: Props) => {
> >
<Card <Card
ref={ref} ref={ref}
className={cx(classes.itemCard, "grid-stack-item-content")} className={combineClasses(
classes.itemCard,
"grid-stack-item-content",
)}
withBorder withBorder
styles={{ styles={{
root: { root: {

View File

@@ -17,6 +17,14 @@ const config = {
}, },
plugins: ["@typescript-eslint", "import"], plugins: ["@typescript-eslint", "import"],
rules: { rules: {
"id-length": [
"warn",
{
min: 3,
exceptions: ["_", "i", "z", "t", "id"], // _ for unused variables, i for index, z for zod, t for translation
properties: "never", // This allows for example the use of <Grid.Col span={{ sm: 12, md: 6 }}> as sm and md would be too short
},
],
"@typescript-eslint/prefer-nullish-coalescing": "off", "@typescript-eslint/prefer-nullish-coalescing": "off",
"turbo/no-undeclared-env-vars": "off", "turbo/no-undeclared-env-vars": "off",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [