Skip to content

Commit

Permalink
Fix remaining warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Gildas Garcia authored and djhi committed Jun 12, 2019
1 parent 1a72c85 commit 7d535a8
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 71 deletions.
2 changes: 1 addition & 1 deletion examples/data-generator/src/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default (db, { serializeDate }) => {
(total_ex_taxes + delivery_fees + taxes).toFixed(2)
),
status: status,
returned: status == 'delivered' ? weightedBoolean(10) : false,
returned: status === 'delivered' ? weightedBoolean(10) : false,
};
});
};
4 changes: 2 additions & 2 deletions examples/data-generator/src/finalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ export default function(db) {
customers[command.customer_id].nbProducts += command.basket.length;
return customers;
}, {});
Object.keys(customersBySpending).map(customer_id => {
Object.keys(customersBySpending).forEach(customer_id => {
if (customersBySpending[customer_id].nbProducts > 10) {
db.customers[customer_id].groups.push('collector');
}
});

// add 'ordered_once' group
db.customers
.filter(customer => customer.nb_commands == 1)
.filter(customer => customer.nb_commands === 1)
.forEach(customer => customer.groups.push('ordered_once'));

// add 'compulsive' group
Expand Down
6 changes: 1 addition & 5 deletions examples/data-generator/src/invoices.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { random, lorem } from 'faker/locale/en';
import subDays from 'date-fns/sub_days';
import { randomDate } from './utils';

export default (db, { serializeDate }) => {
export default db => {
let id = 0;

return db.commands
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/actions/dataActions/crudUpdateMany.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Identifier, Record } from '../../types';
import { Identifier } from '../../types';
import { UPDATE_MANY } from '../../dataFetchActions';
import { FETCH_END, FETCH_ERROR } from '../fetchActions';
import { NotificationSideEffect, RefreshSideEffect } from '../../sideEffect';
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/controller/CreateController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const CreateController = (props: Props) => {
(data: Partial<Record>, redirect: RedirectionSideEffect) => {
dispatch(crudCreate(resource, data, basePath, redirect));
},
[resource, basePath]
[resource, basePath] // eslint-disable-line react-hooks/exhaustive-deps
);

if (!children) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-core/src/controller/EditController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const EditController = (props: Props) => {

useEffect(() => {
dispatch(resetForm(REDUX_FORM_NAME));
}, [resource, id, version]);
}, [resource, id, version]); // eslint-disable-line react-hooks/exhaustive-deps

const resourceName = translate(`resources.${resource}.name`, {
smart_count: 1,
Expand Down Expand Up @@ -130,7 +130,7 @@ const EditController = (props: Props) => {
dispatch(updateAction);
}
},
[resource, id, record, basePath, undoable]
[resource, id, record, basePath, undoable] // eslint-disable-line react-hooks/exhaustive-deps
);

if (!children) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render, cleanup } from 'react-testing-library';
import { cleanup } from 'react-testing-library';

import ReferenceFieldController from './ReferenceFieldController';
import renderWithRedux from '../../util/renderWithRedux';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import assert from 'assert';
import { render } from 'react-testing-library';

import ReferenceManyFieldController from './ReferenceManyFieldController';
import renderWithRedux from '../../util/renderWithRedux';
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/controller/field/useReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const useReference = ({
if (sourceId !== null && typeof sourceId !== 'undefined') {
dispatch(crudGetManyAccumulate(reference, [sourceId]));
}
}, [sourceId, reference]);
}, [sourceId, reference]); // eslint-disable-line react-hooks/exhaustive-deps
const rootPath = basePath.replace(resource, reference);
const resourceLinkPath = !linkType
? false
Expand Down
8 changes: 4 additions & 4 deletions packages/ra-core/src/controller/field/useReferenceArray.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FunctionComponent, ReactNode, useEffect, ReactElement } from 'react';
import { useEffect } from 'react';
// @ts-ignore
import { useDispatch, useSelector } from 'react-redux';
import get from 'lodash/get';

import { crudGetManyAccumulate } from '../../actions';
import { getReferencesByIds } from '../../reducer/admin/references/oneToMany';
import { ReduxState, Record, RecordMap, Sort, Identifier } from '../../types';
import { ReduxState, Record, RecordMap, Identifier } from '../../types';

interface ReferenceArrayProps {
loadedOnce: boolean;
Expand Down Expand Up @@ -70,12 +70,12 @@ const useReferenceArray = ({
);
useEffect(() => {
dispatch(crudGetManyAccumulate(reference, ids));
}, [reference, ids, record.id]);
}, [reference, ids, record.id]); // eslint-disable-line react-hooks/exhaustive-deps

const referenceBasePath = basePath.replace(resource, reference); // FIXME obviously very weak

return {
// tslint:disable-next-line:triple-equals
// eslint-disable-next-line eqeqeq
loadedOnce: data != undefined,
ids,
data,
Expand Down
14 changes: 7 additions & 7 deletions packages/ra-core/src/controller/useListParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const useListParams = ({
sort,
perPage,
}),
requestSignature
requestSignature // eslint-disable-line react-hooks/exhaustive-deps
);

const changeParams = useCallback(action => {
Expand All @@ -151,21 +151,21 @@ const useListParams = ({
})
);
dispatch(changeListParams(resource, newParams));
}, requestSignature);
}, requestSignature); // eslint-disable-line react-hooks/exhaustive-deps

const setSort = useCallback(
newSort => changeParams({ type: SET_SORT, payload: { sort: newSort } }),
requestSignature
requestSignature // eslint-disable-line react-hooks/exhaustive-deps
);

const setPage = useCallback(
newPage => changeParams({ type: SET_PAGE, payload: newPage }),
requestSignature
requestSignature // eslint-disable-line react-hooks/exhaustive-deps
);

const setPerPage = useCallback(
newPerPage => changeParams({ type: SET_PER_PAGE, payload: newPerPage }),
requestSignature
requestSignature // eslint-disable-line react-hooks/exhaustive-deps
);

const filterValues = query.filter || emptyObject;
Expand All @@ -190,7 +190,7 @@ const useListParams = ({
setDisplayedFilters({ [filterName]: false });
const newFilters = removeKey(filterValues, filterName);
setFilters(newFilters);
}, requestSignature);
}, requestSignature); // eslint-disable-line react-hooks/exhaustive-deps

const showFilter = useCallback((filterName: string, defaultValue: any) => {
setDisplayedFilters({ [filterName]: true });
Expand All @@ -200,7 +200,7 @@ const useListParams = ({
[filterName]: defaultValue,
});
}
}, requestSignature);
}, requestSignature); // eslint-disable-line react-hooks/exhaustive-deps

return [
{
Expand Down
6 changes: 3 additions & 3 deletions packages/ra-core/src/controller/useRecordSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ const useSelectItems = (resource: string) => {
(newIds: Identifier[]) => {
dispatch(setListSelectedIds(resource, newIds));
},
[resource]
[resource] // eslint-disable-line react-hooks/exhaustive-deps
),
toggle: useCallback(
(id: Identifier) => {
dispatch(toggleListItem(resource, id));
},
[resource]
[resource] // eslint-disable-line react-hooks/exhaustive-deps
),
clearSelection: useCallback(() => {
dispatch(setListSelectedIds(resource, []));
}, [resource]),
}, [resource]), // eslint-disable-line react-hooks/exhaustive-deps
};
return [selectedIds, selectionModifiers];
};
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/controller/useSortState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default (
return;
}
dispatch(initialSort);
}, [initialSort.field, initialSort.order]);
}, [initialSort.field, initialSort.order]); // eslint-disable-line react-hooks/exhaustive-deps

return {
setSort: (field: string) => dispatch(field),
Expand Down
3 changes: 1 addition & 2 deletions packages/ra-core/src/fetch/useDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ const useDataProvider = () => {
: dispatch(queryAction);
});
},

[]
[] // eslint-disable-line react-hooks/exhaustive-deps
);
};

Expand Down
3 changes: 2 additions & 1 deletion packages/ra-core/src/fetch/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ const useMutation = (
loaded: false,
});
});
}, [JSON.stringify({ query, options })]); // deep equality, see https://github.com/facebook/react/issues/14476#issuecomment-471199055
// deep equality, see https://github.com/facebook/react/issues/14476#issuecomment-471199055
}, [JSON.stringify({ query, options })]); // eslint-disable-line react-hooks/exhaustive-deps

return [mutate, state];
};
Expand Down
3 changes: 2 additions & 1 deletion packages/ra-core/src/fetch/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ const useQuery = (
loaded: false,
});
});
}, [JSON.stringify({ query, options })]); // deep equality, see https://github.com/facebook/react/issues/14476#issuecomment-471199055
// deep equality, see https://github.com/facebook/react/issues/14476#issuecomment-471199055
}, [JSON.stringify({ query, options })]); // eslint-disable-line react-hooks/exhaustive-deps

return state;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/ra-core/src/reducer/admin/references/oneToMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const getReferences = (state: ReduxState, reference, relatedTo) => {
const resource = state.admin.resources[reference];

if (!resource) {
return;
return undefined;
}

return resource.data[id];
Expand Down Expand Up @@ -124,7 +124,7 @@ export const getReferencesByIds = (
const resource = state.admin.resources[reference];

if (!resource) {
return;
return undefined;
}

return resource.data[id];
Expand Down
1 change: 0 additions & 1 deletion packages/ra-core/src/reducer/admin/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
STOP_OPTIMISTIC_MODE,
StopOptimisticModeAction,
} from '../../actions';
import { number } from '../../form';

type ActionTypes =
| ToggleSidebarAction
Expand Down
6 changes: 3 additions & 3 deletions packages/ra-data-graphcool/src/buildVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const buildGetListVariables = introspectionResults => (
const parts = key.split('.');

if (parts.length > 1) {
if (parts[1] == 'id') {
if (parts[1] === 'id') {
const type = introspectionResults.types.find(
t => t.name === `${resource.type.name}Filter`
);
Expand Down Expand Up @@ -157,7 +157,6 @@ export default introspectionResults => (
queryType
);
}

case CREATE: {
return buildCreateUpdateVariables(introspectionResults)(
resource,
Expand All @@ -166,10 +165,11 @@ export default introspectionResults => (
queryType
);
}

case DELETE:
return {
id: params.id,
};
default:
console.log('Unknown fetch verb');
}
};
10 changes: 3 additions & 7 deletions packages/ra-data-graphql-simple/src/buildVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const buildGetListVariables = introspectionResults => (
const parts = key.split('.');

if (parts.length > 1) {
if (parts[1] == 'id') {
if (parts[1] === 'id') {
const type = introspectionResults.types.find(
t => t.name === `${resource.type.name}Filter`
);
Expand Down Expand Up @@ -240,24 +240,20 @@ export default introspectionResults => (
queryType
);
}

case GET_MANY:
return {
filter: { ids: preparedParams.ids },
};

case GET_MANY_REFERENCE: {
const parts = preparedParams.target.split('.');
return {
filter: { [`${parts[0]}Id`]: preparedParams.id },
};
}

case GET_ONE:
return {
id: preparedParams.id,
};

case UPDATE: {
return buildCreateUpdateVariables(introspectionResults)(
resource,
Expand All @@ -266,7 +262,6 @@ export default introspectionResults => (
queryType
);
}

case CREATE: {
return buildCreateUpdateVariables(introspectionResults)(
resource,
Expand All @@ -275,10 +270,11 @@ export default introspectionResults => (
queryType
);
}

case DELETE:
return {
id: preparedParams.id,
};
default:
console.log('Unknown fetch verb');
}
};
3 changes: 2 additions & 1 deletion packages/ra-data-graphql/src/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export default async (client, options) => {
[aorFetchType]: queries.find(
query =>
options.operationNames[aorFetchType] &&
query.name == options.operationNames[aorFetchType](type)
query.name ===
options.operationNames[aorFetchType](type)
),
}),
{ type }
Expand Down
6 changes: 4 additions & 2 deletions packages/ra-input-rich-text/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export class RichTextInput extends Component {

onTextChange = () => {
const value =
this.editor.innerHTML == '<p><br></p>' ? '' : this.editor.innerHTML;
this.editor.innerHTML === '<p><br></p>'
? ''
: this.editor.innerHTML;
this.lastValueChange = value;
this.props.input.onChange(value);
};
Expand All @@ -94,7 +96,7 @@ export class RichTextInput extends Component {
const { error, helperText = false } = this.props.meta;
return (
<FormControl
error={error !== null && error != undefined}
error={error !== null && error != undefined} // eslint-disable-line eqeqeq
fullWidth={this.props.fullWidth}
className="ra-rich-text-input"
>
Expand Down
8 changes: 1 addition & 7 deletions packages/ra-input-rich-text/src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import React from 'react';
import debounce from 'lodash/debounce';
import {
render,
fireEvent,
waitForElement,
cleanup,
getByTestId,
} from 'react-testing-library';
import { render, fireEvent, waitForElement } from 'react-testing-library';

import { RichTextInput } from './index';

Expand Down
1 change: 1 addition & 0 deletions packages/ra-ui-materialui/src/auth/Logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const LogoutWithRef: FunctionComponent<
const classes = useStyles();
const translate = useTranslate();
const dispatch = useDispatch();
// eslint-disable-next-line react-hooks/exhaustive-deps
const logout = useCallback(() => dispatch(userLogout(redirectTo)), [
redirectTo,
]);
Expand Down
Loading

0 comments on commit 7d535a8

Please sign in to comment.