diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-04 13:35:25 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-04 13:35:25 +0100 |
| commit | d53d375d09dd86a85ffb249de1c0cc7c3b3438bc (patch) | |
| tree | 827e02f739a542e674e5d447f46ee97096f02cd7 /src/utils | |
| parent | ab5e5f4bdf40b5bc1ccf82dc1b4aca94d5171ec3 (diff) | |
refactor: avoid useless assignement before return statement
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/helpers/format.ts | 8 | ||||
| -rw-r--r-- | src/utils/hooks/useHeadingsTree.tsx | 7 |
2 files changed, 4 insertions, 11 deletions
diff --git a/src/utils/helpers/format.ts b/src/utils/helpers/format.ts index 94aa2e7..44536dd 100644 --- a/src/utils/helpers/format.ts +++ b/src/utils/helpers/format.ts @@ -61,15 +61,11 @@ export const getFormattedPostPreview = (rawPost: RawArticlePreview) => { export const getFormattedPostsList = ( rawPosts: RawArticlePreview[] ): ArticlePreview[] => { - const formattedPosts = rawPosts + return rawPosts .filter((post) => Object.getOwnPropertyNames(post).length > 0) .map((post) => { - const formattedPost = getFormattedPostPreview(post); - - return formattedPost; + return getFormattedPostPreview(post); }); - - return formattedPosts; }; /** diff --git a/src/utils/hooks/useHeadingsTree.tsx b/src/utils/hooks/useHeadingsTree.tsx index 94d3b4b..745ba23 100644 --- a/src/utils/hooks/useHeadingsTree.tsx +++ b/src/utils/hooks/useHeadingsTree.tsx @@ -8,9 +8,7 @@ const useHeadingsTree = (wrapper: string) => { const getElementDepth = useCallback( (el: HTMLHeadingElement) => { - const elDepth = depths.findIndex((depth) => depth === el.localName); - - return elDepth; + return depths.findIndex((depth) => depth === el.localName); }, [depths] ); @@ -73,9 +71,8 @@ const useHeadingsTree = (wrapper: string) => { const getHeadingsList = useCallback( (headings: NodeListOf<HTMLHeadingElement>): Heading[] => { const formattedHeadings = formatHeadings(headings); - const headingsList = buildTree(formattedHeadings); - return headingsList; + return buildTree(formattedHeadings); }, [formatHeadings, buildTree] ); |
