diff --git a/babel.config.js b/babel.config.js
index b8e8432be7..651b6cc008 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -6,9 +6,9 @@ const isCJS = process.env.BABEL_ENV === 'cjs';
const isES = process.env.BABEL_ENV === 'es';
const isUMD = process.env.BABEL_ENV === 'umd';
-const clean = x => x.filter(Boolean);
+const clean = (x) => x.filter(Boolean);
-module.exports = api => {
+module.exports = (api) => {
const isTest = api.env('test');
const modules = isTest || isCJS ? 'commonjs' : false;
const targets = {};
diff --git a/examples/e-commerce/src/routing.ts b/examples/e-commerce/src/routing.ts
index 388fe67228..3ca55085ed 100644
--- a/examples/e-commerce/src/routing.ts
+++ b/examples/e-commerce/src/routing.ts
@@ -58,10 +58,7 @@ const decodedCategories = Object.keys(encodedCategories).reduce((acc, key) => {
function getCategorySlug(name: string): string {
const encodedName = decodedCategories[name] || name;
- return encodedName
- .split(' ')
- .map(encodeURIComponent)
- .join('+');
+ return encodedName.split(' ').map(encodeURIComponent).join('+');
}
// Returns a name from the category slug.
@@ -70,10 +67,7 @@ function getCategorySlug(name: string): string {
function getCategoryName(slug: string): string {
const decodedSlug = encodedCategories[slug] || slug;
- return decodedSlug
- .split('+')
- .map(decodeURIComponent)
- .join(' ');
+ return decodedSlug.split('+').map(decodeURIComponent).join(' ');
}
const originalWindowTitle = document.title;
@@ -216,9 +210,8 @@ const getStateMapping = ({ indexName }) => ({
routeToState(routeState: RouteState): UiState {
const hierarchicalMenu: { [key: string]: string[] } = {};
if (routeState.category) {
- hierarchicalMenu[
- 'hierarchicalCategories.lvl0'
- ] = routeState.category.split('/');
+ hierarchicalMenu['hierarchicalCategories.lvl0'] =
+ routeState.category.split('/');
}
const refinementList: { [key: string]: string[] } = {};
diff --git a/examples/e-commerce/src/ui.ts b/examples/e-commerce/src/ui.ts
index 5c9e3d50fd..8f4431f649 100644
--- a/examples/e-commerce/src/ui.ts
+++ b/examples/e-commerce/src/ui.ts
@@ -38,11 +38,11 @@ function onClick(event: MouseEvent) {
}
export function attachEventListeners() {
- filtersButtons.forEach(button => {
+ filtersButtons.forEach((button) => {
button.addEventListener('click', openFilters);
});
- closeOverlayButtons.forEach(button => {
+ closeOverlayButtons.forEach((button) => {
button.addEventListener('click', closeFilters);
});
}
diff --git a/examples/e-commerce/src/widgets/HitsPerPage.ts b/examples/e-commerce/src/widgets/HitsPerPage.ts
index 236a400c7c..85038f3230 100644
--- a/examples/e-commerce/src/widgets/HitsPerPage.ts
+++ b/examples/e-commerce/src/widgets/HitsPerPage.ts
@@ -24,7 +24,9 @@ export const hitsPerPage = hitsPerPageWidget({
export function getFallbackHitsPerPageRoutingValue(
hitsPerPageValue: string
): string | undefined {
- if (items.map(item => item.value).indexOf(Number(hitsPerPageValue)) !== -1) {
+ if (
+ items.map((item) => item.value).indexOf(Number(hitsPerPageValue)) !== -1
+ ) {
return hitsPerPageValue;
}
diff --git a/examples/e-commerce/src/widgets/ResultsNumberMobile.ts b/examples/e-commerce/src/widgets/ResultsNumberMobile.ts
index 1ca380133c..c344401d44 100644
--- a/examples/e-commerce/src/widgets/ResultsNumberMobile.ts
+++ b/examples/e-commerce/src/widgets/ResultsNumberMobile.ts
@@ -3,7 +3,6 @@ import { stats } from 'instantsearch.js/es/widgets';
export const resultsNumberMobile = stats({
container: '[data-widget="results-number-mobile"]',
templates: {
- text:
- '{{#helpers.formatNumber}}{{nbHits}}{{/helpers.formatNumber}} results',
+ text: '{{#helpers.formatNumber}}{{nbHits}}{{/helpers.formatNumber}} results',
},
});
diff --git a/examples/e-commerce/src/widgets/SortBy.ts b/examples/e-commerce/src/widgets/SortBy.ts
index 6f0c0c2285..27e6e6b834 100644
--- a/examples/e-commerce/src/widgets/SortBy.ts
+++ b/examples/e-commerce/src/widgets/SortBy.ts
@@ -23,7 +23,7 @@ export const sortBy = sortByWidget({
export function getFallbackSortByRoutingValue(
sortByValue: string
): string | undefined {
- if (items.map(item => item.value).indexOf(sortByValue) !== -1) {
+ if (items.map((item) => item.value).indexOf(sortByValue) !== -1) {
return sortByValue;
}
diff --git a/package.json b/package.json
index 050a2fba18..74122b931d 100644
--- a/package.json
+++ b/package.json
@@ -116,7 +116,7 @@
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jasmine": "4.1.0",
"eslint-plugin-jest": "24.3.5",
- "eslint-plugin-prettier": "3.3.1",
+ "eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.18.0",
"eslint-plugin-react-hooks": "2.3.0",
"instantsearch-e2e-tests": "algolia/instantsearch-e2e-tests#1.3.0",
@@ -129,7 +129,7 @@
"jscodeshift": "0.7.0",
"jsdom-global": "3.0.2",
"places.js": "1.17.1",
- "prettier": "1.19.1",
+ "prettier": "2.3.2",
"rollup": "1.29.1",
"rollup-plugin-babel": "4.3.3",
"rollup-plugin-commonjs": "10.1.0",
diff --git a/scripts/transforms/addWidget-to-addWidgets.js b/scripts/transforms/addWidget-to-addWidgets.js
index a66133ccbb..0ccb68701f 100644
--- a/scripts/transforms/addWidget-to-addWidgets.js
+++ b/scripts/transforms/addWidget-to-addWidgets.js
@@ -6,10 +6,10 @@ export default function transform(file, api, options) {
const root = j(file.source);
// replace xxx[from](arguments) to xxx[to]([arguments])
- const replaceSingularToPlural = (from, to) => root =>
+ const replaceSingularToPlural = (from, to) => (root) =>
root
.find(j.CallExpression, { callee: { property: { name: from } } })
- .replaceWith(path =>
+ .replaceWith((path) =>
j.callExpression(
j.memberExpression(path.value.callee.object, j.identifier(to), false),
[j.arrayExpression(path.value.arguments)]
diff --git a/src/__tests__/index-test.ts b/src/__tests__/index-test.ts
index e0bc53965e..91ef76077b 100644
--- a/src/__tests__/index-test.ts
+++ b/src/__tests__/index-test.ts
@@ -8,13 +8,13 @@ describe('instantsearch()', () => {
});
it('includes the widget functions', () => {
- Object.values(instantsearch.widgets).forEach(widget => {
+ Object.values(instantsearch.widgets).forEach((widget) => {
expect(widget).toBeInstanceOf(Function);
});
});
it('includes the connectors functions', () => {
- Object.values(instantsearch.connectors).forEach(connector => {
+ Object.values(instantsearch.connectors).forEach((connector) => {
expect(connector).toBeInstanceOf(Function);
});
});
diff --git a/src/components/Answers/__tests__/Answers-test.tsx b/src/components/Answers/__tests__/Answers-test.tsx
index 53239d7574..b201b891b4 100644
--- a/src/components/Answers/__tests__/Answers-test.tsx
+++ b/src/components/Answers/__tests__/Answers-test.tsx
@@ -103,7 +103,7 @@ describe('Answers', () => {
templateProps: {
templates: {
...defaultProps.templateProps.templates,
- item: hit => {
+ item: (hit) => {
return `answer: ${hit.title}`;
},
},
diff --git a/src/components/Breadcrumb/Breadcrumb.tsx b/src/components/Breadcrumb/Breadcrumb.tsx
index 676db0c82e..38a7b6d989 100644
--- a/src/components/Breadcrumb/Breadcrumb.tsx
+++ b/src/components/Breadcrumb/Breadcrumb.tsx
@@ -11,9 +11,8 @@ import { ComponentCSSClasses } from '../../types';
import { PreparedTemplateProps } from '../../lib/utils/prepareTemplateProps';
import { BreadcrumbConnectorParamsItem } from '../../connectors/breadcrumb/connectBreadcrumb';
-export type BreadcrumbComponentCSSClasses = ComponentCSSClasses<
- BreadcrumbCSSClasses
->;
+export type BreadcrumbComponentCSSClasses =
+ ComponentCSSClasses;
export type BreadcrumbComponentTemplates = Required;
@@ -84,7 +83,7 @@ const Breadcrumb = ({
{
+ onClick={(event) => {
event.preventDefault();
refine(item.value);
}}
diff --git a/src/components/ClearRefinements/ClearRefinements.tsx b/src/components/ClearRefinements/ClearRefinements.tsx
index 0f32b4de34..ef32af8844 100644
--- a/src/components/ClearRefinements/ClearRefinements.tsx
+++ b/src/components/ClearRefinements/ClearRefinements.tsx
@@ -11,13 +11,11 @@ import {
import { ComponentCSSClasses } from '../../types';
import { PreparedTemplateProps } from '../../lib/utils/prepareTemplateProps';
-export type ClearRefinementsComponentCSSClasses = ComponentCSSClasses<
- ClearRefinementsCSSClasses
->;
+export type ClearRefinementsComponentCSSClasses =
+ ComponentCSSClasses;
-export type ClearRefinementsComponentTemplates = Required<
- ClearRefinementsTemplates
->;
+export type ClearRefinementsComponentTemplates =
+ Required;
export type ClearRefinementsProps = {
refine: ClearRefinementsRenderState['refine'];
diff --git a/src/components/CurrentRefinements/CurrentRefinements.tsx b/src/components/CurrentRefinements/CurrentRefinements.tsx
index 79e49ef5ee..cd2f0d5aa2 100644
--- a/src/components/CurrentRefinements/CurrentRefinements.tsx
+++ b/src/components/CurrentRefinements/CurrentRefinements.tsx
@@ -9,9 +9,8 @@ import {
import { CurrentRefinementsCSSClasses } from '../../widgets/current-refinements/current-refinements';
import { ComponentCSSClasses } from '../../types';
-export type CurrentRefinementsComponentCSSClasses = ComponentCSSClasses<
- CurrentRefinementsCSSClasses
->;
+export type CurrentRefinementsComponentCSSClasses =
+ ComponentCSSClasses;
export type CurrentRefinementsProps = {
items: CurrentRefinementsConnectorParamsItem[];
@@ -25,7 +24,7 @@ const createItemKey = ({
operator,
}: CurrentRefinementsConnectorParamsRefinement): string =>
[attribute, type, value, operator]
- .map(key => key)
+ .map((key) => key)
.filter(Boolean)
.join(':');
@@ -48,7 +47,7 @@ const CurrentRefinements = ({ items, cssClasses }: CurrentRefinementsProps) => (
>
{capitalize(item.label)}:
- {item.refinements.map(refinement => (
+ {item.refinements.map((refinement) => (
{
};
const { container } = render();
- const categoryLabel = container.querySelector('.categoryLabel')!
- .innerHTML;
+ const categoryLabel =
+ container.querySelector('.categoryLabel')!.innerHTML;
expect(categoryLabel).toEqual('search1
');
expect(container).toMatchSnapshot();
diff --git a/src/components/InfiniteHits/InfiniteHits.tsx b/src/components/InfiniteHits/InfiniteHits.tsx
index dd5f87ed50..d29a1be715 100644
--- a/src/components/InfiniteHits/InfiniteHits.tsx
+++ b/src/components/InfiniteHits/InfiniteHits.tsx
@@ -11,9 +11,8 @@ import {
} from '../../widgets/infinite-hits/infinite-hits';
import { SendEventForHits, BindEventForHits } from '../../lib/utils';
-export type InfiniteHitsComponentCSSClasses = ComponentCSSClasses<
- InfiniteHitsCSSClasses
->;
+export type InfiniteHitsComponentCSSClasses =
+ ComponentCSSClasses;
export type InfiniteHitsComponentTemplates = Required;
export type InfiniteHitsProps = {
diff --git a/src/components/MenuSelect/MenuSelect.tsx b/src/components/MenuSelect/MenuSelect.tsx
index 96f298ca9f..8712663a6d 100644
--- a/src/components/MenuSelect/MenuSelect.tsx
+++ b/src/components/MenuSelect/MenuSelect.tsx
@@ -11,9 +11,8 @@ import {
import { MenuRenderState } from '../../connectors/menu/connectMenu';
import { ComponentCSSClasses } from '../../types';
-export type MenuSelectComponentCSSClasses = ComponentCSSClasses<
- MenuSelectCSSClasses
->;
+export type MenuSelectComponentCSSClasses =
+ ComponentCSSClasses;
export type MenuSelectComponentTemplates = Required;
@@ -46,7 +45,7 @@ type Props = {
};
function MenuSelect({ cssClasses, templateProps, items, refine }: Props) {
- const { value: selectedValue } = find(items, item => item.isRefined) || {
+ const { value: selectedValue } = find(items, (item) => item.isRefined) || {
value: '',
};
@@ -59,7 +58,7 @@ function MenuSelect({ cssClasses, templateProps, items, refine }: Props) {