Skip to content

Commit

Permalink
chore(prettier): update version (#4836)
Browse files Browse the repository at this point in the history
* chore(prettier): update version

main changes are around parens

* fix lint

* more lint fix somehow
  • Loading branch information
Haroenv authored Aug 18, 2021
1 parent 536120d commit 6e62930
Show file tree
Hide file tree
Showing 224 changed files with 3,734 additions and 3,905 deletions.
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
15 changes: 4 additions & 11 deletions examples/e-commerce/src/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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[] } = {};
Expand Down
4 changes: 2 additions & 2 deletions examples/e-commerce/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
4 changes: 3 additions & 1 deletion examples/e-commerce/src/widgets/HitsPerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions examples/e-commerce/src/widgets/ResultsNumberMobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { stats } from 'instantsearch.js/es/widgets';
export const resultsNumberMobile = stats({
container: '[data-widget="results-number-mobile"]',
templates: {
text:
'<strong>{{#helpers.formatNumber}}{{nbHits}}{{/helpers.formatNumber}}</strong> results',
text: '<strong>{{#helpers.formatNumber}}{{nbHits}}{{/helpers.formatNumber}}</strong> results',
},
});
2 changes: 1 addition & 1 deletion examples/e-commerce/src/widgets/SortBy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions scripts/transforms/addWidget-to-addWidgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/Answers/__tests__/Answers-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('Answers', () => {
templateProps: {
templates: {
...defaultProps.templateProps.templates,
item: hit => {
item: (hit) => {
return `answer: ${hit.title}`;
},
},
Expand Down
7 changes: 3 additions & 4 deletions src/components/Breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<BreadcrumbCSSClasses>;

export type BreadcrumbComponentTemplates = Required<BreadcrumbTemplates>;

Expand Down Expand Up @@ -84,7 +83,7 @@ const Breadcrumb = ({
<a
className={cssClasses.link}
href={createURL(item.value)}
onClick={event => {
onClick={(event) => {
event.preventDefault();
refine(item.value);
}}
Expand Down
10 changes: 4 additions & 6 deletions src/components/ClearRefinements/ClearRefinements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import {
import { ComponentCSSClasses } from '../../types';
import { PreparedTemplateProps } from '../../lib/utils/prepareTemplateProps';

export type ClearRefinementsComponentCSSClasses = ComponentCSSClasses<
ClearRefinementsCSSClasses
>;
export type ClearRefinementsComponentCSSClasses =
ComponentCSSClasses<ClearRefinementsCSSClasses>;

export type ClearRefinementsComponentTemplates = Required<
ClearRefinementsTemplates
>;
export type ClearRefinementsComponentTemplates =
Required<ClearRefinementsTemplates>;

export type ClearRefinementsProps = {
refine: ClearRefinementsRenderState['refine'];
Expand Down
9 changes: 4 additions & 5 deletions src/components/CurrentRefinements/CurrentRefinements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<CurrentRefinementsCSSClasses>;

export type CurrentRefinementsProps = {
items: CurrentRefinementsConnectorParamsItem[];
Expand All @@ -25,7 +24,7 @@ const createItemKey = ({
operator,
}: CurrentRefinementsConnectorParamsRefinement): string =>
[attribute, type, value, operator]
.map(key => key)
.map((key) => key)
.filter(Boolean)
.join(':');

Expand All @@ -48,7 +47,7 @@ const CurrentRefinements = ({ items, cssClasses }: CurrentRefinementsProps) => (
>
<span className={cssClasses.label}>{capitalize(item.label)}:</span>

{item.refinements.map(refinement => (
{item.refinements.map((refinement) => (
<span
key={createItemKey(refinement)}
className={cssClasses.category}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ describe('CurrentRefinements', () => {
};

const { container } = render(<CurrentRefinements {...props} />);
const categoryLabel = container.querySelector('.categoryLabel')!
.innerHTML;
const categoryLabel =
container.querySelector('.categoryLabel')!.innerHTML;

expect(categoryLabel).toEqual('<q>search1</q>');
expect(container).toMatchSnapshot();
Expand Down
5 changes: 2 additions & 3 deletions src/components/InfiniteHits/InfiniteHits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<InfiniteHitsCSSClasses>;
export type InfiniteHitsComponentTemplates = Required<InfiniteHitsTemplates>;

export type InfiniteHitsProps = {
Expand Down
11 changes: 5 additions & 6 deletions src/components/MenuSelect/MenuSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
import { MenuRenderState } from '../../connectors/menu/connectMenu';
import { ComponentCSSClasses } from '../../types';

export type MenuSelectComponentCSSClasses = ComponentCSSClasses<
MenuSelectCSSClasses
>;
export type MenuSelectComponentCSSClasses =
ComponentCSSClasses<MenuSelectCSSClasses>;

export type MenuSelectComponentTemplates = Required<MenuSelectTemplates>;

Expand Down Expand Up @@ -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: '',
};

Expand All @@ -59,7 +58,7 @@ function MenuSelect({ cssClasses, templateProps, items, refine }: Props) {
<select
className={cssClasses.select}
value={selectedValue}
onChange={event => {
onChange={(event) => {
refine((event.target as HTMLSelectElement).value);
}}
>
Expand All @@ -73,7 +72,7 @@ function MenuSelect({ cssClasses, templateProps, items, refine }: Props) {
}}
/>

{items.map(item => (
{items.map((item) => (
<Template
{...templateProps}
templateKey="item"
Expand Down
7 changes: 3 additions & 4 deletions src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
} from '../../widgets/pagination/pagination';
import { ComponentCSSClasses } from '../../types';

export type PaginationComponentCSSClasses = ComponentCSSClasses<
PaginationCSSClasses
>;
export type PaginationComponentCSSClasses =
ComponentCSSClasses<PaginationCSSClasses>;

export type PaginationComponentTemplates = Required<PaginationTemplates>;

Expand Down Expand Up @@ -143,7 +142,7 @@ class Pagination extends Component<PaginationProps> {
};

private pages = () => {
return this.props.pages!.map(pageNumber =>
return this.props.pages!.map((pageNumber) =>
this.pageLink({
ariaLabel: `${pageNumber + 1}`,
additionalClassName: this.props.cssClasses.pageItem,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pagination/PaginationLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const PaginationLink = ({
className={cssClasses.link}
aria-label={ariaLabel}
href={url}
onClick={event => handleClick(pageNumber, event)}
onClick={(event) => handleClick(pageNumber, event)}
dangerouslySetInnerHTML={{
__html: label,
}}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Pagination/__tests__/Pagination-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Pagination', () => {
disabledItem: 'disabledItem',
link: 'link',
},
createURL: args => JSON.stringify(args),
createURL: (args) => JSON.stringify(args),
templates: { first: '', last: '', next: '', previous: '' },
currentPage: 0,
pages: pager.pages(),
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('Pagination', () => {
const preventDefault = jest.fn();
const component = new Pagination({ ...defaultProps, ...props });
const modifiers = ['ctrlKey', 'shiftKey', 'altKey', 'metaKey'] as const;
modifiers.forEach(e => {
modifiers.forEach((e) => {
const event: Partial<KeyboardEvent> = { preventDefault };
(event as any)[e] = true;
// @ts-expect-error
Expand Down
9 changes: 4 additions & 5 deletions src/components/Panel/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ export type PanelComponentCSSClasses = ComponentCSSClasses<
Omit<PanelCSSClasses, 'collapseIcon'>
>;

export type PanelComponentTemplates<
TWidget extends UnknownWidgetFactory
> = Required<PanelTemplates<TWidget>>;
export type PanelComponentTemplates<TWidget extends UnknownWidgetFactory> =
Required<PanelTemplates<TWidget>>;

export type PanelProps<TWidget extends UnknownWidgetFactory> = {
hidden: boolean;
Expand Down Expand Up @@ -75,11 +74,11 @@ function Panel<TWidget extends UnknownWidgetFactory>(
<button
className={props.cssClasses.collapseButton}
aria-expanded={!isCollapsed}
onClick={event => {
onClick={(event) => {
event.preventDefault();

setIsControlled(true);
setIsCollapsed(prevIsCollapsed => !prevIsCollapsed);
setIsCollapsed((prevIsCollapsed) => !prevIsCollapsed);
}}
>
<Template
Expand Down
5 changes: 2 additions & 3 deletions src/components/PoweredBy/PoweredBy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { h } from 'preact';
import { ComponentCSSClasses } from '../../types';
import { PoweredByCSSClasses } from '../../widgets/powered-by/powered-by';

export type PoweredByComponentCSSClasses = ComponentCSSClasses<
PoweredByCSSClasses
>;
export type PoweredByComponentCSSClasses =
ComponentCSSClasses<PoweredByCSSClasses>;

export type PoweredByProps = {
url: string;
Expand Down
10 changes: 4 additions & 6 deletions src/components/QueryRuleCustomData/QueryRuleCustomData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import {
} from '../../widgets/query-rule-custom-data/query-rule-custom-data';
import Template from '../Template/Template';

export type QueryRuleCustomDataComponentCSSClasses = ComponentCSSClasses<
QueryRuleCustomDataCSSClasses
>;
export type QueryRuleCustomDataComponentCSSClasses =
ComponentCSSClasses<QueryRuleCustomDataCSSClasses>;

export type QueryRuleCustomDataComponentTemplates = Required<
QueryRuleCustomDataTemplates
>;
export type QueryRuleCustomDataComponentTemplates =
Required<QueryRuleCustomDataTemplates>;

export type QueryRuleCustomDataProps = {
cssClasses: QueryRuleCustomDataComponentCSSClasses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type QueryRuleItem = {
};

function defaultTemplate({ items }: { items: QueryRuleItem[] }) {
return items.map(item => item.banner).join(' ');
return items.map((item) => item.banner).join(' ');
}

describe('QueryRuleCustomData', () => {
Expand Down
Loading

0 comments on commit 6e62930

Please sign in to comment.