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 #8978

Merged
merged 4 commits into from
Jun 7, 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
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
"caughtErrorsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion cypress/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
setupNodeEvents(on) {
on('before:browser:launch', (browser = {}, launchOptions) => {
// Fix for Cypress 4:
// https://docs.cypress.io/api/plugins/browser-launch-api.html#Usage
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/edit.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Edit Page', () => {
cy.contains('Required');
// FIXME: We navigate away from the page and confirm the unsaved changes
// This is needed because HashHistory would prevent further navigation
cy.window().then(win => {
cy.window().then(() => {
cy.on('window:confirm', () => true);
});
cy.get('.RaSidebar-fixed [role="menuitem"]:first-child').click();
Expand Down
2 changes: 1 addition & 1 deletion examples/crm/src/dataGenerator/sales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { name, internet } from 'faker/locale/en_US';

import { Db } from './types';

export const generateSales = (db: Db) => {
export const generateSales = (_: Db) => {
const randomSales = Array.from(Array(10).keys()).map(id => {
const first_name = name.firstName();
const last_name = name.lastName();
Expand Down
2 changes: 1 addition & 1 deletion examples/crm/src/dataGenerator/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ const tags = [
{ id: 5, name: 'vip', color: '#dbe7e4' },
];

export const generateTags = (db: Db) => {
export const generateTags = (_: Db) => {
return [...tags];
};
2 changes: 1 addition & 1 deletion examples/crm/src/deals/OnlyMineInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { useListFilterContext, useGetIdentity } from 'react-admin';
import { Box, Switch, FormControlLabel } from '@mui/material';

export const OnlyMineInput = ({ alwaysOn }: { alwaysOn: boolean }) => {
export const OnlyMineInput = (_: { alwaysOn: boolean }) => {
const {
filterValues,
displayedFilters,
Expand Down
7 changes: 1 addition & 6 deletions examples/demo/src/orders/MobileGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ import {
BooleanField,
useTranslate,
useListContext,
RaRecord,
RecordContextProvider,
} from 'react-admin';

import CustomerReferenceField from '../visitors/CustomerReferenceField';
import { Order } from '../types';

interface MobileGridProps {
data?: RaRecord[];
}

const MobileGrid = (props: MobileGridProps) => {
const MobileGrid = () => {
const { data, isLoading } = useListContext<Order>();
const translate = useTranslate();
if (isLoading || data.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/products/ThumbnailField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Img = styled('img')({
verticalAlign: 'middle',
});

const ThumbnailField = (props: { source: string; label?: string }) => {
const ThumbnailField = (_: { source: string; label?: string }) => {
const record = useRecordContext<Product>();
if (!record) return null;
return <Img src={record.thumbnail} alt="" />;
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/visitors/CustomerLinkField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Link, FieldProps, useRecordContext } from 'react-admin';
import FullNameField from './FullNameField';
import { Customer } from '../types';

const CustomerLinkField = (props: FieldProps<Customer>) => {
const CustomerLinkField = (_: FieldProps<Customer>) => {
const record = useRecordContext<Customer>();
if (!record) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/visitors/SegmentsField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const segmentsById = segments.reduce((acc, segment) => {
return acc;
}, {} as { [key: string]: any });

const SegmentsField = (props: FieldProps) => {
const SegmentsField = (_: FieldProps) => {
const translate = useTranslate();
const record = useRecordContext<Customer>();
if (!record || !record.groups) {
Expand Down
9 changes: 2 additions & 7 deletions examples/simple/src/posts/PostCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import { useFormContext, useWatch } from 'react-hook-form';
import { Button, Dialog, DialogActions, DialogContent } from '@mui/material';

const PostCreateToolbar = props => {
const PostCreateToolbar = () => {
const notify = useNotify();
const redirect = useRedirect();
const { reset } = useFormContext();
Expand Down Expand Up @@ -163,12 +163,7 @@ const PostCreate = () => {
/>
</ReferenceInput>
<FormDataConsumer>
{({
formData,
scopedFormData,
getSource,
...rest
}) =>
{({ scopedFormData, getSource, ...rest }) =>
scopedFormData && scopedFormData.user_id ? (
<SelectInput
source={getSource('role')}
Expand Down
8 changes: 2 additions & 6 deletions examples/simple/src/posts/PostEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const EditActions = ({ hasShow }: EditActionsProps) => (
);

const SanitizedBox = ({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
fullWidth,
...props
}: BoxProps & { fullWidth?: boolean }) => <Box {...props} />;
Expand Down Expand Up @@ -156,12 +157,7 @@ const PostEdit = () => {
<AutocompleteInput helperText={false} />
</ReferenceInput>
<FormDataConsumer>
{({
formData,
scopedFormData,
getSource,
...rest
}) =>
{({ scopedFormData, getSource, ...rest }) =>
scopedFormData &&
scopedFormData.user_id ? (
<SelectInput
Expand Down
34 changes: 23 additions & 11 deletions examples/simple/src/posts/PostList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ import {
import ResetViewsButton from './ResetViewsButton';
export const PostIcon = BookIcon;

const QuickFilter = ({ label, source, defaultValue }) => {
const QuickFilter = ({
label,
}: {
label?: string;
source?: string;
defaultValue?: any;
}) => {
const translate = useTranslate();
return <Chip sx={{ marginBottom: 1 }} label={translate(label)} />;
};
Expand Down Expand Up @@ -104,13 +110,19 @@ const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
'& .publishedAt': { fontStyle: 'italic' },
}));

const PostListBulkActions = memo(({ children, ...props }) => (
<Fragment>
<ResetViewsButton {...props} />
<BulkDeleteButton {...props} />
<BulkExportButton {...props} />
</Fragment>
));
const PostListBulkActions = memo(
({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
children,
...props
}) => (
<Fragment>
<ResetViewsButton {...props} />
<BulkDeleteButton {...props} />
<BulkExportButton {...props} />
</Fragment>
)
);

const PostListActions = () => (
<TopToolbar>
Expand All @@ -121,19 +133,19 @@ const PostListActions = () => (
</TopToolbar>
);

const PostListActionToolbar = ({ children, ...props }) => (
const PostListActionToolbar = ({ children }) => (
<Box sx={{ alignItems: 'center', display: 'flex' }}>{children}</Box>
);

const rowClick = (id, resource, record) => {
const rowClick = (_id, _resource, record) => {
if (record.commentable) {
return 'edit';
}

return 'show';
};

const PostPanel = ({ id, record, resource }) => (
const PostPanel = ({ record }) => (
<div dangerouslySetInnerHTML={{ __html: record.body }} />
);

Expand Down
2 changes: 1 addition & 1 deletion examples/simple/src/users/UserCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const UserEditToolbar = ({ permissions, ...props }) => {
<SaveButton
label="user.action.save_and_add"
mutationOptions={{
onSuccess: data => {
onSuccess: () => {
notify('ra.notification.created', {
type: 'info',
messageArgs: {
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-ui-materialui/src/input/AutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ If you provided a React element for the optionText prop, you must also provide t
const handleInputChange = (
event: any,
newInputValue: string,
reason: string
_reason: string
) => {
if (
event?.type === 'change' ||
Expand Down Expand Up @@ -511,7 +511,7 @@ If you provided a React element for the optionText prop, you must also provide t
const handleAutocompleteChange = (
event: any,
newValue: any,
reason: string
_reason: string
) => {
handleChangeWithCreateSupport(newValue != null ? newValue : emptyValue);
};
Expand Down
14 changes: 7 additions & 7 deletions packages/ra-ui-materialui/src/input/DatagridInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ReferenceArrayInput } from './ReferenceArrayInput';
export default { title: 'ra-ui-materialui/input/DatagridInput' };

const dataProvider = {
getOne: (resource, params) =>
getOne: () =>
Promise.resolve({
data: {
id: 1,
Expand All @@ -23,7 +23,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 @@ -74,7 +74,7 @@ const authors = [
];

const dataProviderWithAuthors = {
getOne: (resource, params) =>
getOne: () =>
Promise.resolve({
data: {
id: 1,
Expand All @@ -85,11 +85,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 @@ -119,8 +119,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
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/DateInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('<DateInput />', () => {
onSubmit={onSubmit}
defaultValues={{ publishedAt: new Date('2021-09-11') }}
>
<DateInput {...defaultProps} parse={val => null} />
<DateInput {...defaultProps} parse={() => null} />
</SimpleForm>
</AdminContext>
);
Expand Down
8 changes: 4 additions & 4 deletions packages/ra-ui-materialui/src/input/FileInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe('<FileInput />', () => {
>
<FileInput
{...defaultProps}
validateFileRemoval={file => {
validateFileRemoval={() => {
throw Error('Cancel Removal Action');
}}
>
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('<FileInput />', () => {
>
<FileInput
{...defaultProps}
validateFileRemoval={async file => {
validateFileRemoval={async () => {
throw Error('Cancel Removal Action');
}}
>
Expand Down Expand Up @@ -381,7 +381,7 @@ describe('<FileInput />', () => {
>
<FileInput
{...defaultProps}
validateFileRemoval={file => true}
validateFileRemoval={() => true}
>
<FileField source="src" title="title" />
</FileInput>
Expand Down Expand Up @@ -420,7 +420,7 @@ describe('<FileInput />', () => {
>
<FileInput
{...defaultProps}
validateFileRemoval={async file => true}
validateFileRemoval={async () => true}
>
<FileField source="src" title="title" />
</FileInput>
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/input/NumberInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ describe('<NumberInput />', () => {
>
<NumberInput
{...defaultProps}
validate={value => undefined}
validate={() => undefined}
/>
</SimpleForm>
</AdminContext>
Expand Down
Loading