Skip to content

Commit

Permalink
Merge pull request #1679 from BLSQ/ESLINT-RULES
Browse files Browse the repository at this point in the history
IA-3484: Eslint
  • Loading branch information
beygorghor authored Oct 4, 2024
2 parents 7673357 + 6680887 commit f1dcc22
Show file tree
Hide file tree
Showing 416 changed files with 1,910 additions and 2,491 deletions.
520 changes: 300 additions & 220 deletions .eslintrc.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion hat/assets/js/apps/Iaso/components/Cells/BreakWordCell.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable camelcase */
import { Box } from '@mui/material';
import React, { ReactElement } from 'react';
import { makeStyles } from '@mui/styles';
Expand Down
5 changes: 3 additions & 2 deletions hat/assets/js/apps/Iaso/components/Cells/DateTimeCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { apiDateFormats } from '../../utils/dates';
/* DateTimeCell
For use in Table's columns to display DateTime
*/
export const DateTimeCell = (cellInfo: { value?: number | null }): string =>
displayDateFromTimestamp(cellInfo?.value);
export const DateTimeCell = (cellInfo: {
value?: number | null | undefined;
}): string => displayDateFromTimestamp(cellInfo?.value);

export const convertToDateTimeRfc = (
value: string | null | undefined,
Expand Down
3 changes: 1 addition & 2 deletions hat/assets/js/apps/Iaso/components/Cells/UserCell.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable camelcase */
import React, { ReactElement } from 'react';
import getDisplayName, { User } from '../../utils/usersUtils';

export const UserCell = (cellInfo: { value?: Partial<User> }): ReactElement => {
const value = cellInfo?.value ?? '';
return <>{value ? getDisplayName(value) : '--'}</>;
return <span>{value ? getDisplayName(value) : '--'}</span>;
};
6 changes: 2 additions & 4 deletions hat/assets/js/apps/Iaso/components/FilterButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable react/require-default-props */
/* eslint-disable react/jsx-props-no-spreading */
import React, { FunctionComponent } from 'react';
import FiltersIcon from '@mui/icons-material/FilterList';
import { Button, Box } from '@mui/material';
import { Box, Button } from '@mui/material';
import React, { FunctionComponent } from 'react';
import { FormattedMessage, defineMessages } from 'react-intl';

const MESSAGES = defineMessages({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
/* eslint-disable camelcase */
import React, { FunctionComponent, useCallback, useMemo } from 'react';
import { Box, Button } from '@mui/material';
import {
ConfirmCancelModal,
IntlMessage,
makeFullModal,
ConfirmCancelModal,
useSafeIntl,
} from 'bluesquare-components';
import React, { FunctionComponent, useCallback, useMemo } from 'react';
import * as Yup from 'yup';
import { Box, Button } from '@mui/material';

import { useFormik } from 'formik';
import Add from '@mui/icons-material/Add';
import { useFormik } from 'formik';
import { EditIconButton } from '../Buttons/EditIconButton';
import { LegendBuilder } from './index';
import { MESSAGES } from './messages';
import { ScaleThreshold } from './types';
import { LegendBuilder } from './index';
import { getRangeValues, getScaleThreshold } from './utils';
import { EditIconButton } from '../Buttons/EditIconButton';

type Props = {
titleMessage: IntlMessage;
isOpen: boolean;
closeDialog: () => void;
// eslint-disable-next-line no-unused-vars
onConfirm: (threshold?: ScaleThreshold) => void;
threshold?: ScaleThreshold;
};
Expand Down
12 changes: 4 additions & 8 deletions hat/assets/js/apps/Iaso/components/LegendBuilder/LegendRange.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { FunctionComponent } from 'react';
import { IconButton, Grid, Typography, Box } from '@mui/material';
import { makeStyles } from '@mui/styles';
import RemoveIcon from '@mui/icons-material/Remove';
import { Box, Grid, IconButton, Typography } from '@mui/material';
import { makeStyles } from '@mui/styles';
import React, { FunctionComponent } from 'react';
import { ColorPicker } from '../forms/ColorPicker';
import InputComponent from '../forms/InputComponent';
import { RangeValue } from './types';
import { legendColors } from './colors';
import { RangeValue } from './types';

const useStyles = makeStyles(theme => ({
legendItem: {
Expand All @@ -23,13 +23,9 @@ type LegendRowProps = {
rangeItem: RangeValue;
index: number;
rangeValues: RangeValue[];
// eslint-disable-next-line no-unused-vars
handleColorChange: (index: number) => void;
// eslint-disable-next-line no-unused-vars
handleNumberChange: (index: number, newNumber?: number) => void;
// eslint-disable-next-line no-unused-vars
removeRangeValue: (index: number) => void;
// eslint-disable-next-line no-unused-vars
setFieldError: (keyValue: string, message: string) => void;
errors?: string[];
};
Expand Down
8 changes: 3 additions & 5 deletions hat/assets/js/apps/Iaso/components/LegendBuilder/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { FunctionComponent, useCallback } from 'react';
import AddIcon from '@mui/icons-material/Add';
import { Box, IconButton } from '@mui/material';
import { makeStyles } from '@mui/styles';
import AddIcon from '@mui/icons-material/Add';
import React, { FunctionComponent, useCallback } from 'react';

import { legendColors } from './colors';
import { LegendRange } from './LegendRange';
import { RangeValue } from './types';
import { legendColors } from './colors';

const useStyles = makeStyles(theme => ({
root: {
Expand Down Expand Up @@ -36,9 +36,7 @@ const useStyles = makeStyles(theme => ({

type LegendBuilderProps = {
rangeValues: RangeValue[];
// eslint-disable-next-line no-unused-vars
onChange: (newRangeValues: RangeValue[]) => void;
// eslint-disable-next-line no-unused-vars
setFieldError: (keyValue: string, message: string) => void;
errors?: string[];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,23 @@ function RawConfirmCancelActions({
>
<FormattedMessage {...confirmMessage} />
</Button>
{additionalButton && additionalMessage && onAdditionalButtonClick && (
<Button
data-test="additional-button"
onClick={() => onAdditionalButtonClick(closeDialog)}
color="primary"
disabled={
allowConfimAdditionalButton !== null &&
allowConfimAdditionalButton !== undefined
? !allowConfimAdditionalButton
: !allowConfirm
}
>
<FormattedMessage {...additionalMessage} />
</Button>
)}
{additionalButton &&
additionalMessage &&
onAdditionalButtonClick && (
<Button
data-test="additional-button"
onClick={() => onAdditionalButtonClick(closeDialog)}
color="primary"
disabled={
allowConfimAdditionalButton !== null &&
allowConfimAdditionalButton !== undefined
? !allowConfimAdditionalButton
: !allowConfirm
}
>
<FormattedMessage {...additionalMessage} />
</Button>
)}
</DialogActions>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const normalizedMessage = CompOrMessage => {
return '';
}
if (CompOrMessage.id) {
// eslint-disable-next-line react/jsx-props-no-spreading
return <FormattedMessage {...CompOrMessage} />;
}
return CompOrMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ type Props = {
closeLightbox: () => void;
imageList: ShortFile[];
currentIndex: number;
// eslint-disable-next-line no-unused-vars
setCurrentIndex?: (index: number) => void;
url?: string | null;
urlLabel?: { id: string; defaultMessage: string } | undefined;
// eslint-disable-next-line no-unused-vars
getExtraInfos?: (image: ShortFile) => React.ReactNode;
};

Expand Down
7 changes: 3 additions & 4 deletions hat/assets/js/apps/Iaso/components/errors/PageNoPerms.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable react/jsx-props-no-spreading */
import React from 'react';
import { FormattedMessage } from 'react-intl';
import Info from '@mui/icons-material/Info';
import { Box, Container, Paper, Typography } from '@mui/material';
import { makeStyles } from '@mui/styles';
import Info from '@mui/icons-material/Info';
import { ClassNameMap } from 'notistack';
import React from 'react';
import { FormattedMessage } from 'react-intl';
import TopBar from '../nav/TopBarComponent';

import MESSAGES from './messages';
Expand Down
2 changes: 0 additions & 2 deletions hat/assets/js/apps/Iaso/components/files/FavButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ const MESSAGES = defineMessages({

type Props = {
file: ShortFile;
// eslint-disable-next-line no-unused-vars
onImageFavoriteClick: (id: number) => void;
// eslint-disable-next-line no-unused-vars
isDefaultImage: (id: number) => boolean;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ const styles = {

type Props = {
imageList: ShortFile[];
// eslint-disable-next-line no-unused-vars
onImageClick: (index: number) => void;
// eslint-disable-next-line no-unused-vars
onImageFavoriteClick?: (id: number) => void;
// eslint-disable-next-line no-unused-vars
isDefaultImage?: (id: number) => boolean;
};

Expand Down
1 change: 0 additions & 1 deletion hat/assets/js/apps/Iaso/components/filters/DatesRange.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ComponentType } from 'react';
interface DatesRangeProps {
dateFrom?: string;
dateTo?: string;
// eslint-disable-next-line no-unused-vars
onChangeDate: (key: string, value: any) => void;
labelTo?: { id: string; defaultMessage: string };
labelFrom?: { id: string; defaultMessage: string };
Expand Down
16 changes: 5 additions & 11 deletions hat/assets/js/apps/Iaso/components/forms/AsyncSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { FunctionComponent, useEffect, useMemo, useState } from 'react';
import { defineMessages } from 'react-intl';
import { debounce } from '@mui/material/utils';
import { Box, TextField } from '@mui/material';
import Autocomplete from '@mui/material/Autocomplete';
import { AutocompleteGetTagProps } from '@mui/material/Autocomplete/Autocomplete';
import { debounce } from '@mui/material/utils';
import {
IntlMessage,
renderTags as defaultRenderTags,
useSafeIntl,
} from 'bluesquare-components';
import { Box, TextField } from '@mui/material';
import { isArray } from 'lodash';
import { AutocompleteGetTagProps } from '@mui/material/Autocomplete/Autocomplete';
import React, { FunctionComponent, useEffect, useMemo, useState } from 'react';
import { defineMessages } from 'react-intl';

const MESSAGES = defineMessages({
noOptionsText: {
Expand All @@ -24,7 +24,6 @@ type Props = {
loading?: boolean;
loadingText?: IntlMessage;
keyValue: string;
// eslint-disable-next-line no-unused-vars
onChange: (keyValue, newValue: any | null) => void;
errors?: string[];
required?: boolean;
Expand All @@ -34,12 +33,9 @@ type Props = {
multi?: boolean;
helperText?: string;
minCharBeforeQuery?: number;
// eslint-disable-next-line no-unused-vars
fetchOptions: (input: string) => Promise<any[]>;
renderTags?: (
// eslint-disable-next-line no-unused-vars
tag: any[],
// eslint-disable-next-line no-unused-vars
getTagProps: AutocompleteGetTagProps,
) => React.ReactNode;
};
Expand Down Expand Up @@ -94,7 +90,6 @@ export const AsyncSelect: FunctionComponent<Props> = ({
debounce(
(
request: { input: string },
// eslint-disable-next-line no-unused-vars
callback: (results?: readonly any[]) => void,
) => {
setLoading(true);
Expand Down Expand Up @@ -139,7 +134,6 @@ export const AsyncSelect: FunctionComponent<Props> = ({
id={keyValue}
renderInput={params => (
<TextField
/* eslint-disable-next-line react/jsx-props-no-spreading */
{...params}
id={keyValue}
disabled={disabled}
Expand Down
18 changes: 2 additions & 16 deletions hat/assets/js/apps/Iaso/components/forms/InputComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export type InputComponentProps = {
keyValue: string;
value?: any;
errors?: string[];
onChange?: // eslint-disable-next-line no-unused-vars
(key: string, value: any, countryData?: BaseCountryData) => void;
onChange?: (key: string, value: any, countryData?: BaseCountryData) => void;

options?: any[];
disabled?: boolean;
Expand All @@ -76,26 +75,17 @@ export type InputComponentProps = {
multi?: boolean;
uid?: string;
loading?: boolean;
// eslint-disable-next-line no-unused-vars
getOptionLabel?: (option: Option) => string;
getOptionSelected?: (
// eslint-disable-next-line no-unused-vars
option: Option,
// eslint-disable-next-line no-unused-vars
value: Option,
) => boolean;
getOptionSelected?: (option: Option, value: Option) => boolean;
renderOption?: (
// eslint-disable-next-line no-unused-vars
option: Option,
// eslint-disable-next-line no-unused-vars
{ inputValue }: { inputValue: string },
) => ReactNode;
className?: string;
helperText?: string;
min?: number;
max?: number;
blockForbiddenChars?: boolean;
// eslint-disable-next-line no-unused-vars
onErrorChange?: (hasError: boolean) => void;
numberInputOptions?: {
prefix?: string;
Expand All @@ -107,10 +97,8 @@ export type InputComponentProps = {
thousandSeparator?: '.' | ',';
};
phoneInputOptions?: PhoneInputOptions;
// eslint-disable-next-line no-unused-vars
setFieldError?: (keyValue: string, message: string) => void;
autoComplete?: string;
// eslint-disable-next-line no-unused-vars
renderTags?: (tagValue: Array<any>, getTagProps: any) => Array<any>;
freeSolo?: boolean; // this props i only use on single select and allow user to give an option not present in the list. Errors will be ignored
returnFullObject?: boolean;
Expand Down Expand Up @@ -240,7 +228,6 @@ const InputComponent: React.FC<InputComponentProps> = ({
}}
setFieldError={setFieldError}
dataTestId={dataTestId}
// eslint-disable-next-line react/jsx-props-no-spreading
{...localizedNumberOptions}
/>
);
Expand Down Expand Up @@ -334,7 +321,6 @@ const InputComponent: React.FC<InputComponentProps> = ({
lang={locale as LangOptions}
required={required}
disabled={disabled}
// eslint-disable-next-line react/jsx-props-no-spreading
{...phoneInputOptions}
/>
);
Expand Down
5 changes: 2 additions & 3 deletions hat/assets/js/apps/Iaso/components/forms/TextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React, { FunctionComponent, useEffect, useRef, useState } from 'react';

import { FormHelperText, InputLabel } from '@mui/material';
import { makeStyles } from '@mui/styles';
import {
FormControl,
commonStyles,
useSkipEffectOnMount,
} from 'bluesquare-components';
import classnames from 'classnames';
import { InputLabel, FormHelperText } from '@mui/material';
import { makeStyles } from '@mui/styles';
import { useDebounce } from 'use-debounce';
import { Optional } from '../../types/utils';

type Props = {
value?: string;
label: string;
// eslint-disable-next-line no-unused-vars
onChange: (newValue: string) => void;
errors?: string[];
required?: boolean;
Expand Down
Loading

0 comments on commit f1dcc22

Please sign in to comment.