POC: chore: use Nx workspace lint rules (#3163)

* chore: use Nx workspace lint rules

Closes #3162

* Fix lint

* Fix lint on BE

* Fix tests

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Thaïs
2024-01-03 19:07:25 -03:00
committed by GitHub
parent 1924962e8c
commit 8483cf0b4b
125 changed files with 2547 additions and 3161 deletions

View File

@ -55,7 +55,7 @@ export const ActivityBodyEditor = ({
const imagesActivated = useIsFeatureEnabled('IS_NOTE_CREATE_IMAGES_ENABLED');
if (!imagesActivated) {
slashMenuItems = slashMenuItems.filter((x) => x.name != 'Image');
slashMenuItems = slashMenuItems.filter((x) => x.name !== 'Image');
}
const [uploadFile] = useUploadFileMutation();

View File

@ -102,8 +102,8 @@ export const Attachments = ({
fullPath: attachmentUrl,
type: getFileType(file.name),
companyId:
targetableEntity.type == 'Company' ? targetableEntity.id : null,
personId: targetableEntity.type == 'Person' ? targetableEntity.id : null,
targetableEntity.type === 'Company' ? targetableEntity.id : null,
personId: targetableEntity.type === 'Person' ? targetableEntity.id : null,
});
};

View File

@ -42,7 +42,7 @@ export const useHandleCheckableActivityTargetChange = ({
.map(([id, _]) => id);
if (idsToAdd.length) {
idsToAdd.map((id) => {
idsToAdd.forEach((id) => {
const entityFromToSelect = entitiesToSelect.filter(
(entity: any) => entity.id === id,
).length
@ -65,7 +65,7 @@ export const useHandleCheckableActivityTargetChange = ({
}
if (idsToDelete.length) {
idsToDelete.map((id) => {
idsToDelete.forEach((id) => {
const currentActivityTargetId = currentActivityTargets.filter(
({ companyId, personId }) => companyId === id || personId === id,
)[0].id;

View File

@ -62,7 +62,7 @@ export const NoteList = ({ title, notes, button }: NoteListProps) => (
<NoteCard
key={note.id}
note={note}
isSingleNote={notes.length == 1}
isSingleNote={notes.length === 1}
/>
))}
</StyledNoteContainer>

View File

@ -13,7 +13,7 @@ import { useUpdateEffect } from '~/hooks/useUpdateEffect';
import { ApolloFactory } from '../services/apollo.factory';
export const useApolloFactory = () => {
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const apolloRef = useRef<ApolloFactory<NormalizedCacheObject> | null>(null);
const [isDebugMode] = useRecoilState(isDebugModeState);

View File

@ -1,15 +1,15 @@
import { OperationType } from '../types/operation-type';
const operationTypeColors = {
// eslint-disable-next-line twenty/no-hardcoded-colors
// eslint-disable-next-line @nx/workspace-no-hardcoded-colors
query: '#03A9F4',
// eslint-disable-next-line twenty/no-hardcoded-colors
// eslint-disable-next-line @nx/workspace-no-hardcoded-colors
mutation: '#61A600',
// eslint-disable-next-line twenty/no-hardcoded-colors
// eslint-disable-next-line @nx/workspace-no-hardcoded-colors
subscription: '#61A600',
// eslint-disable-next-line twenty/no-hardcoded-colors
// eslint-disable-next-line @nx/workspace-no-hardcoded-colors
error: '#F51818',
// eslint-disable-next-line twenty/no-hardcoded-colors
// eslint-disable-next-line @nx/workspace-no-hardcoded-colors
default: '#61A600',
};

View File

@ -68,7 +68,7 @@ export const loggerLink = (getSchemaName: (operation: Operation) => string) =>
errors.forEach((err: any) => {
logDebug(
`%c${err.message}`,
// eslint-disable-next-line twenty/no-hardcoded-colors
// eslint-disable-next-line @nx/workspace-no-hardcoded-colors
'color: #F51818; font-weight: lighter',
);
});

View File

@ -157,6 +157,7 @@ export const useAuth = () => {
set(supportChatState, supportChat);
set(telemetryState, telemetry);
set(isDebugModeState, isDebugMode);
return undefined;
});
goToRecoilSnapshot(initialSnapshot);

View File

@ -44,7 +44,7 @@ export const ObjectMetadataNavItems = () => {
key={objectMetadataItem.id}
label={objectMetadataItem.labelPlural}
to={`/objects/${objectMetadataItem.namePlural}`}
active={currentPath == `/objects/${objectMetadataItem.namePlural}`}
active={currentPath === `/objects/${objectMetadataItem.namePlural}`}
Icon={getIcon(objectMetadataItem.icon)}
onClick={() => {
navigate(`/objects/${objectMetadataItem.namePlural}`);

View File

@ -36,7 +36,7 @@ const StyledIconTableCell = styled(TableCell)`
export const SettingsObjectFieldItemTableRow = ({
ActionIcon,
fieldMetadataItem: fieldMetadataItem,
fieldMetadataItem,
}: SettingsObjectFieldItemTableRowProps) => {
const theme = useTheme();
const { getIcon } = useIcons();

View File

@ -1,9 +1,11 @@
import { ModalWrapper } from '@/spreadsheet-import/components/ModalWrapper';
import { Providers } from '@/spreadsheet-import/components/Providers';
import { Steps } from '@/spreadsheet-import/steps/components/Steps';
import { SpreadsheetOptions } from '@/spreadsheet-import/types';
import { SpreadsheetOptions as SpreadsheetImportProps } from '@/spreadsheet-import/types';
export const defaultSpreadsheetImportProps: Partial<SpreadsheetOptions<any>> = {
export const defaultSpreadsheetImportProps: Partial<
SpreadsheetImportProps<any>
> = {
autoMapHeaders: true,
allowInvalidSubmit: true,
autoMapDistance: 2,
@ -17,8 +19,7 @@ export const defaultSpreadsheetImportProps: Partial<SpreadsheetOptions<any>> = {
} as const;
export const SpreadsheetImport = <T extends string>(
// eslint-disable-next-line twenty/component-props-naming
props: SpreadsheetOptions<T>,
props: SpreadsheetImportProps<T>,
) => {
return (
<Providers values={props}>

View File

@ -56,9 +56,9 @@ export const ProgressBar = forwardRef<ProgressBarControls, ProgressBarProps>(
const theme = useTheme();
const controls = useAnimation();
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const startTimestamp = useRef<number>(0);
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const remainingTime = useRef<number>(duration);
const start = useCallback(async () => {

View File

@ -118,7 +118,7 @@ export const SnackBar = ({
}: SnackBarProps) => {
const theme = useTheme();
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const progressBarRef = useRef<ProgressBarControls | null>(null);
const closeSnackbar = useCallback(() => {

View File

@ -1,13 +1,13 @@
import { useCallback, useEffect, useRef } from 'react';
export const usePausableTimeout = (callback: () => void, delay: number) => {
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const savedCallback = useRef<() => void>(callback);
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const remainingTime = useRef<number>(delay);
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const startTime = useRef<number>(Date.now());
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const timeoutId = useRef<ReturnType<typeof setTimeout> | null>(null);
const tick = () => {

View File

@ -131,7 +131,7 @@ const TextInputComponent = (
tabIndex,
RightIcon,
}: TextInputComponentProps,
// eslint-disable-next-line twenty/component-props-naming
// eslint-disable-next-line @nx/workspace-component-props-naming
ref: ForwardedRef<HTMLInputElement>,
): JSX.Element => {
const theme = useTheme();

View File

@ -23,7 +23,7 @@ const StyledEditor = styled.div`
export const BlockEditor = ({ editor }: BlockEditorProps) => {
const theme = useTheme();
const blockNoteTheme = theme.name == 'light' ? 'light' : 'dark';
const blockNoteTheme = theme.name === 'light' ? 'light' : 'dark';
return (
<StyledEditor>
<BlockNoteView editor={editor} theme={blockNoteTheme} />

View File

@ -30,7 +30,7 @@ export const ShowPageMoreButton = ({
const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState);
const navigate = useNavigate();
const { deleteOneRecord: deleteOneRecord } = useDeleteOneRecord({
const { deleteOneRecord } = useDeleteOneRecord({
objectNameSingular,
});

View File

@ -1,4 +1,4 @@
/* eslint-disable twenty/no-hardcoded-colors */
/* eslint-disable @nx/workspace-no-hardcoded-colors */
import DarkNoise from '../assets/dark-noise.jpg';
import LightNoise from '../assets/light-noise.png';

View File

@ -1,4 +1,4 @@
/* eslint-disable twenty/no-hardcoded-colors */
/* eslint-disable @nx/workspace-no-hardcoded-colors */
import hexRgb from 'hex-rgb';
export const grayScale = {

View File

@ -1,4 +1,4 @@
/* eslint-disable twenty/no-hardcoded-colors */
/* eslint-disable @nx/workspace-no-hardcoded-colors */
import { accentDark, accentLight } from './accent';
import { animation } from './animation';
import { backgroundDark, backgroundLight } from './background';

View File

@ -18,7 +18,7 @@ export const RecoilScope = ({
scopeId?: string;
CustomRecoilScopeContext?: RecoilScopeContextType;
}) => {
// eslint-disable-next-line twenty/no-state-useref
// eslint-disable-next-line @nx/workspace-no-state-useref
const currentScopeId = useRef(scopeId ?? v4());
return CustomRecoilScopeContext ? (

View File

@ -28,8 +28,8 @@ export const getViewScopedStatesFromSnapshot = ({
availableFieldDefinitionsState,
availableFilterDefinitionsState,
availableSortDefinitionsState,
canPersistFiltersSelector: canPersistFiltersSelector,
canPersistSortsSelector: canPersistSortsSelector,
canPersistFiltersSelector,
canPersistSortsSelector,
currentViewFieldsState,
currentViewFiltersState,
currentViewIdState,
@ -41,11 +41,11 @@ export const getViewScopedStatesFromSnapshot = ({
onViewFieldsChangeState,
onViewFiltersChangeState,
onViewSortsChangeState,
savedViewFieldsByKeySelector: savedViewFieldsByKeySelector,
savedViewFieldsByKeySelector,
savedViewFieldsState,
savedViewFiltersByKeySelector: savedViewFiltersByKeySelector,
savedViewFiltersByKeySelector,
savedViewFiltersState,
savedViewSortsByKeySelector: savedViewSortsByKeySelector,
savedViewSortsByKeySelector,
savedViewSortsState,
viewEditModeState,
viewObjectMetadataIdState,