Added unused imports and vars and fixed lint (#929)

This commit is contained in:
Lucas Bordeau
2023-07-26 02:18:25 +02:00
committed by GitHub
parent c0700c9b20
commit b52745533a
17 changed files with 89 additions and 27 deletions

View File

@ -5,7 +5,7 @@ module.exports = {
tsconfigRootDir: __dirname, tsconfigRootDir: __dirname,
sourceType: 'module', sourceType: 'module',
}, },
plugins: ['@typescript-eslint/eslint-plugin', 'simple-import-sort', 'twenty'], plugins: ['@typescript-eslint/eslint-plugin', 'simple-import-sort', 'twenty', 'unused-imports'],
extends: [ extends: [
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended', 'plugin:prettier/recommended',
@ -48,5 +48,12 @@ module.exports = {
'twenty/sort-css-properties-alphabetically': 'error', 'twenty/sort-css-properties-alphabetically': 'error',
'twenty/no-hardcoded-colors': 'error', 'twenty/no-hardcoded-colors': 'error',
'func-style':['error', 'declaration', { 'allowArrowFunctions': true }], 'func-style':['error', 'declaration', { 'allowArrowFunctions': true }],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "warn",
"unused-imports/no-unused-vars": [
"warn",
{ "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
]
} }
}; };

View File

@ -51,7 +51,7 @@
"yup": "^1.2.0" "yup": "^1.2.0"
}, },
"scripts": { "scripts": {
"start": "PORT=3001 craco start", "start": "PORT=3001 craco start --max-warnings=0",
"build": "craco build", "build": "craco build",
"test": "craco test", "test": "craco test",
"coverage": "craco test --coverage .", "coverage": "craco test --coverage .",
@ -148,6 +148,7 @@
"eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-storybook": "^0.6.12", "eslint-plugin-storybook": "^0.6.12",
"eslint-plugin-twenty": "file:../packages/eslint-plugin-twenty", "eslint-plugin-twenty": "file:../packages/eslint-plugin-twenty",
"eslint-plugin-unused-imports": "^3.0.0",
"http-server": "^14.1.1", "http-server": "^14.1.1",
"mock-apollo-client": "^1.2.1", "mock-apollo-client": "^1.2.1",
"msw": "1.2.1", "msw": "1.2.1",

View File

@ -46,6 +46,7 @@ export type Attachment = {
name: Scalars['String']; name: Scalars['String'];
type: AttachmentType; type: AttachmentType;
updatedAt: Scalars['DateTime']; updatedAt: Scalars['DateTime'];
workspace: Workspace;
}; };
export type AttachmentCreateNestedManyWithoutActivityInput = { export type AttachmentCreateNestedManyWithoutActivityInput = {
@ -84,6 +85,12 @@ export type AttachmentUpdateManyWithoutAuthorNestedInput = {
set?: InputMaybe<Array<AttachmentWhereUniqueInput>>; set?: InputMaybe<Array<AttachmentWhereUniqueInput>>;
}; };
export type AttachmentUpdateManyWithoutWorkspaceNestedInput = {
connect?: InputMaybe<Array<AttachmentWhereUniqueInput>>;
disconnect?: InputMaybe<Array<AttachmentWhereUniqueInput>>;
set?: InputMaybe<Array<AttachmentWhereUniqueInput>>;
};
export type AttachmentWhereInput = { export type AttachmentWhereInput = {
AND?: InputMaybe<Array<AttachmentWhereInput>>; AND?: InputMaybe<Array<AttachmentWhereInput>>;
NOT?: InputMaybe<Array<AttachmentWhereInput>>; NOT?: InputMaybe<Array<AttachmentWhereInput>>;
@ -219,6 +226,10 @@ export type CommentThreadCreateInput = {
updatedAt?: InputMaybe<Scalars['DateTime']>; updatedAt?: InputMaybe<Scalars['DateTime']>;
}; };
export type CommentThreadCreateNestedOneWithoutCommentThreadTargetsInput = {
connect?: InputMaybe<CommentThreadWhereUniqueInput>;
};
export type CommentThreadCreateNestedOneWithoutCommentsInput = { export type CommentThreadCreateNestedOneWithoutCommentsInput = {
connect?: InputMaybe<CommentThreadWhereUniqueInput>; connect?: InputMaybe<CommentThreadWhereUniqueInput>;
}; };
@ -282,6 +293,7 @@ export type CommentThreadTarget = {
createdAt: Scalars['DateTime']; createdAt: Scalars['DateTime'];
id: Scalars['ID']; id: Scalars['ID'];
updatedAt: Scalars['DateTime']; updatedAt: Scalars['DateTime'];
workspace: Workspace;
}; };
export type CommentThreadTargetCreateManyCommentThreadInput = { export type CommentThreadTargetCreateManyCommentThreadInput = {
@ -297,6 +309,20 @@ export type CommentThreadTargetCreateManyCommentThreadInputEnvelope = {
skipDuplicates?: InputMaybe<Scalars['Boolean']>; skipDuplicates?: InputMaybe<Scalars['Boolean']>;
}; };
export type CommentThreadTargetCreateManyWorkspaceInput = {
commentThreadId: Scalars['String'];
commentableId: Scalars['String'];
commentableType: CommentableType;
createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type CommentThreadTargetCreateManyWorkspaceInputEnvelope = {
data: Array<CommentThreadTargetCreateManyWorkspaceInput>;
skipDuplicates?: InputMaybe<Scalars['Boolean']>;
};
export type CommentThreadTargetCreateNestedManyWithoutCommentThreadInput = { export type CommentThreadTargetCreateNestedManyWithoutCommentThreadInput = {
connect?: InputMaybe<Array<CommentThreadTargetWhereUniqueInput>>; connect?: InputMaybe<Array<CommentThreadTargetWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<CommentThreadTargetCreateOrConnectWithoutCommentThreadInput>>; connectOrCreate?: InputMaybe<Array<CommentThreadTargetCreateOrConnectWithoutCommentThreadInput>>;
@ -309,6 +335,11 @@ export type CommentThreadTargetCreateOrConnectWithoutCommentThreadInput = {
where: CommentThreadTargetWhereUniqueInput; where: CommentThreadTargetWhereUniqueInput;
}; };
export type CommentThreadTargetCreateOrConnectWithoutWorkspaceInput = {
create: CommentThreadTargetCreateWithoutWorkspaceInput;
where: CommentThreadTargetWhereUniqueInput;
};
export type CommentThreadTargetCreateWithoutCommentThreadInput = { export type CommentThreadTargetCreateWithoutCommentThreadInput = {
commentableId: Scalars['String']; commentableId: Scalars['String'];
commentableType: CommentableType; commentableType: CommentableType;
@ -317,6 +348,15 @@ export type CommentThreadTargetCreateWithoutCommentThreadInput = {
updatedAt?: InputMaybe<Scalars['DateTime']>; updatedAt?: InputMaybe<Scalars['DateTime']>;
}; };
export type CommentThreadTargetCreateWithoutWorkspaceInput = {
commentThread: CommentThreadCreateNestedOneWithoutCommentThreadTargetsInput;
commentableId: Scalars['String'];
commentableType: CommentableType;
createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
export type CommentThreadTargetListRelationFilter = { export type CommentThreadTargetListRelationFilter = {
every?: InputMaybe<CommentThreadTargetWhereInput>; every?: InputMaybe<CommentThreadTargetWhereInput>;
none?: InputMaybe<CommentThreadTargetWhereInput>; none?: InputMaybe<CommentThreadTargetWhereInput>;
@ -350,6 +390,17 @@ export type CommentThreadTargetUpdateManyWithoutCommentThreadNestedInput = {
set?: InputMaybe<Array<CommentThreadTargetWhereUniqueInput>>; set?: InputMaybe<Array<CommentThreadTargetWhereUniqueInput>>;
}; };
export type CommentThreadTargetUpdateManyWithoutWorkspaceNestedInput = {
connect?: InputMaybe<Array<CommentThreadTargetWhereUniqueInput>>;
connectOrCreate?: InputMaybe<Array<CommentThreadTargetCreateOrConnectWithoutWorkspaceInput>>;
create?: InputMaybe<Array<CommentThreadTargetCreateWithoutWorkspaceInput>>;
createMany?: InputMaybe<CommentThreadTargetCreateManyWorkspaceInputEnvelope>;
delete?: InputMaybe<Array<CommentThreadTargetWhereUniqueInput>>;
deleteMany?: InputMaybe<Array<CommentThreadTargetScalarWhereInput>>;
disconnect?: InputMaybe<Array<CommentThreadTargetWhereUniqueInput>>;
set?: InputMaybe<Array<CommentThreadTargetWhereUniqueInput>>;
};
export type CommentThreadTargetWhereInput = { export type CommentThreadTargetWhereInput = {
AND?: InputMaybe<Array<CommentThreadTargetWhereInput>>; AND?: InputMaybe<Array<CommentThreadTargetWhereInput>>;
NOT?: InputMaybe<Array<CommentThreadTargetWhereInput>>; NOT?: InputMaybe<Array<CommentThreadTargetWhereInput>>;
@ -1818,6 +1869,8 @@ export type Verify = {
export type Workspace = { export type Workspace = {
__typename?: 'Workspace'; __typename?: 'Workspace';
Attachment?: Maybe<Array<Attachment>>;
CommentThreadTarget?: Maybe<Array<CommentThreadTarget>>;
commentThreads?: Maybe<Array<CommentThread>>; commentThreads?: Maybe<Array<CommentThread>>;
comments?: Maybe<Array<Comment>>; comments?: Maybe<Array<Comment>>;
companies?: Maybe<Array<Company>>; companies?: Maybe<Array<Company>>;
@ -1890,6 +1943,8 @@ export type WorkspaceMemberWhereUniqueInput = {
}; };
export type WorkspaceUpdateInput = { export type WorkspaceUpdateInput = {
Attachment?: InputMaybe<AttachmentUpdateManyWithoutWorkspaceNestedInput>;
CommentThreadTarget?: InputMaybe<CommentThreadTargetUpdateManyWithoutWorkspaceNestedInput>;
commentThreads?: InputMaybe<CommentThreadUpdateManyWithoutWorkspaceNestedInput>; commentThreads?: InputMaybe<CommentThreadUpdateManyWithoutWorkspaceNestedInput>;
comments?: InputMaybe<CommentUpdateManyWithoutWorkspaceNestedInput>; comments?: InputMaybe<CommentUpdateManyWithoutWorkspaceNestedInput>;
companies?: InputMaybe<CompanyUpdateManyWithoutWorkspaceNestedInput>; companies?: InputMaybe<CompanyUpdateManyWithoutWorkspaceNestedInput>;

View File

@ -83,7 +83,7 @@ export function CommentThreadComments({ commentThread }: OwnProps) {
<> <>
<StyledThreadItemListContainer> <StyledThreadItemListContainer>
<StyledThreadCommentTitle>Comments</StyledThreadCommentTitle> <StyledThreadCommentTitle>Comments</StyledThreadCommentTitle>
{commentThread?.comments?.map((comment, index) => ( {commentThread?.comments?.map((comment) => (
<Comment key={comment.id} comment={comment} /> <Comment key={comment.id} comment={comment} />
))} ))}
</StyledThreadItemListContainer> </StyledThreadItemListContainer>

View File

@ -24,7 +24,7 @@ export function useApolloFactory() {
fields: { fields: {
commentThreadTargets: { commentThreadTargets: {
merge( merge(
existing: CommentThreadTarget[] = [], _existing: CommentThreadTarget[] = [],
incoming: CommentThreadTarget[], incoming: CommentThreadTarget[],
) { ) {
return [...incoming]; return [...incoming];

View File

@ -19,7 +19,6 @@ type OwnProps = {
> >
| null | null
| undefined; | undefined;
onChange?: (firstName: string, lastName: string) => void;
onSubmit?: (firstName: string, lastName: string) => void; onSubmit?: (firstName: string, lastName: string) => void;
onCancel?: () => void; onCancel?: () => void;
}; };
@ -33,7 +32,6 @@ const NoEditModeContainer = styled.div`
export function EditablePeopleFullName({ export function EditablePeopleFullName({
person, person,
onChange,
onSubmit, onSubmit,
onCancel, onCancel,
}: OwnProps) { }: OwnProps) {

View File

@ -76,7 +76,7 @@ const StyledButton = styled.button<
} }
}}; }};
border-style: solid; border-style: solid;
border-width: ${({ theme, variant, position }) => { border-width: ${({ variant, position }) => {
switch (variant) { switch (variant) {
case 'primary': case 'primary':
case 'secondary': case 'secondary':

View File

@ -117,7 +117,6 @@ const StyledIconButton = styled.button<
export function IconButton({ export function IconButton({
icon, icon,
title,
variant = 'transparent', variant = 'transparent',
size = 'medium', size = 'medium',
textColor = 'tertiary', textColor = 'tertiary',

View File

@ -140,7 +140,7 @@ export function EditableField({
transition={{ duration: 0.1 }} transition={{ duration: 0.1 }}
whileHover={{ scale: 1.04 }} whileHover={{ scale: 1.04 }}
> >
<EditableFieldEditButton customHotkeyScope={customEditHotkeyScope} /> <EditableFieldEditButton />
</motion.div> </motion.div>
)} )}
</EditableFieldBaseContainer> </EditableFieldBaseContainer>

View File

@ -1,7 +1,6 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { IconButton } from '@/ui/button/components/IconButton'; import { IconButton } from '@/ui/button/components/IconButton';
import { HotkeyScope } from '@/ui/hotkey/types/HotkeyScope';
import { IconPencil } from '@/ui/icon'; import { IconPencil } from '@/ui/icon';
import { overlayBackground } from '@/ui/themes/effects'; import { overlayBackground } from '@/ui/themes/effects';
@ -26,11 +25,7 @@ export const StyledEditableFieldEditButton = styled.div`
${overlayBackground} ${overlayBackground}
`; `;
type OwnProps = { export function EditableFieldEditButton() {
customHotkeyScope?: HotkeyScope;
};
export function EditableFieldEditButton({ customHotkeyScope }: OwnProps) {
const { openEditableField } = useEditableField(); const { openEditableField } = useEditableField();
function handleClick() { function handleClick() {

View File

@ -27,7 +27,7 @@ type OwnProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'> & {
const StyledContainer = styled.div<Pick<OwnProps, 'fullWidth'>>` const StyledContainer = styled.div<Pick<OwnProps, 'fullWidth'>>`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: ${({ fullWidth, theme }) => (fullWidth ? `100%` : 'auto')}; width: ${({ fullWidth }) => (fullWidth ? `100%` : 'auto')};
`; `;
const StyledLabel = styled.span` const StyledLabel = styled.span`

View File

@ -19,9 +19,10 @@ export const snackBarInternalState = atom<SnackBarState>({
}, },
}); });
// TODO: use a recoil callback
export const snackBarSetQueueState = selector<SnackBarOptions | null>({ export const snackBarSetQueueState = selector<SnackBarOptions | null>({
key: 'snackBarQueueState', key: 'snackBarQueueState',
get: ({ get }) => null, // We don't care about getting the value get: ({ get: _get }) => null, // We don't care about getting the value
set: ({ set }, newValue) => set: ({ set }, newValue) =>
set(snackBarInternalState, (prev) => { set(snackBarInternalState, (prev) => {
if (prev.queue.length >= prev.maxQueue) { if (prev.queue.length >= prev.maxQueue) {

View File

@ -1,4 +1,3 @@
import React from 'react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { Checkbox } from '@/ui/input/components/Checkbox'; import { Checkbox } from '@/ui/input/components/Checkbox';
@ -19,7 +18,8 @@ export const SelectAllCheckbox = () => {
const checked = allRowsSelectedStatus === 'all'; const checked = allRowsSelectedStatus === 'all';
const indeterminate = allRowsSelectedStatus === 'some'; const indeterminate = allRowsSelectedStatus === 'some';
function onChange(value: boolean) {
function onChange() {
selectAllRows(); selectAllRows();
} }

View File

@ -36,7 +36,6 @@ export function EditableCellDoubleTextEditMode({
secondValue, secondValue,
firstValuePlaceholder, firstValuePlaceholder,
secondValuePlaceholder, secondValuePlaceholder,
onChange,
onSubmit, onSubmit,
onCancel, onCancel,
}: OwnProps) { }: OwnProps) {

View File

@ -7,20 +7,16 @@ import { EditableCell } from '../components/EditableCell';
type OwnProps = { type OwnProps = {
placeholder?: string; placeholder?: string;
value: string; value: string;
onChange?: (newValue: string) => void;
editModeHorizontalAlign?: 'left' | 'right'; editModeHorizontalAlign?: 'left' | 'right';
loading?: boolean; loading?: boolean;
onSubmit?: (newText: string) => void; onSubmit?: (newText: string) => void;
onCancel?: () => void;
}; };
export function EditableCellText({ export function EditableCellText({
value, value,
placeholder, placeholder,
onChange,
editModeHorizontalAlign, editModeHorizontalAlign,
loading, loading,
onCancel,
onSubmit, onSubmit,
}: OwnProps) { }: OwnProps) {
return ( return (

View File

@ -1,13 +1,12 @@
import { EntityChip, EntityChipVariant } from '@/ui/chip/components/EntityChip'; import { EntityChip } from '@/ui/chip/components/EntityChip';
export type UserChipPropsType = { export type UserChipPropsType = {
id: string; id: string;
name: string; name: string;
pictureUrl?: string; pictureUrl?: string;
variant?: EntityChipVariant;
}; };
export function UserChip({ id, name, pictureUrl, variant }: UserChipPropsType) { export function UserChip({ id, name, pictureUrl }: UserChipPropsType) {
return ( return (
<EntityChip <EntityChip
entityId={id} entityId={id}

View File

@ -9493,6 +9493,18 @@ eslint-plugin-testing-library@^5.0.1:
dependencies: dependencies:
postcss "^8.4.24" postcss "^8.4.24"
eslint-plugin-unused-imports@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-3.0.0.tgz#d25175b0072ff16a91892c3aa72a09ca3a9e69e7"
integrity sha512-sduiswLJfZHeeBJ+MQaG+xYzSWdRXoSw61DpU13mzWumCkR0ufD0HmO4kdNokjrkluMHpj/7PJeN35pgbhW3kw==
dependencies:
eslint-rule-composer "^0.3.0"
eslint-rule-composer@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9"
integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==
eslint-scope@5.1.1, eslint-scope@^5.1.1: eslint-scope@5.1.1, eslint-scope@^5.1.1:
version "5.1.1" version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"