Skip to content

Commit

Permalink
fix(warnings): remove v3 warnings (#4134)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored and Haroenv committed Oct 23, 2019
1 parent 437a4c4 commit 7eb6810
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 137 deletions.
76 changes: 0 additions & 76 deletions src/connectors/geo-search/connectGeoSearch.js
@@ -1,6 +1,5 @@
import {
checkRendering,
warning,
aroundLatLngToPosition,
insideBoundingBoxToBoundingBox,
createDocumentationMessageGenerator,
Expand Down Expand Up @@ -111,81 +110,6 @@ const connectGeoSearch = (renderFn, unmountFn = noop) => {
transformItems = items => items,
} = widgetParams;

// Always trigger this message because the default value was `true`. We can't
// display the message only when the parameter is defined otherwise a user that was
// relying on the default value won't have any information about the changes.
warning(
false,
`
The option \`enableGeolocationWithIP\` has been removed from the GeoSearch widget.
Please consider using the \`Configure\` widget instead:
search.addWidget(
configure({
aroundLatLngViaIP: ${widgetParams.enableGeolocationWithIP || 'true'},
})
);
You can find more information inside the migration guide:
http://community.algolia.com/instantsearch.js/migration-guide
`
);

warning(
typeof widgetParams.position === 'undefined',
`
The option \`position\` has been removed from the GeoSearch widget.
Please consider using the \`Configure\` widget instead:
search.addWidget(
configure({
aroundLatLng: '${widgetParams.position &&
widgetParams.position.lat}, ${widgetParams.position &&
widgetParams.position.lng}',
})
);
You can find more information inside the migration guide:
http://community.algolia.com/instantsearch.js/migration-guide
`
);

warning(
typeof widgetParams.radius === 'undefined',
`
The option \`radius\` has been removed from the GeoSearch widget.
Please consider using the \`Configure\` widget instead:
search.addWidget(
configure({
aroundRadius: ${widgetParams.radius},
})
);
You can find more information inside the migration guide:
http://community.algolia.com/instantsearch.js/migration-guide
`
);

warning(
typeof widgetParams.precision === 'undefined',
`
The option \`precision\` has been removed from the GeoSearch widget.
Please consider using the \`Configure\` widget instead:
search.addWidget(
configure({
aroundPrecision: ${widgetParams.precision},
})
);
You can find more information inside the migration guide:
http://community.algolia.com/instantsearch.js/migration-guide
`
);

const widgetState = {
isRefineOnMapMove: enableRefineOnMapMove,
hasMapMoveSinceLastRefine: false,
Expand Down
6 changes: 0 additions & 6 deletions src/widgets/hits/__tests__/hits-test.js
Expand Up @@ -70,12 +70,6 @@ describe('hits()', () => {
expect(render.mock.calls[0][0]).toMatchSnapshot();
});

it('does not accept both item and allItems templates', () => {
expect(
hits.bind({ container, templates: { item: '', allItems: '' } })
).toThrow();
});

it('should add __position key with absolute position', () => {
results = { ...results, page: 4, hitsPerPage: 10 };
const state = { page: results.page };
Expand Down
12 changes: 0 additions & 12 deletions src/widgets/hits/hits.js
Expand Up @@ -6,8 +6,6 @@ import defaultTemplates from './defaultTemplates';
import {
prepareTemplateProps,
getContainerNode,
warning,
createDocumentationLink,
createDocumentationMessageGenerator,
} from '../../lib/utils';
import { component } from '../../lib/suit';
Expand Down Expand Up @@ -99,16 +97,6 @@ export default function hits({
throw new Error(withUsage('The `container` option is required.'));
}

warning(
typeof templates.allItems === 'undefined',
`The template \`allItems\` does not exist since InstantSearch.js 3.
You may want to migrate using \`connectHits\`: ${createDocumentationLink({
name: 'hits',
connector: true,
})}.`
);

const containerNode = getContainerNode(container);
const cssClasses = {
root: cx(suit(), userCssClasses.root),
Expand Down
13 changes: 0 additions & 13 deletions src/widgets/infinite-hits/infinite-hits.tsx
Expand Up @@ -8,8 +8,6 @@ import connectInfiniteHits, {
import {
prepareTemplateProps,
getContainerNode,
warning,
createDocumentationLink,
createDocumentationMessageGenerator,
} from '../../lib/utils';
import { component } from '../../lib/suit';
Expand Down Expand Up @@ -178,17 +176,6 @@ const infiniteHits: InfiniteHits = (
throw new Error(withUsage('The `container` option is required.'));
}

warning(
// @ts-ignore: We have this specific check because unlike `hits`, `infiniteHits` does not support
// the `allItems` template. This can be misleading as they are very similar.
typeof templates.allItems === 'undefined',
`The template \`allItems\` does not exist since InstantSearch.js 3.
You may want to migrate using \`connectInfiniteHits\`: ${createDocumentationLink(
{ name: 'infinite-hits', connector: true }
)}.`
);

const containerNode = getContainerNode(container);
const cssClasses = {
root: cx(suit(), userCssClasses.root),
Expand Down
12 changes: 0 additions & 12 deletions src/widgets/search-box/__tests__/search-box-test.js
Expand Up @@ -34,18 +34,6 @@ describe('searchBox()', () => {
"The \`container\` option is required.
See documentation: https://www.algolia.com/doc/api-reference/widgets/search-box/js/"
`);
});

it('throws with an `input` container', () => {
expect(() => {
searchBox({
container: document.createElement('input'),
});
}).toThrowErrorMatchingInlineSnapshot(`
"The \`container\` option doesn't accept \`input\` elements since InstantSearch.js 3.
You may want to migrate using \`connectSearchBox\`: https://www.algolia.com/doc/api-reference/widgets/searchbox/js/#connector."
`);
});
});
Expand Down
18 changes: 0 additions & 18 deletions src/widgets/search-box/search-box.js
Expand Up @@ -2,8 +2,6 @@ import React, { render, unmountComponentAtNode } from 'preact-compat';
import cx from 'classnames';
import {
getContainerNode,
warning,
createDocumentationLink,
createDocumentationMessageGenerator,
} from '../../lib/utils';
import { component } from '../../lib/suit';
Expand Down Expand Up @@ -119,22 +117,6 @@ export default function searchBox({

const containerNode = getContainerNode(container);

if (containerNode.tagName === 'INPUT') {
throw new Error(
`The \`container\` option doesn't accept \`input\` elements since InstantSearch.js 3.
You may want to migrate using \`connectSearchBox\`: ${createDocumentationLink({
name: 'searchbox',
connector: true,
})}.`
);
}

warning(
typeof autofocus === 'boolean',
'The `autofocus` option only supports boolean values since InstantSearch.js 3.'
);

const cssClasses = {
root: cx(suit(), userCssClasses.root),
form: cx(suit({ descendantName: 'form' }), userCssClasses.form),
Expand Down

0 comments on commit 7eb6810

Please sign in to comment.