Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter warnings #9024

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions packages/ra-core/src/controller/edit/EditBase.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,11 @@ describe('EditBase', () => {
it('should allow to override the onError function', async () => {
jest.spyOn(console, 'error').mockImplementation(() => {});
const dataProvider = testDataProvider({
// @ts-ignore
getOne: () =>
// @ts-ignore
Promise.resolve({ data: { id: 12, test: 'previous' } }),
update: jest.fn((_, { id, data, previousData }) =>
Promise.reject({ message: 'test' })
),
// @ts-ignore
update: jest.fn(() => Promise.reject({ message: 'test' })),
});
const onError = jest.fn();

Expand Down Expand Up @@ -248,12 +247,11 @@ describe('EditBase', () => {

it('should allow to override the onError function at call time', async () => {
const dataProvider = testDataProvider({
// @ts-ignore
getOne: () =>
// @ts-ignore
Promise.resolve({ data: { id: 12, test: 'previous' } }),
update: jest.fn((_, { id, data, previousData }) =>
Promise.reject({ message: 'test' })
),
// @ts-ignore
update: jest.fn(() => Promise.reject({ message: 'test' })),
});
const onError = jest.fn();
const onErrorOverride = jest.fn();
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-core/src/form/validate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ describe('Validators', () => {
});

describe('composeValidators', () => {
const asyncSuccessfullValidator = async =>
const asyncSuccessfullValidator = async () =>
new Promise(resolve => resolve(undefined));
const asyncFailedValidator = async =>
const asyncFailedValidator = async () =>
new Promise(resolve => resolve('async'));

it('Correctly composes validators passed as an array', async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/ra-data-graphql-simple/src/getResponseParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { IntrospectionResult, IntrospectedResource } from 'ra-data-graphql';
import { IntrospectionField } from 'graphql';
import { ApolloQueryResult } from '@apollo/client';

export default (introspectionResults: IntrospectionResult) => (
export default (_introspectionResults: IntrospectionResult) => (
raFetchMethod: string,
resource: IntrospectedResource,
queryType: IntrospectionField
_resource: IntrospectedResource,
_queryType: IntrospectionField
) => (response: ApolloQueryResult<any>) => {
const data = response.data;

Expand Down
4 changes: 2 additions & 2 deletions packages/ra-ui-materialui/src/auth/Logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export const LogoutClasses = {
const StyledMenuItem = styled(MenuItem, {
name: PREFIX,
overridesResolver: (props, styles) => styles.root,
})(({ theme }) => ({
})({
[`& .${LogoutClasses.icon}`]: {},
}));
});

export interface LogoutProps {
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/button/SaveButton.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe('<SaveButton />', () => {
}),
});

const validateAsync = async (value, allValues) => {
const validateAsync = async value => {
await new Promise(resolve => setTimeout(resolve, 250));
if (value === 'ipsum') {
return 'Already used!';
Expand Down
2 changes: 2 additions & 0 deletions packages/ra-ui-materialui/src/detail/CreateActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ export const CreateActions = ({ className, ...rest }: CreateActionsProps) => {
);
};

/* eslint-disable @typescript-eslint/no-unused-vars */
const sanitizeRestProps = ({
className = null,
hasList = null,
resource = null,
...rest
}) => rest;
/* eslint-enable @typescript-eslint/no-unused-vars */

export interface CreateActionsProps {
className?: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/ra-ui-materialui/src/detail/CreateView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ CreateView.propTypes = {
title: PropTypes.node,
};

/* eslint-disable @typescript-eslint/no-unused-vars */
const sanitizeRestProps = ({
addMiddleware = null,
defaultTitle = null,
Expand All @@ -92,6 +93,7 @@ const sanitizeRestProps = ({
removeMiddleware = null,
...rest
}) => rest;
/* eslint-enable @typescript-eslint/no-unused-vars */

const PREFIX = 'RaCreate';

Expand Down
2 changes: 2 additions & 0 deletions packages/ra-ui-materialui/src/detail/EditActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ export const EditActions = ({ className, ...rest }: EditActionsProps) => {
);
};

/* eslint-disable @typescript-eslint/no-unused-vars */
const sanitizeRestProps = ({
hasCreate = null,
hasEdit = null,
hasShow = null,
hasList = null,
...rest
}) => rest;
/* eslint-enable @typescript-eslint/no-unused-vars */

export interface EditActionsProps {
className?: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/ra-ui-materialui/src/detail/EditView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ EditView.propTypes = {
title: PropTypes.node,
};

/* eslint-disable @typescript-eslint/no-unused-vars */
const sanitizeRestProps = ({
addMiddleware = null,
defaultTitle = null,
Expand All @@ -117,6 +118,7 @@ const sanitizeRestProps = ({
transform = null,
...rest
}) => rest;
/* eslint-enable @typescript-eslint/no-unused-vars */

const PREFIX = 'RaEdit';

Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/detail/Show.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Show } from './Show';
export default { title: 'ra-ui-materialui/detail/Show' };

const dataProvider = {
getOne: (resource, params) =>
getOne: () =>
Promise.resolve({
data: {
id: 1,
Expand Down
6 changes: 4 additions & 2 deletions packages/ra-ui-materialui/src/detail/ShowView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ShowView.propTypes = {
title: PropTypes.any,
};

/* eslint-disable @typescript-eslint/no-unused-vars */
const sanitizeRestProps = ({
defaultTitle = null,
hasCreate = null,
Expand All @@ -82,6 +83,7 @@ const sanitizeRestProps = ({
permissions = null,
...rest
}) => rest;
/* eslint-enable @typescript-eslint/no-unused-vars */

const PREFIX = 'RaShow';

Expand All @@ -94,7 +96,7 @@ export const ShowClasses = {
const Root = styled('div', {
name: PREFIX,
overridesResolver: (props, styles) => styles.root,
})(({ theme }) => ({
})({
[`& .${ShowClasses.main}`]: {
display: 'flex',
},
Expand All @@ -104,4 +106,4 @@ const Root = styled('div', {
[`& .${ShowClasses.card}`]: {
flex: '1 1 auto',
},
}));
});
5 changes: 1 addition & 4 deletions packages/ra-ui-materialui/src/detail/editFieldTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ ${children.map(child => ` ${child.getRepresentation()}`).join('\n')}
},
reference: {
component: ReferenceInput,
representation: (
props: ReferenceInputProps,
children: InferredElement
) =>
representation: (props: ReferenceInputProps) =>
`<ReferenceInput source="${props.source}" reference="${props.reference}" />`,
},
referenceArray: {
Expand Down
16 changes: 10 additions & 6 deletions packages/ra-ui-materialui/src/field/ReferenceField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const Wrapper = ({
<ResourceDefinitionContextProvider
definitions={{
book_details: {
name: 'book_details',
hasShow: true,
hasEdit: true,
},
Expand All @@ -90,7 +91,7 @@ export const Basic = () => (
);

const slowDataProvider = {
getMany: (resource, params) =>
getMany: () =>
new Promise(resolve => {
setTimeout(
() => resolve({ data: [{ id: 1, ISBN: '9780393966473' }] }),
Expand Down Expand Up @@ -165,6 +166,7 @@ export const LinkWithoutEditView = () => (
<ResourceDefinitionContextProvider
definitions={{
book_details: {
name: 'book_details',
hasEdit: false,
},
}}
Expand Down Expand Up @@ -288,11 +290,13 @@ const ListWrapper = ({ children }) => (
<ThemeProvider theme={createTheme()}>
<Wrapper>
<ListContextProvider
value={{
total: 1,
data: [{ id: 1, title: 'War and Peace', detail_id: 1 }],
sort: { field: 'title', order: 'ASC' },
}}
value={
{
total: 1,
data: [{ id: 1, title: 'War and Peace', detail_id: 1 }],
sort: { field: 'title', order: 'ASC' },
} as any
}
>
{children}
</ListContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const Basic = () => (
);

const slowDataProvider = {
getManyReference: (resource, params) =>
getManyReference: () =>
new Promise(resolve => {
setTimeout(
() =>
Expand All @@ -92,7 +92,7 @@ export const Loading = () => (
);

const emptyDataProvider = {
getManyReference: (resource, params) =>
getManyReference: () =>
Promise.resolve({
data: [],
total: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AutocompleteInput } from '../AutocompleteInput';
export default { title: 'ra-ui-materialui/input/ArrayInput' };

const dataProvider = {
getOne: (resource, params) =>
getOne: () =>
Promise.resolve({
data: {
id: 1,
Expand All @@ -34,8 +34,8 @@ const dataProvider = {
tags: ['novel', 'war', 'classic'],
},
}),
update: (resource, params) => Promise.resolve(params),
create: (resource, params) => {
update: (_resource, params) => Promise.resolve(params),
create: (_resource, params) => {
return Promise.resolve({ data: { ...params.data, id: 2 } });
},
} as any;
Expand Down Expand Up @@ -218,8 +218,8 @@ export const Realistic = () => (
<Admin
dataProvider={
{
getOne: (resource, params) => Promise.resolve({ data: order }),
update: (resource, params) => Promise.resolve(params),
getOne: () => Promise.resolve({ data: order }),
update: (_resource, params) => Promise.resolve(params),
} as any
}
history={createMemoryHistory({ initialEntries: ['/orders/1'] })}
Expand Down Expand Up @@ -279,8 +279,8 @@ export const NestedInline = () => (
<Admin
dataProvider={
{
getOne: (resource, params) => Promise.resolve({ data: order }),
update: (resource, params) => Promise.resolve(params),
getOne: () => Promise.resolve({ data: order }),
update: (_resource, params) => Promise.resolve(params),
} as any
}
history={createMemoryHistory({ initialEntries: ['/orders/1'] })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ describe('<SimpleFormIterator />', () => {
});

it('should not display the default reorder element if a custom reorder element is passed', () => {
const CustomReOrderButtons = props => (
const CustomReOrderButtons = () => (
<button>Custom reorder Button</button>
);

Expand Down Expand Up @@ -792,7 +792,7 @@ describe('<SimpleFormIterator />', () => {
<SimpleFormIterator>
<TextInput source="email" label="Email" />
<FormDataConsumer>
{({ scopedFormData, getSource }) => (
{({ getSource }) => (
<TextInput
label="Role"
source={(getSource as (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ describe('<AutocompleteArrayInput />', () => {
]}
optionText={<SuggestionItem />}
inputText={choice => choice?.name}
matchSuggestion={(filter, choice) => true}
matchSuggestion={() => true}
/>
</SimpleForm>
</AdminContext>
Expand Down Expand Up @@ -872,7 +872,7 @@ describe('<AutocompleteArrayInput />', () => {
resource="posts"
choices={choices}
onCreate={handleCreate}
optionText={choice => `Choice is not displayed`}
optionText={() => `Choice is not displayed`}
/>
</SimpleForm>
</AdminContext>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import * as React from 'react';
import { Admin } from 'react-admin';
import {
RaRecord,
Resource,
required,
useCreate,
useRecordContext,
} from 'ra-core';
import { Resource, required, useCreate, useRecordContext } from 'ra-core';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import englishMessages from 'ra-language-english';
import { createMemoryHistory } from 'history';
Expand Down Expand Up @@ -111,7 +105,7 @@ export const CreateProp = () => (
);

const dataProvider = {
getOne: (resource, params) =>
getOne: () =>
Promise.resolve({
data: {
id: 1,
Expand All @@ -122,7 +116,7 @@ const dataProvider = {
year: 1869,
},
}),
update: (resource, params) => Promise.resolve(params),
update: (_resource, params) => Promise.resolve(params),
} as any;

const history = createMemoryHistory({ initialEntries: ['/books/1'] });
Expand Down Expand Up @@ -346,7 +340,7 @@ const authors = [
];

const dataProviderWithAuthors = {
getOne: (resource, params) =>
getOne: () =>
Promise.resolve({
data: {
id: 1,
Expand All @@ -357,11 +351,11 @@ const dataProviderWithAuthors = {
year: 1869,
},
}),
getMany: (resource, params) =>
getMany: (_resource, params) =>
Promise.resolve({
data: authors.filter(author => params.ids.includes(author.id)),
}),
getList: (resource, params) =>
getList: (_resource, params) =>
new Promise(resolve => {
// eslint-disable-next-line eqeqeq
if (params.filter.q == undefined) {
Expand Down Expand Up @@ -391,8 +385,8 @@ const dataProviderWithAuthors = {
500
);
}),
update: (resource, params) => Promise.resolve(params),
create: (resource, params) => {
update: (_resource, params) => Promise.resolve(params),
create: (_resource, params) => {
const newAuthor = {
id: authors.length + 1,
name: params.data.name,
Expand Down
Loading