Skip to content

Commit

Permalink
Merge pull request #9033 from marmelab/fix-lint-errors-3
Browse files Browse the repository at this point in the history
Fix linter warnings
  • Loading branch information
fzaninotto authored Jun 20, 2023
2 parents 3d26bce + b0d7bb4 commit e0c9c52
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 70 deletions.
2 changes: 1 addition & 1 deletion examples/simple/src/users/UserEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const UserEditForm = () => {
const { save } = useSaveContext();

const newSave = values =>
new Promise((resolve, reject) => {
new Promise(resolve => {
if (values.name === 'test') {
return resolve({
name: {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/users/UserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const UserBulkActionButtons = props => (
<BulkDeleteWithConfirmButton {...props} />
);

const rowClick = memoize(permissions => (id, resource, record) => {
const rowClick = memoize(permissions => () => {
return permissions === 'admin'
? Promise.resolve('edit')
: Promise.resolve('show');
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/auth/useCheckAuth.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const TestComponent = ({
useEffect(() => {
checkAuth(params, logoutOnFailure, redirectTo, disableNotification)
.then(() => setAuthenticated(true))
.catch(error => setAuthenticated(false));
.catch(() => setAuthenticated(false));
}, [params, logoutOnFailure, redirectTo, disableNotification, checkAuth]);
return <div>{authenticated ? 'authenticated' : 'not authenticated'}</div>;
};
Expand Down
12 changes: 6 additions & 6 deletions packages/ra-core/src/auth/useLogin.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('useLogin', () => {
};
const authProvider = {
login: () => Promise.resolve(),
checkError: error => Promise.resolve(),
checkAuth: params => Promise.resolve(),
checkError: () => Promise.resolve(),
checkAuth: () => Promise.resolve(),
logout: () => Promise.resolve(),
getIdentity: () => Promise.resolve({ id: 'joe' }),
getPermissions: () => Promise.resolve(),
Expand All @@ -42,8 +42,8 @@ describe('useLogin', () => {
};
const authProvider = {
login: () => Promise.resolve({ redirectTo: '/foo' }),
checkError: error => Promise.resolve(),
checkAuth: params => Promise.resolve(),
checkError: () => Promise.resolve(),
checkAuth: () => Promise.resolve(),
logout: () => Promise.resolve(),
getIdentity: () => Promise.resolve({ id: 'joe' }),
getPermissions: () => Promise.resolve(),
Expand Down Expand Up @@ -71,8 +71,8 @@ describe('useLogin', () => {
};
const authProvider = {
login: () => Promise.resolve({ redirectTo: false }),
checkError: error => Promise.resolve(),
checkAuth: params => Promise.resolve(),
checkError: () => Promise.resolve(),
checkAuth: () => Promise.resolve(),
logout: () => Promise.resolve(),
getIdentity: () => Promise.resolve({ id: 'joe' }),
getPermissions: () => Promise.resolve(),
Expand Down
8 changes: 2 additions & 6 deletions packages/ra-core/src/controller/create/CreateBase.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ describe('CreateBase', () => {
it('should allow to override the onError function', async () => {
jest.spyOn(console, 'error').mockImplementation(() => {});
const dataProvider = testDataProvider({
create: jest.fn((_, { data }) =>
Promise.reject({ message: 'test' })
),
create: jest.fn(() => Promise.reject({ message: 'test' })),
});
const onError = jest.fn();

Expand Down Expand Up @@ -172,9 +170,7 @@ describe('CreateBase', () => {

it('should allow to override the onError function at call time', async () => {
const dataProvider = testDataProvider({
create: jest.fn((_, { data }) =>
Promise.reject({ message: 'test' })
),
create: jest.fn(() => Promise.reject({ message: 'test' })),
});
const onError = jest.fn();
const onErrorOverride = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ describe('useCreateController', () => {
render(
<CoreAdminContext dataProvider={dataProvider}>
<CreateController {...defaultProps}>
{({ save, record }) => {
{({ save }) => {
saveCallback = save;
return <div />;
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('useEditController', () => {
render(
<CoreAdminContext dataProvider={dataProvider}>
<EditController {...defaultProps} mutationMode="pessimistic">
{({ record, save, saving }) => {
{({ record, save }) => {
return (
<>
<p>{record?.test}</p>
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('useEditController', () => {
let post = { id: 12, test: 'previous' };
const update = jest
.fn()
.mockImplementationOnce((_, { id, data, previousData }) => {
.mockImplementationOnce((_, { data, previousData }) => {
post = { ...previousData, ...data };
return Promise.resolve({ data: post });
});
Expand Down Expand Up @@ -299,7 +299,7 @@ describe('useEditController', () => {
let post = { id: 12 };
const update = jest
.fn()
.mockImplementationOnce((_, { id, data, previousData }) => {
.mockImplementationOnce((_, { data, previousData }) => {
post = { ...previousData, ...data };
return Promise.resolve({ data: post });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,7 @@ describe('useReferenceArrayInputController', () => {
it('should set isLoading to false if enableGetChoices returns false', async () => {
const children = jest.fn().mockReturnValue(<div />);
await new Promise(resolve => setTimeout(resolve, 100)); // empty the query deduplication in useQueryWithStore
const enableGetChoices = jest.fn().mockImplementation(({ q }) => {
return false;
});
const enableGetChoices = jest.fn().mockImplementation(() => false);
render(
<CoreAdminContext dataProvider={testDataProvider()}>
<Form onSubmit={jest.fn()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,7 @@ describe('useInfiniteListController', () => {
it('Does not remove previously shown filter when adding a new one', async () => {
let currentDisplayedFilters;

let childFunction = ({
showFilter,
displayedFilters,
filterValues,
}) => {
let childFunction = ({ showFilter, displayedFilters }) => {
currentDisplayedFilters = displayedFilters;
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,7 @@ describe('useListController', () => {
it('Does not remove previously shown filter when adding a new one', async () => {
let currentDisplayedFilters;

let childFunction = ({
showFilter,
displayedFilters,
filterValues,
}) => {
let childFunction = ({ showFilter, displayedFilters }) => {
currentDisplayedFilters = displayedFilters;
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SaveContext, SaveContextValue } from './SaveContext';
export const useSaveContext = <
PropsType extends SaveContextValue = SaveContextValue
>(
props?: PropsType
_props?: PropsType
): SaveContextValue => {
return useContext(SaveContext);
};
2 changes: 1 addition & 1 deletion packages/ra-core/src/core/CustomRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ReactNode } from 'react';
* @param props.noLayout A boolean indicating whether to render the routes outside the Layout. Defaults to false.
* @returns Nothing. This is a configuration component.
*/
export const CustomRoutes = (props: CustomRoutesProps) => {
export const CustomRoutes = (_props: CustomRoutesProps) => {
return null;
};

Expand Down
1 change: 0 additions & 1 deletion packages/ra-core/src/dataProvider/useGetList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const UseGetList = ({
options = {},
meta = undefined,
callback = null,
...rest
}) => {
const hookValue = useGetList(
resource,
Expand Down
9 changes: 1 addition & 8 deletions packages/ra-core/src/dataProvider/useGetMany.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const UseGetMany = ({
meta = undefined,
options = {},
callback = null,
...rest
}) => {
const hookValue = useGetMany(resource, { ids, meta }, options);
if (callback) callback(hookValue);
Expand All @@ -22,13 +21,7 @@ const UseGetMany = ({

let updateState;

const UseCustomGetMany = ({
resource,
ids,
options = {},
callback = null,
...rest
}) => {
const UseCustomGetMany = ({ resource, ids, options = {}, callback = null }) => {
const [stateIds, setStateIds] = useState(ids);
const hookValue = useGetMany(resource, { ids: stateIds }, options);
if (callback) callback(hookValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const UseGetManyAggregate = ({
ids,
options = {},
callback = null,
...rest
}) => {
const hookValue = useGetManyAggregate(resource, { ids }, options);
if (callback) callback(hookValue);
Expand Down
1 change: 0 additions & 1 deletion packages/ra-core/src/dataProvider/useGetOne.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const UseGetOne = ({
meta = undefined,
options = {},
callback = null,
...rest
}) => {
const hookValue = useGetOne(resource, { id, meta }, options);
if (callback) callback(hookValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Basic = props => {

if (!dataProvider) {
dataProvider = {
getList: (resource, params) => {
getList: (_resource, params) => {
return new Promise(resolve => {
setTimeout(
() =>
Expand Down Expand Up @@ -55,7 +55,6 @@ const UseInfiniteComponent = ({
filter = {},
options = {},
meta = undefined,
...rest
}) => {
const {
data,
Expand Down Expand Up @@ -109,7 +108,7 @@ export const PageInfo = props => {

if (!dataProvider) {
dataProvider = {
getList: (resource, params) => {
getList: (_resource, params) => {
return new Promise(resolve => {
setTimeout(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ describe('withLifecycleCallbacks', () => {
describe('afterUpdateMany', () => {
it('should update the updateMany result', async () => {
const base = {
updateMany: jest.fn((resource, { ids, data }) =>
updateMany: jest.fn((resource, { ids }) =>
Promise.resolve({ data: ids })
),
};
Expand Down Expand Up @@ -716,7 +716,7 @@ describe('withLifecycleCallbacks', () => {
data: ids.map(id => ({ id })),
})
),
updateMany: jest.fn((resource, { ids, data }) =>
updateMany: jest.fn((resource, { ids }) =>
Promise.resolve({ data: ids })
),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/form/getFormInitialValues.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('getFormInitialValues', () => {
jest.spyOn(console, 'warn').mockImplementationOnce(() => {});
expect(
getFormInitialValues(
record => ({
() => ({
value1: 'value1',
value2: 'value2',
}),
Expand Down
8 changes: 1 addition & 7 deletions packages/ra-core/src/form/useAugmentedForm.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
BaseSyntheticEvent,
useCallback,
useMemo,
useEffect,
useRef,
} from 'react';
import { BaseSyntheticEvent, useCallback, useMemo, useRef } from 'react';
import {
FieldValues,
SubmitHandler,
Expand Down
6 changes: 2 additions & 4 deletions packages/ra-no-code/src/ui/NewResourceMenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { styled } from '@mui/material/styles';
import { MouseEvent, ReactElement, useState } from 'react';
import { ReactElement, useState } from 'react';
import AddIcon from '@mui/icons-material/Add';
import { ImportResourceDialog } from './ImportResourceDialog';
import {
Expand Down Expand Up @@ -39,9 +39,7 @@ export const NewResourceMenuItem = (
false
);

const handleClick = (
event: MouseEvent<HTMLAnchorElement> & MouseEvent<HTMLLIElement>
) => {
const handleClick = () => {
setShowImportResourceDialog(true);
};

Expand Down
4 changes: 2 additions & 2 deletions packages/ra-no-code/src/ui/ResourceMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const classes = {
settings: `${PREFIX}-settings`,
};

const Root = styled('div')(({ theme }) => ({
const Root = styled('div')({
[`&.${classes.root}`]: {
display: 'flex',
},
Expand All @@ -27,7 +27,7 @@ const Root = styled('div')(({ theme }) => ({
[`& .${classes.settings}`]: {
marginLeft: 'auto',
},
}));
});

export const ResourceMenuItem = (
props: Omit<MenuItemLinkProps, 'to' | 'resource'> & {
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-no-code/src/ui/useImportResourceFromCsv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useImportResourceFromCsv = (): [boolean, ImportResource] => {
.create(resource, {
data: record,
})
.catch(error => {
.catch(() => {
// Ignore errors while adding a single record
console.error(
`Error while importing record ${JSON.stringify(
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-ui-materialui/src/Labeled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const LabeledClasses = {
const Root = styled(Stack, {
name: PREFIX,
overridesResolver: (props, styles) => styles.root,
})(({ theme }) => ({
})({
display: 'inline-flex',
marginBottom: '0.2em',

Expand All @@ -101,4 +101,4 @@ const Root = styled(Stack, {
fontSize: '0.75em',
marginBottom: '0.2em',
},
}));
});
4 changes: 2 additions & 2 deletions packages/ra-ui-materialui/src/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export const LinkClasses = {
link: `${PREFIX}-link`,
};

const StyledMuiLink = styled(MuiLink)(({ theme }) => ({
const StyledMuiLink = styled(MuiLink)({
[`&.${LinkClasses.link}`]: {
textDecoration: 'none',
},
})) as typeof MuiLink; // @see https://mui.com/material-ui/guides/typescript/#complications-with-the-component-prop
}) as typeof MuiLink; // @see https://mui.com/material-ui/guides/typescript/#complications-with-the-component-prop

// @see https://mui.com/material-ui/guides/composition/#with-typescript
export interface LinkProps
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/AutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ If you provided a React element for the optionText prop, you must also provide t
throw new Error(`
If you provided a React element for the optionText prop, you must also provide the matchSuggestion prop (used to match the user input with a choice)`);
}
}, [optionText, inputText, matchSuggestion, emptyText]);
}, [optionText, inputText, matchSuggestion, emptyText, isFromReference]);

useEffect(() => {
warning(
Expand Down

0 comments on commit e0c9c52

Please sign in to comment.