Skip to content

Commit 32a7892

Browse files
committed
enforce function declaration for components
1 parent 46b43c5 commit 32a7892

22 files changed

+54
-47
lines changed

.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ module.exports = {
22
extends: ['algolia', 'algolia/react'],
33
rules: {
44
'eslint-comments/disable-enable-pair': 0,
5+
// Enforce function declaration for components
6+
'react/function-component-definition': [
7+
'error',
8+
{
9+
'named-components': 'function-declaration',
10+
},
11+
],
512
// Allow boolean props without explicit values
613
'react/jsx-boolean-value': 0,
714
// Allow JSX content in .js files

src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getUrlFromState, getStateFromUrl, createURL } from './router';
99
export const AppContext = React.createContext(null);
1010
export const SearchContext = React.createContext(null);
1111

12-
export const App = ({ config }) => {
12+
export function App({ config }) {
1313
const navigate = useNavigate();
1414
const location = useLocation();
1515
const searchClient = useSearchClient(config);
@@ -228,4 +228,4 @@ export const App = ({ config }) => {
228228
)}
229229
</AppContext.Provider>
230230
);
231-
};
231+
}

src/components/Banner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { QueryRuleCustomData } from 'react-instantsearch-dom';
33

44
import './Banner.scss';
55

6-
export const Banner = () => {
6+
export function Banner() {
77
return (
88
<QueryRuleCustomData>
99
{({ items }) => {
@@ -23,4 +23,4 @@ export const Banner = () => {
2323
}}
2424
</QueryRuleCustomData>
2525
);
26-
};
26+
}

src/components/CloseIcon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'preact/compat';
22

3-
export const CloseIcon = (props) => {
3+
export function CloseIcon(props) {
44
return (
55
<svg viewBox="0 0 31 32" width="31" height="32" {...props}>
66
<path
@@ -13,4 +13,4 @@ export const CloseIcon = (props) => {
1313
/>
1414
</svg>
1515
);
16-
};
16+
}

src/components/FilterIcon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'preact/compat';
22

3-
export const FilterIcon = (props) => {
3+
export function FilterIcon(props) {
44
return (
55
<svg viewBox="0 0 16 14" {...props}>
66
<path
@@ -14,4 +14,4 @@ export const FilterIcon = (props) => {
1414
></path>
1515
</svg>
1616
);
17-
};
17+
}

src/components/FiltersButton.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useSearchContext } from '../hooks';
44

55
import { FilterIcon } from './FilterIcon';
66

7-
export const FiltersButton = ({ onClick }) => {
7+
export function FiltersButton({ onClick }) {
88
const { refinementCount } = useSearchContext();
99

1010
return (
@@ -21,4 +21,4 @@ export const FiltersButton = ({ onClick }) => {
2121
)}
2222
</button>
2323
);
24-
};
24+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'preact/compat';
22

3-
export const IconViewGrid = (props) => {
3+
export function IconViewGrid(props) {
44
return (
55
<svg width={16} height={16} viewBox="0 0 16 16" {...props}>
66
<path
@@ -10,4 +10,4 @@ export const IconViewGrid = (props) => {
1010
/>
1111
</svg>
1212
);
13-
};
13+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'preact/compat';
22

3-
export const IconViewList = (props) => {
3+
export function IconViewList(props) {
44
return (
55
<svg width={16} height={16} viewBox="0 0 14 14" {...props}>
66
<path
@@ -10,4 +10,4 @@ export const IconViewList = (props) => {
1010
/>
1111
</svg>
1212
);
13-
};
13+
}

src/components/NoResultsHandler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const HitsPreview = connectHits(function MoreHits(props) {
159159
);
160160
});
161161

162-
const QuerySuggestions = () => {
162+
function QuerySuggestions() {
163163
const { config, searchState, searchParameters } = useAppContext();
164164

165165
if (!config.suggestionsIndex) {
@@ -177,7 +177,7 @@ const QuerySuggestions = () => {
177177
<QuerySuggestionsHits />
178178
</Index>
179179
);
180-
};
180+
}
181181

182182
const QuerySuggestionsHits = connectHits(function QuerySuggestionsHits(props) {
183183
const { setQuery } = useSearchContext();

src/components/Panel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import React from 'preact/compat';
22

33
import './Panel.scss';
44

5-
export const Panel = ({
5+
export function Panel({
66
isOpened,
77
header,
88
footer,
99
onToggle,
1010
children,
1111
...rest
12-
}) => {
12+
}) {
1313
return (
1414
<div
1515
className={[
@@ -53,4 +53,4 @@ export const Panel = ({
5353
{footer && <div className="ais-Panel-footer">{footer}</div>}
5454
</div>
5555
);
56-
};
56+
}

0 commit comments

Comments
 (0)