From 46b43c5368cbe15e4bbc0be7bf6a6fd6201276c0 Mon Sep 17 00:00:00 2001 From: Dhaya <154633+dhayab@users.noreply.github.com> Date: Fri, 11 Mar 2022 11:22:19 +0100 Subject: [PATCH 1/2] chore: fix eslint issues --- .eslintrc.js | 6 ------ src/App.js | 8 ++++---- src/components/CloseIcon.js | 4 ++-- src/components/ColorList.js | 2 +- src/components/FilterIcon.js | 4 ++-- src/components/FiltersButton.js | 7 ++++--- src/components/Hits.js | 1 + src/components/Icons/IconViewGrid.js | 4 ++-- src/components/Icons/IconViewList.js | 4 ++-- src/components/InfiniteHits.js | 2 +- src/components/NoResultsHandler.js | 6 +++--- src/components/Panel.js | 6 +++--- src/components/PartialHighlight.js | 6 +++--- src/components/ProductList.js | 4 ++-- src/components/Refinements.js | 9 +++++---- src/components/ReverseHighlight.js | 6 +++--- src/components/Search.js | 17 +++++++++-------- src/components/SearchBox/ConnectedSearchBox.js | 1 + src/components/SearchBox/PredictiveSearchBox.js | 1 + src/components/SearchButton.js | 4 ++-- src/components/SizeList.js | 2 +- src/components/Views.js | 4 ++-- src/config/Hit.js | 8 ++++---- src/config/settings.js | 1 + src/hooks/useSearchClient.js | 4 ++-- src/index.js | 2 +- 26 files changed, 62 insertions(+), 61 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a152caf0..fd684972 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,16 +2,10 @@ module.exports = { extends: ['algolia', 'algolia/react'], rules: { 'eslint-comments/disable-enable-pair': 0, - // Do not enforce a specific import order - 'import/order': 0, - // Allow function components - 'react/function-component-definition': 0, // Allow boolean props without explicit values 'react/jsx-boolean-value': 0, // Allow JSX content in .js files 'react/jsx-filename-extension': 0, - // Do not enforce event listeners naming conventions - 'react/jsx-handler-names': 0, // Allow passing function references to event listeners 'react/jsx-no-bind': 0, // Avoid errors about `UNSAFE` lifecycles (e.g. `UNSAFE_componentWillMount`) diff --git a/src/App.js b/src/App.js index 18d3be29..b4ba1679 100644 --- a/src/App.js +++ b/src/App.js @@ -2,14 +2,14 @@ import React, { createPortal } from 'preact/compat'; import { connectHitInsights } from 'react-instantsearch-dom'; import { useNavigate, useLocation } from 'react-router-dom'; -import { getUrlFromState, getStateFromUrl, createURL } from './router'; -import { useSearchClient, useInsights, useMatchMedia } from './hooks'; import { SearchButton, Search } from './components'; +import { useSearchClient, useInsights, useMatchMedia } from './hooks'; +import { getUrlFromState, getStateFromUrl, createURL } from './router'; export const AppContext = React.createContext(null); export const SearchContext = React.createContext(null); -export function App({ config }) { +export const App = ({ config }) => { const navigate = useNavigate(); const location = useLocation(); const searchClient = useSearchClient(config); @@ -228,4 +228,4 @@ export function App({ config }) { )} ); -} +}; diff --git a/src/components/CloseIcon.js b/src/components/CloseIcon.js index db503452..d0ed5cf5 100644 --- a/src/components/CloseIcon.js +++ b/src/components/CloseIcon.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export function CloseIcon(props) { +export const CloseIcon = (props) => { return ( ); -} +}; diff --git a/src/components/ColorList.js b/src/components/ColorList.js index d57a532b..c4ca862f 100644 --- a/src/components/ColorList.js +++ b/src/components/ColorList.js @@ -2,8 +2,8 @@ import React from 'preact/compat'; import { connectRefinementList } from 'react-instantsearch-dom'; import './ColorList.scss'; -import { FacetSearchBox } from './SearchBox/FacetSearchBox'; import { PartialHighlight } from './PartialHighlight'; +import { FacetSearchBox } from './SearchBox/FacetSearchBox'; export const ColorList = connectRefinementList(function ColorList(props) { const [query, setQuery] = React.useState(''); diff --git a/src/components/FilterIcon.js b/src/components/FilterIcon.js index 408b89e3..4a2aec54 100644 --- a/src/components/FilterIcon.js +++ b/src/components/FilterIcon.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export function FilterIcon(props) { +export const FilterIcon = (props) => { return ( ); -} +}; diff --git a/src/components/FiltersButton.js b/src/components/FiltersButton.js index a37c3004..48aac4cd 100644 --- a/src/components/FiltersButton.js +++ b/src/components/FiltersButton.js @@ -1,9 +1,10 @@ import React from 'preact/compat'; -import { FilterIcon } from './FilterIcon'; import { useSearchContext } from '../hooks'; -export function FiltersButton({ onClick }) { +import { FilterIcon } from './FilterIcon'; + +export const FiltersButton = ({ onClick }) => { const { refinementCount } = useSearchContext(); return ( @@ -20,4 +21,4 @@ export function FiltersButton({ onClick }) { )} ); -} +}; diff --git a/src/components/Hits.js b/src/components/Hits.js index 29c34370..1e5505a6 100644 --- a/src/components/Hits.js +++ b/src/components/Hits.js @@ -2,6 +2,7 @@ import React from 'preact/compat'; import { connectHits } from 'react-instantsearch-dom'; import { useAppContext } from '../hooks'; + import { Pagination } from './Pagination'; export const Hits = connectHits((props) => { diff --git a/src/components/Icons/IconViewGrid.js b/src/components/Icons/IconViewGrid.js index 5843a700..21043be7 100644 --- a/src/components/Icons/IconViewGrid.js +++ b/src/components/Icons/IconViewGrid.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export function IconViewGrid(props) { +export const IconViewGrid = (props) => { return ( ); -} +}; diff --git a/src/components/Icons/IconViewList.js b/src/components/Icons/IconViewList.js index 4be97f77..08ed496e 100644 --- a/src/components/Icons/IconViewList.js +++ b/src/components/Icons/IconViewList.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export function IconViewList(props) { +export const IconViewList = (props) => { return ( ); -} +}; diff --git a/src/components/InfiniteHits.js b/src/components/InfiniteHits.js index 49cb02c6..1af5bebc 100644 --- a/src/components/InfiniteHits.js +++ b/src/components/InfiniteHits.js @@ -16,7 +16,7 @@ export const InfiniteHits = connectInfiniteHits((props) => { diff --git a/src/components/NoResultsHandler.js b/src/components/NoResultsHandler.js index f9802394..6bcabaa8 100644 --- a/src/components/NoResultsHandler.js +++ b/src/components/NoResultsHandler.js @@ -7,11 +7,11 @@ import { connectHits, } from 'react-instantsearch-dom'; -import { useAppContext, useSearchContext } from '../hooks'; import { NO_RESULTS_INDEX_NAME, QUERY_SUGGESTIONS_INDEX_NAME, } from '../constants'; +import { useAppContext, useSearchContext } from '../hooks'; export const NoResultsHandler = connectStateResults(function ResultsWrapper( props @@ -159,7 +159,7 @@ const HitsPreview = connectHits(function MoreHits(props) { ); }); -function QuerySuggestions() { +const QuerySuggestions = () => { const { config, searchState, searchParameters } = useAppContext(); if (!config.suggestionsIndex) { @@ -177,7 +177,7 @@ function QuerySuggestions() { ); -} +}; const QuerySuggestionsHits = connectHits(function QuerySuggestionsHits(props) { const { setQuery } = useSearchContext(); diff --git a/src/components/Panel.js b/src/components/Panel.js index 9f1220c1..2945d7e3 100644 --- a/src/components/Panel.js +++ b/src/components/Panel.js @@ -2,14 +2,14 @@ import React from 'preact/compat'; import './Panel.scss'; -export function Panel({ +export const Panel = ({ isOpened, header, footer, onToggle, children, ...rest -}) { +}) => { return (
{footer}
} ); -} +}; diff --git a/src/components/PartialHighlight.js b/src/components/PartialHighlight.js index 6ddcf618..65b8874b 100644 --- a/src/components/PartialHighlight.js +++ b/src/components/PartialHighlight.js @@ -2,12 +2,12 @@ import React from 'preact/compat'; import { getAttributeValueByPath, parseAttribute } from '../utils'; -export function PartialHighlight({ +export const PartialHighlight = ({ hit, attribute, tagName = 'mark', ...rest -}) { +}) => { let parts = []; try { @@ -43,7 +43,7 @@ export function PartialHighlight({ })} ); -} +}; function parsePartialHighlightedAttribute({ hit, diff --git a/src/components/ProductList.js b/src/components/ProductList.js index a7f3e324..e118fb63 100644 --- a/src/components/ProductList.js +++ b/src/components/ProductList.js @@ -1,10 +1,10 @@ import React from 'preact/compat'; +import { useAppContext } from '../hooks'; + import { Hits } from './Hits'; import { InfiniteHits } from './InfiniteHits'; -import { useAppContext } from '../hooks'; - export const ProductList = (props) => { const { isMobile } = useAppContext(); diff --git a/src/components/Refinements.js b/src/components/Refinements.js index 51a577f4..e03cc470 100644 --- a/src/components/Refinements.js +++ b/src/components/Refinements.js @@ -6,12 +6,13 @@ import { } from 'react-instantsearch-dom'; import { useAppContext } from '../hooks'; -import { Panel } from './Panel'; + import { ColorList } from './ColorList'; -import { Slider } from './Slider'; +import { Panel } from './Panel'; import { SizeList } from './SizeList'; +import { Slider } from './Slider'; -function RefinementWidget({ type, ...props }) { +const RefinementWidget = ({ type, ...props }) => { switch (type) { case 'color': return ; @@ -58,7 +59,7 @@ function RefinementWidget({ type, ...props }) { default: return null; } -} +}; function getPanelId(refinement) { return refinement.options.attributes diff --git a/src/components/ReverseHighlight.js b/src/components/ReverseHighlight.js index 5ad3f685..8bd2bb33 100644 --- a/src/components/ReverseHighlight.js +++ b/src/components/ReverseHighlight.js @@ -2,12 +2,12 @@ import React from 'preact/compat'; import { getAttributeValueByPath, parseAttribute } from '../utils'; -export function ReverseHighlight({ +export const ReverseHighlight = ({ hit, attribute, tagName = 'mark', ...rest -}) { +}) => { let parts = []; try { @@ -43,7 +43,7 @@ export function ReverseHighlight({ })} ); -} +}; function parseReverseHighlightedAttribute({ hit, diff --git a/src/components/Search.js b/src/components/Search.js index 323dfa4f..aca0961d 100644 --- a/src/components/Search.js +++ b/src/components/Search.js @@ -2,21 +2,22 @@ import React from 'preact/compat'; import { InstantSearch, Configure, SortBy } from 'react-instantsearch-dom'; import { useAppContext, useSearchContext } from '../hooks'; + import { Banner } from './Banner'; +import { CloseIcon } from './CloseIcon'; import { CurrentRefinements } from './CurrentRefinements'; +import { FiltersButton } from './FiltersButton'; +import { NoResultsHandler } from './NoResultsHandler'; +import { ProductList } from './ProductList'; import { QueryRulesHandler } from './QueryRulesHandler'; import { Refinements } from './Refinements'; +import { ResetButton } from './ResetButton'; import { HeaderSearchBox } from './SearchBox'; +import { SeeResultsButton } from './SeeResultsButton'; import { Stats } from './Stats'; -import { CloseIcon } from './CloseIcon'; -import { NoResultsHandler } from './NoResultsHandler'; -import { ProductList } from './ProductList'; import { Views } from './Views'; -import { FiltersButton } from './FiltersButton'; -import { SeeResultsButton } from './SeeResultsButton'; -import { ResetButton } from './ResetButton'; -export function Search(props) { +export const Search = (props) => { const { config, view, searchParameters, isMobile } = useAppContext(); const { isSearchStalled } = useSearchContext(); @@ -165,4 +166,4 @@ export function Search(props) { ); -} +}; diff --git a/src/components/SearchBox/ConnectedSearchBox.js b/src/components/SearchBox/ConnectedSearchBox.js index c0790e9c..90a91963 100644 --- a/src/components/SearchBox/ConnectedSearchBox.js +++ b/src/components/SearchBox/ConnectedSearchBox.js @@ -2,6 +2,7 @@ import React from 'preact/compat'; import { connectSearchBox } from 'react-instantsearch-dom'; import { useAppContext } from '../../hooks'; + import { PredictiveSearchBox } from './PredictiveSearchBox'; import { SearchBox as SearchBoxComponent } from './SearchBox'; diff --git a/src/components/SearchBox/PredictiveSearchBox.js b/src/components/SearchBox/PredictiveSearchBox.js index 1783d84d..67ed1df8 100644 --- a/src/components/SearchBox/PredictiveSearchBox.js +++ b/src/components/SearchBox/PredictiveSearchBox.js @@ -3,6 +3,7 @@ import { Index, connectHits, Configure } from 'react-instantsearch-dom'; import { QUERY_SUGGESTIONS_INDEX_NAME } from '../../constants'; import { ReverseHighlight } from '../ReverseHighlight'; + import { SearchBox } from './SearchBox'; export const PredictiveSearchBox = (props) => { diff --git a/src/components/SearchButton.js b/src/components/SearchButton.js index 45ecd196..6af8447e 100644 --- a/src/components/SearchButton.js +++ b/src/components/SearchButton.js @@ -31,7 +31,7 @@ export const SearchButton = ({ onClick }) => { ); }; -function SearchIcon(props) { +const SearchIcon = (props) => { return ( ); -} +}; diff --git a/src/components/SizeList.js b/src/components/SizeList.js index f264af09..6069f23d 100644 --- a/src/components/SizeList.js +++ b/src/components/SizeList.js @@ -1,8 +1,8 @@ import React from 'preact/compat'; import { connectRefinementList } from 'react-instantsearch-dom'; -import { FacetSearchBox } from './SearchBox/FacetSearchBox'; import { PartialHighlight } from './PartialHighlight'; +import { FacetSearchBox } from './SearchBox/FacetSearchBox'; export const SizeList = connectRefinementList(function SizeList(props) { const [query, setQuery] = React.useState(''); diff --git a/src/components/Views.js b/src/components/Views.js index fb3d6f61..c4edcc94 100644 --- a/src/components/Views.js +++ b/src/components/Views.js @@ -2,7 +2,7 @@ import React from 'preact/compat'; import { IconViewGrid, IconViewList } from './Icons'; -export function Views(props) { +export const Views = (props) => { return ( ); -} +}; diff --git a/src/config/Hit.js b/src/config/Hit.js index e8a6888a..e8e4cd0b 100644 --- a/src/config/Hit.js +++ b/src/config/Hit.js @@ -3,7 +3,7 @@ import { Highlight, Snippet } from 'react-instantsearch-dom'; import './Hit.scss'; -export function Hit({ hit, insights, view }) { +export const Hit = ({ hit, insights, view }) => { return ( ); -} +}; -function CartIcon(props) { +const CartIcon = (props) => { return ( ); -} +}; diff --git a/src/config/settings.js b/src/config/settings.js index 808d2391..00793b42 100644 --- a/src/config/settings.js +++ b/src/config/settings.js @@ -14,6 +14,7 @@ */ import React from 'preact/compat'; + import { Hit } from './Hit'; /* diff --git a/src/hooks/useSearchClient.js b/src/hooks/useSearchClient.js index 1c17b472..3b99610f 100644 --- a/src/hooks/useSearchClient.js +++ b/src/hooks/useSearchClient.js @@ -1,11 +1,11 @@ -import React from 'preact/compat'; import algoliasearch from 'algoliasearch/lite'; +import React from 'preact/compat'; -import { version } from '../version'; import { NO_RESULTS_INDEX_NAME, QUERY_SUGGESTIONS_INDEX_NAME, } from '../constants'; +import { version } from '../version'; export function useSearchClient(config) { const appId = config.appId; diff --git a/src/index.js b/src/index.js index 37493a42..7993468d 100644 --- a/src/index.js +++ b/src/index.js @@ -5,9 +5,9 @@ import './reset.scss'; import './theme.scss'; import './App.scss'; +import { App } from './App'; import config from './config'; import rules from './config/rules'; -import { App } from './App'; import { getDomElement, validateConfig } from './utils'; validateConfig(config, rules); From 32a789213a0760fa26866125a6bf9ef52c11de9b Mon Sep 17 00:00:00 2001 From: Dhaya <154633+dhayab@users.noreply.github.com> Date: Wed, 16 Mar 2022 11:19:08 +0100 Subject: [PATCH 2/2] enforce function declaration for components --- .eslintrc.js | 7 +++++++ src/App.js | 4 ++-- src/components/Banner.js | 4 ++-- src/components/CloseIcon.js | 4 ++-- src/components/FilterIcon.js | 4 ++-- src/components/FiltersButton.js | 4 ++-- src/components/Icons/IconViewGrid.js | 4 ++-- src/components/Icons/IconViewList.js | 4 ++-- src/components/NoResultsHandler.js | 4 ++-- src/components/Panel.js | 6 +++--- src/components/PartialHighlight.js | 6 +++--- src/components/ProductList.js | 4 ++-- src/components/QueryRulesHandler.js | 4 ++-- src/components/Refinements.js | 4 ++-- src/components/ReverseHighlight.js | 6 +++--- src/components/Search.js | 4 ++-- src/components/SearchBox/FacetSearchBox.js | 4 ++-- src/components/SearchBox/PredictiveSearchBox.js | 4 ++-- src/components/SearchBox/SearchBox.js | 4 ++-- src/components/SearchButton.js | 4 ++-- src/components/Views.js | 4 ++-- src/config/Hit.js | 8 ++++---- 22 files changed, 54 insertions(+), 47 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index fd684972..b5f0f28c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,6 +2,13 @@ module.exports = { extends: ['algolia', 'algolia/react'], rules: { 'eslint-comments/disable-enable-pair': 0, + // Enforce function declaration for components + 'react/function-component-definition': [ + 'error', + { + 'named-components': 'function-declaration', + }, + ], // Allow boolean props without explicit values 'react/jsx-boolean-value': 0, // Allow JSX content in .js files diff --git a/src/App.js b/src/App.js index b4ba1679..291574ea 100644 --- a/src/App.js +++ b/src/App.js @@ -9,7 +9,7 @@ import { getUrlFromState, getStateFromUrl, createURL } from './router'; export const AppContext = React.createContext(null); export const SearchContext = React.createContext(null); -export const App = ({ config }) => { +export function App({ config }) { const navigate = useNavigate(); const location = useLocation(); const searchClient = useSearchClient(config); @@ -228,4 +228,4 @@ export const App = ({ config }) => { )} ); -}; +} diff --git a/src/components/Banner.js b/src/components/Banner.js index 88464de9..dee8bdc0 100644 --- a/src/components/Banner.js +++ b/src/components/Banner.js @@ -3,7 +3,7 @@ import { QueryRuleCustomData } from 'react-instantsearch-dom'; import './Banner.scss'; -export const Banner = () => { +export function Banner() { return ( {({ items }) => { @@ -23,4 +23,4 @@ export const Banner = () => { }} ); -}; +} diff --git a/src/components/CloseIcon.js b/src/components/CloseIcon.js index d0ed5cf5..db503452 100644 --- a/src/components/CloseIcon.js +++ b/src/components/CloseIcon.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export const CloseIcon = (props) => { +export function CloseIcon(props) { return ( { /> ); -}; +} diff --git a/src/components/FilterIcon.js b/src/components/FilterIcon.js index 4a2aec54..408b89e3 100644 --- a/src/components/FilterIcon.js +++ b/src/components/FilterIcon.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export const FilterIcon = (props) => { +export function FilterIcon(props) { return ( { > ); -}; +} diff --git a/src/components/FiltersButton.js b/src/components/FiltersButton.js index 48aac4cd..cd61c52f 100644 --- a/src/components/FiltersButton.js +++ b/src/components/FiltersButton.js @@ -4,7 +4,7 @@ import { useSearchContext } from '../hooks'; import { FilterIcon } from './FilterIcon'; -export const FiltersButton = ({ onClick }) => { +export function FiltersButton({ onClick }) { const { refinementCount } = useSearchContext(); return ( @@ -21,4 +21,4 @@ export const FiltersButton = ({ onClick }) => { )} ); -}; +} diff --git a/src/components/Icons/IconViewGrid.js b/src/components/Icons/IconViewGrid.js index 21043be7..5843a700 100644 --- a/src/components/Icons/IconViewGrid.js +++ b/src/components/Icons/IconViewGrid.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export const IconViewGrid = (props) => { +export function IconViewGrid(props) { return ( { /> ); -}; +} diff --git a/src/components/Icons/IconViewList.js b/src/components/Icons/IconViewList.js index 08ed496e..4be97f77 100644 --- a/src/components/Icons/IconViewList.js +++ b/src/components/Icons/IconViewList.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export const IconViewList = (props) => { +export function IconViewList(props) { return ( { /> ); -}; +} diff --git a/src/components/NoResultsHandler.js b/src/components/NoResultsHandler.js index 6bcabaa8..370ea108 100644 --- a/src/components/NoResultsHandler.js +++ b/src/components/NoResultsHandler.js @@ -159,7 +159,7 @@ const HitsPreview = connectHits(function MoreHits(props) { ); }); -const QuerySuggestions = () => { +function QuerySuggestions() { const { config, searchState, searchParameters } = useAppContext(); if (!config.suggestionsIndex) { @@ -177,7 +177,7 @@ const QuerySuggestions = () => { ); -}; +} const QuerySuggestionsHits = connectHits(function QuerySuggestionsHits(props) { const { setQuery } = useSearchContext(); diff --git a/src/components/Panel.js b/src/components/Panel.js index 2945d7e3..9f1220c1 100644 --- a/src/components/Panel.js +++ b/src/components/Panel.js @@ -2,14 +2,14 @@ import React from 'preact/compat'; import './Panel.scss'; -export const Panel = ({ +export function Panel({ isOpened, header, footer, onToggle, children, ...rest -}) => { +}) { return (
{footer}
} ); -}; +} diff --git a/src/components/PartialHighlight.js b/src/components/PartialHighlight.js index 65b8874b..6ddcf618 100644 --- a/src/components/PartialHighlight.js +++ b/src/components/PartialHighlight.js @@ -2,12 +2,12 @@ import React from 'preact/compat'; import { getAttributeValueByPath, parseAttribute } from '../utils'; -export const PartialHighlight = ({ +export function PartialHighlight({ hit, attribute, tagName = 'mark', ...rest -}) => { +}) { let parts = []; try { @@ -43,7 +43,7 @@ export const PartialHighlight = ({ })} ); -}; +} function parsePartialHighlightedAttribute({ hit, diff --git a/src/components/ProductList.js b/src/components/ProductList.js index e118fb63..5ab5b922 100644 --- a/src/components/ProductList.js +++ b/src/components/ProductList.js @@ -5,7 +5,7 @@ import { useAppContext } from '../hooks'; import { Hits } from './Hits'; import { InfiniteHits } from './InfiniteHits'; -export const ProductList = (props) => { +export function ProductList(props) { const { isMobile } = useAppContext(); if (isMobile) { @@ -13,4 +13,4 @@ export const ProductList = (props) => { } return ; -}; +} diff --git a/src/components/QueryRulesHandler.js b/src/components/QueryRulesHandler.js index 4a8c07eb..e2422c20 100644 --- a/src/components/QueryRulesHandler.js +++ b/src/components/QueryRulesHandler.js @@ -21,7 +21,7 @@ const getRulesContextFromSearchState = ({ refinementList = {}, menu = {} }) => { }, {}); }; -export const QueryRulesHandler = (props) => { +export function QueryRulesHandler(props) { const ruleContexts = getRulesContextFromSearchState(props.searchState); if (Object.keys(ruleContexts).length === 0) { @@ -29,4 +29,4 @@ export const QueryRulesHandler = (props) => { } return ; -}; +} diff --git a/src/components/Refinements.js b/src/components/Refinements.js index e03cc470..5cdcd9ae 100644 --- a/src/components/Refinements.js +++ b/src/components/Refinements.js @@ -12,7 +12,7 @@ import { Panel } from './Panel'; import { SizeList } from './SizeList'; import { Slider } from './Slider'; -const RefinementWidget = ({ type, ...props }) => { +function RefinementWidget({ type, ...props }) { switch (type) { case 'color': return ; @@ -59,7 +59,7 @@ const RefinementWidget = ({ type, ...props }) => { default: return null; } -}; +} function getPanelId(refinement) { return refinement.options.attributes diff --git a/src/components/ReverseHighlight.js b/src/components/ReverseHighlight.js index 8bd2bb33..5ad3f685 100644 --- a/src/components/ReverseHighlight.js +++ b/src/components/ReverseHighlight.js @@ -2,12 +2,12 @@ import React from 'preact/compat'; import { getAttributeValueByPath, parseAttribute } from '../utils'; -export const ReverseHighlight = ({ +export function ReverseHighlight({ hit, attribute, tagName = 'mark', ...rest -}) => { +}) { let parts = []; try { @@ -43,7 +43,7 @@ export const ReverseHighlight = ({ })} ); -}; +} function parseReverseHighlightedAttribute({ hit, diff --git a/src/components/Search.js b/src/components/Search.js index aca0961d..ac562204 100644 --- a/src/components/Search.js +++ b/src/components/Search.js @@ -17,7 +17,7 @@ import { SeeResultsButton } from './SeeResultsButton'; import { Stats } from './Stats'; import { Views } from './Views'; -export const Search = (props) => { +export function Search(props) { const { config, view, searchParameters, isMobile } = useAppContext(); const { isSearchStalled } = useSearchContext(); @@ -166,4 +166,4 @@ export const Search = (props) => { ); -}; +} diff --git a/src/components/SearchBox/FacetSearchBox.js b/src/components/SearchBox/FacetSearchBox.js index cbcba972..cc0b31db 100644 --- a/src/components/SearchBox/FacetSearchBox.js +++ b/src/components/SearchBox/FacetSearchBox.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export const FacetSearchBox = (props) => { +export function FacetSearchBox(props) { return (
{
); -}; +} diff --git a/src/components/SearchBox/PredictiveSearchBox.js b/src/components/SearchBox/PredictiveSearchBox.js index 67ed1df8..56389560 100644 --- a/src/components/SearchBox/PredictiveSearchBox.js +++ b/src/components/SearchBox/PredictiveSearchBox.js @@ -6,7 +6,7 @@ import { ReverseHighlight } from '../ReverseHighlight'; import { SearchBox } from './SearchBox'; -export const PredictiveSearchBox = (props) => { +export function PredictiveSearchBox(props) { const [suggestion, setSuggestion] = React.useState(null); return ( @@ -58,7 +58,7 @@ export const PredictiveSearchBox = (props) => { ); -}; +} const Suggestions = connectHits(function Suggestions({ query, diff --git a/src/components/SearchBox/SearchBox.js b/src/components/SearchBox/SearchBox.js index 52b94880..dd27ab9f 100644 --- a/src/components/SearchBox/SearchBox.js +++ b/src/components/SearchBox/SearchBox.js @@ -1,6 +1,6 @@ import React from 'preact/compat'; -export const SearchBox = (props) => { +export function SearchBox(props) { const inputRef = React.useRef(null); function onSubmit(event) { @@ -138,4 +138,4 @@ export const SearchBox = (props) => { ); -}; +} diff --git a/src/components/SearchButton.js b/src/components/SearchButton.js index 6af8447e..45ecd196 100644 --- a/src/components/SearchButton.js +++ b/src/components/SearchButton.js @@ -31,7 +31,7 @@ export const SearchButton = ({ onClick }) => { ); }; -const SearchIcon = (props) => { +function SearchIcon(props) { return ( { /> ); -}; +} diff --git a/src/components/Views.js b/src/components/Views.js index c4edcc94..fb3d6f61 100644 --- a/src/components/Views.js +++ b/src/components/Views.js @@ -2,7 +2,7 @@ import React from 'preact/compat'; import { IconViewGrid, IconViewList } from './Icons'; -export const Views = (props) => { +export function Views(props) { return (
); -}; +} diff --git a/src/config/Hit.js b/src/config/Hit.js index e8e4cd0b..e8a6888a 100644 --- a/src/config/Hit.js +++ b/src/config/Hit.js @@ -3,7 +3,7 @@ import { Highlight, Snippet } from 'react-instantsearch-dom'; import './Hit.scss'; -export const Hit = ({ hit, insights, view }) => { +export function Hit({ hit, insights, view }) { return (
); -}; +} -const CartIcon = (props) => { +function CartIcon(props) { return ( { ); -}; +}