From 0082b72e08d435a28e1030a7997bcdfaa6f11749 Mon Sep 17 00:00:00 2001 From: Michael Neeley Date: Thu, 11 Dec 2025 08:48:08 -0500 Subject: [PATCH 1/6] adds lint checks to web shared pkg --- .github/workflows/lint.yml | 28 ++++++++---- packages/web-shared/analytics/segment.js | 1 + packages/web-shared/client/apolloClient.js | 4 +- packages/web-shared/client/authLink.js | 1 + packages/web-shared/client/httpLink.js | 2 +- packages/web-shared/client/initCache.js | 1 + .../client/introspectionToPossibleTypes.js | 4 +- .../components/AddToCalendar/AddToCalendar.js | 4 +- .../AddToCalendar/AddToCalendar.styles.js | 6 +-- .../components/AddToCalendar/index.js | 1 + .../components/AppHeader/AppHeader.js | 9 ++-- .../web-shared/components/Auth/AuthConfirm.js | 6 +-- .../web-shared/components/Auth/AuthDetails.js | 3 +- .../components/Auth/AuthIdentity.js | 2 +- .../components/Auth/AuthLayout/AuthLayout.js | 7 +-- .../Auth/AuthLayout/AuthLayout.styles.js | 3 +- .../web-shared/components/Auth/AuthManager.js | 6 +-- .../components/Auth/AuthMerge/AuthMerge.js | 45 ++++--------------- .../Auth/AuthMerge/AuthMerge.styles.js | 3 +- .../web-shared/components/Auth/AuthWelcome.js | 4 +- .../BirthDateField.styles.web.js | 3 +- .../Auth/BirthDateField/BirthDateField.web.js | 10 ++--- .../Auth/GenderField/GenderField.js | 8 +--- .../components/Comments/AddComment.js | 12 ++--- .../web-shared/components/Comments/Comment.js | 1 + .../components/Comments/Comments.js | 12 ++--- .../web-shared/components/ContentChannel.js | 5 ++- .../components/ContentSeriesSingle.js | 18 ++++---- .../web-shared/components/ContentSingle.js | 40 ++++++++--------- .../components/ContentSingle.styles.js | 5 +-- .../components/EventCalendar/EventCalendar.js | 19 ++++---- .../components/EventCalendar/index.js | 4 +- .../FeatureFeed/Features/ActionBarFeature.js | 2 +- .../Features/ActionBarFeature.styles.js | 5 +-- .../FeatureFeed/Features/ActionListFeature.js | 5 ++- .../Features/ActionListFeature.styles.js | 5 +-- .../FeatureFeed/Features/ButtonFeature.js | 16 ++++--- .../FeatureFeed/Features/ChipListFeature.js | 3 +- .../Features/ChipListFeature.styles.js | 5 +-- .../FeatureFeed/Features/EventBlockFeature.js | 9 ++-- .../Features/EventBlockFeature.styles.js | 3 +- .../FeatureFeed/Features/HeroListFeature.js | 10 +++-- .../Features/HeroListFeature.styles.js | 3 +- .../Features/HorizontalCardListFeature.js | 6 +-- .../Features/HorizontalMediaListFeature.js | 6 +-- .../FeatureFeed/Features/HtmlFeature.js | 3 +- .../FeatureFeed/Features/PrayerListFeature.js | 10 +++-- .../Features/PrayerListFeature.styles.js | 5 +-- .../FeatureFeed/Features/ScriptureFeature.js | 7 ++- .../Features/ScriptureFeature.styles.js | 10 +++-- .../Features/VerticalCardListFeature.js | 5 ++- .../VerticalCardListFeature.styles.js | 4 +- .../web-shared/components/FeatureFeed/Feed.js | 8 ++-- .../FeatureFeedList/FeatureFeedList.js | 6 +-- .../FeatureFeedList/FeatureFeedListGrid.js | 5 +-- .../InteractWhenLoaded/InteractWhenLoaded.js | 7 +-- .../components/InteractWhenLoaded/index.js | 2 +- .../web-shared/components/LivestreamSingle.js | 14 +++--- packages/web-shared/components/Logo/Logo.js | 5 ++- .../web-shared/components/Logo/Logo.styles.js | 3 +- packages/web-shared/components/Modal/Modal.js | 15 ++++--- .../components/Modal/Modal.styles.js | 3 +- .../components/Profile/ImageUploader.js | 7 +-- .../web-shared/components/Profile/Profile.js | 34 +++++++------- .../components/Profile/Profile.styles.js | 8 ++-- .../components/Profile/ProfileButton.js | 8 ++-- .../components/Profile/ProfileDetails.js | 5 +-- .../components/Profile/canvasPreview.js | 14 +++--- .../components/Searchbar/Autocomplete.js | 12 +++-- .../components/Searchbar/Search.styles.js | 5 +-- .../components/Searchbar/SearchResults.js | 13 +++--- .../components/Searchbar/Searchbar.js | 14 +++--- .../components/StoreLinks/StoreLinks.js | 5 +-- .../components/VideoPlayer/DevVideoDetails.js | 19 +++----- .../components/VideoPlayer/VideoPlayer.js | 8 ++-- .../VideoPlayer/VideoPlayer.styles.js | 2 +- .../components/Wordmark/Wordmark.js | 3 +- .../components/Wordmark/Wordmark.styles.js | 3 +- packages/web-shared/components/index.js | 4 +- packages/web-shared/embeds/Auth.js | 1 + packages/web-shared/embeds/FeatureFeed.js | 8 ++-- packages/web-shared/embeds/Main.js | 10 ++--- packages/web-shared/embeds/Search.js | 11 +++-- packages/web-shared/embeds/index.js | 2 +- packages/web-shared/hooks/useAuthQuery.js | 27 ++++++----- .../web-shared/hooks/useCompleteRegister.js | 10 +---- packages/web-shared/hooks/useContentItem.js | 1 + packages/web-shared/hooks/useFeatureFeed.js | 1 + packages/web-shared/hooks/useHTMLContent.js | 8 ++-- .../web-shared/hooks/useHandleActionPress.js | 5 +-- .../web-shared/hooks/useInteractWithNode.js | 13 +++--- packages/web-shared/hooks/useLink.js | 6 ++- .../web-shared/hooks/useLivestreamStatus.js | 21 ++++++--- packages/web-shared/hooks/useValidateLogin.js | 5 +-- .../web-shared/hooks/useValidateRegister.js | 5 +-- packages/web-shared/package.json | 3 ++ .../web-shared/providers/AnalyticsProvider.js | 8 ++-- packages/web-shared/providers/AppProvider.js | 9 ++-- packages/web-shared/providers/AuthProvider.js | 4 +- .../providers/ContentFeedProvider.js | 15 ++----- .../providers/ContentItemProvider.js | 2 +- .../providers/FeatureFeedProvider.js | 15 ++----- .../web-shared/providers/ModalProvider.js | 4 +- .../providers/NavigationProvider.js | 3 ++ .../web-shared/providers/SearchProvider.js | 1 + packages/web-shared/providers/index.js | 7 +-- packages/web-shared/ui-kit/Avatar/Avatar.js | 3 +- packages/web-shared/ui-kit/Box/Box.js | 3 +- packages/web-shared/ui-kit/Box/Box.styles.js | 3 +- packages/web-shared/ui-kit/Button/Button.js | 3 +- .../web-shared/ui-kit/Button/Button.styles.js | 4 +- .../ui-kit/ButtonGroup/ButtonGroup.js | 7 +-- .../ui-kit/ButtonGroup/ButtonGroup.styles.js | 8 ++-- packages/web-shared/ui-kit/Card/Card.js | 1 + .../ui-kit/ContentCard/ContentCard.js | 7 +-- .../ui-kit/ContentCard/ContentCard.styles.js | 4 +- packages/web-shared/ui-kit/Icons/Dot.js | 5 ++- packages/web-shared/ui-kit/Input/Input.js | 4 +- .../web-shared/ui-kit/Input/Input.styles.js | 12 ++--- packages/web-shared/ui-kit/Layout/Layout.js | 3 +- .../web-shared/ui-kit/Layout/Layout.styles.js | 3 +- .../web-shared/ui-kit/ListItem/ListItem.js | 9 ++-- .../ui-kit/ListItem/ListItem.styles.js | 5 +-- packages/web-shared/ui-kit/Loader/Loader.js | 3 +- .../web-shared/ui-kit/Loader/Loader.styles.js | 3 +- .../web-shared/ui-kit/Longform/Longform.js | 2 +- .../ui-kit/Longform/Longform.styles.js | 4 +- .../web-shared/ui-kit/MediaItem/LiveChip.js | 2 +- .../web-shared/ui-kit/MediaItem/MediaItem.js | 16 +++---- .../ui-kit/MediaItem/MediaItem.styles.js | 6 +-- packages/web-shared/ui-kit/MediaItem/index.js | 2 +- .../ui-kit/PhospherIcon/PhospherIcon.js | 8 ++-- .../ui-kit/ProgressBar/ProgressBar.js | 4 +- .../ui-kit/ProgressBar/ProgressBar.styles.js | 3 +- .../ui-kit/ResourceCard/ResourceCard.js | 7 +-- .../ResourceCard/ResourceCard.styles.js | 5 +-- .../web-shared/ui-kit/ResourceCard/index.js | 2 +- packages/web-shared/ui-kit/Select/Select.js | 10 ++--- .../web-shared/ui-kit/Select/Select.styles.js | 28 +++++------- packages/web-shared/ui-kit/Select/index.js | 2 +- .../ui-kit/ShareButton/ShareButton.js | 11 ++--- .../ui-kit/ShareButton/ShareButton.styles.js | 19 +++----- .../ui-kit/ShareButton/functions.js | 12 ++--- .../web-shared/ui-kit/ShareButton/icons.js | 7 +-- .../web-shared/ui-kit/ShareButton/options.js | 2 +- .../ui-kit/ThemeProvider/ThemeProvider.js | 8 +++- .../web-shared/ui-kit/Typography/BodyText.js | 5 +-- packages/web-shared/ui-kit/Typography/H1.js | 6 +-- packages/web-shared/ui-kit/Typography/H2.js | 5 +-- packages/web-shared/ui-kit/Typography/H3.js | 5 +-- packages/web-shared/ui-kit/Typography/H4.js | 5 +-- packages/web-shared/ui-kit/Typography/H5.js | 5 +-- packages/web-shared/ui-kit/Typography/H6.js | 5 +-- .../ui-kit/Typography/LargeSystemText.js | 5 +-- .../ui-kit/Typography/SmallBodyText.js | 5 +-- .../ui-kit/Typography/SmallSystemText.js | 5 +-- .../ui-kit/Typography/SystemText.js | 5 +-- .../ui-kit/Typography/_typeStyles.js | 2 +- .../web-shared/ui-kit/Typography/index.js | 2 +- packages/web-shared/ui-kit/_config/theme.js | 2 +- .../ui-kit/_utils/__tests__/rem.test.js | 2 +- packages/web-shared/ui-kit/_utils/index.js | 2 +- packages/web-shared/ui-kit/index.js | 13 +++--- .../web-shared/utils/getContentFromURL.js | 5 ++- .../web-shared/utils/parseSlugToIdAndType.js | 14 +++--- packages/web-shared/utils/validateEmail.js | 3 +- yarn.lock | 31 +++++++++++-- 167 files changed, 595 insertions(+), 623 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cf03e17a..7b38c8fb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,27 +1,39 @@ -name: Lint Web Embeds +name: Lint Web Packages on: push: paths: - 'web-embeds/**' + - 'packages/web-shared/**' + - '.github/workflows/lint.yml' + - 'package.json' + - 'yarn.lock' pull_request: paths: - 'web-embeds/**' + - 'packages/web-shared/**' + - '.github/workflows/lint.yml' + - 'package.json' + - 'yarn.lock' jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: - node-version: '>=18.17.0' + node-version: '18' + cache: 'yarn' - - name: Install Dependencies - run: cd web-embeds && yarn install + - name: Install dependencies + run: yarn install --frozen-lockfile - - name: Run Lint - run: cd web-embeds && yarn lint + - name: Lint web embeds + run: yarn workspace @apollosproject/apollos-embeds lint + + - name: Lint web shared + run: yarn workspace @apollosproject/web-shared lint diff --git a/packages/web-shared/analytics/segment.js b/packages/web-shared/analytics/segment.js index 34cd0135..3d0becd4 100644 --- a/packages/web-shared/analytics/segment.js +++ b/packages/web-shared/analytics/segment.js @@ -1,4 +1,5 @@ import { AnalyticsBrowser } from '@segment/analytics-next'; + const clientFactory = (writeKey, clientManaged = false) => { if (!writeKey) { return null; diff --git a/packages/web-shared/client/apolloClient.js b/packages/web-shared/client/apolloClient.js index 01c42833..ab11bcd5 100644 --- a/packages/web-shared/client/apolloClient.js +++ b/packages/web-shared/client/apolloClient.js @@ -1,11 +1,11 @@ import { ApolloClient, ApolloLink } from '@apollo/client'; -import { AUTH_TOKEN_KEY, AUTH_REFRESH_TOKEN_KEY } from '../config/keys'; import apollosApiLink from './apollosApiLink'; import authLink from './authLink'; +import buildErrorLink from './buildErrorLink'; import httpLink from './httpLink'; import initCache from './initCache'; -import buildErrorLink from './buildErrorLink'; +import { AUTH_TOKEN_KEY, AUTH_REFRESH_TOKEN_KEY } from '../config/keys'; const client = async (church_slug) => { let storeIsResetting = false; diff --git a/packages/web-shared/client/authLink.js b/packages/web-shared/client/authLink.js index dd0794d8..b8262552 100644 --- a/packages/web-shared/client/authLink.js +++ b/packages/web-shared/client/authLink.js @@ -1,4 +1,5 @@ import { setContext } from '@apollo/client/link/context'; + import { AUTH_TOKEN_KEY } from '../config/keys'; export default setContext(async (request, { headers }) => { diff --git a/packages/web-shared/client/httpLink.js b/packages/web-shared/client/httpLink.js index 705343a9..e083a92a 100644 --- a/packages/web-shared/client/httpLink.js +++ b/packages/web-shared/client/httpLink.js @@ -1,6 +1,6 @@ -import { createUploadLink } from 'apollo-upload-client'; import { split, createHttpLink } from '@apollo/client'; import { getMainDefinition } from '@apollo/client/utilities'; +import { createUploadLink } from 'apollo-upload-client'; export const uri = process.env.NEXT_PUBLIC_DATA_URL || process.env.REACT_APP_DATA_URL || 'https://cdn.apollos.app'; diff --git a/packages/web-shared/client/initCache.js b/packages/web-shared/client/initCache.js index 74bccfbe..d80fed76 100644 --- a/packages/web-shared/client/initCache.js +++ b/packages/web-shared/client/initCache.js @@ -1,5 +1,6 @@ import { InMemoryCache } from '@apollo/client/core'; import { persistCache } from 'apollo3-cache-persist'; + import { uri } from './httpLink'; const initCache = async (initialState, { church }) => { diff --git a/packages/web-shared/client/introspectionToPossibleTypes.js b/packages/web-shared/client/introspectionToPossibleTypes.js index c7bd03a0..aa77213d 100644 --- a/packages/web-shared/client/introspectionToPossibleTypes.js +++ b/packages/web-shared/client/introspectionToPossibleTypes.js @@ -3,9 +3,7 @@ function introspectionToPossibleTypes(introspectionQueryResultData) { introspectionQueryResultData.__schema.types.forEach((supertype) => { if (supertype.possibleTypes) { - possibleTypes[supertype.name] = [ - ...supertype.possibleTypes.map((subtype) => subtype.name), - ]; + possibleTypes[supertype.name] = [...supertype.possibleTypes.map((subtype) => subtype.name)]; } }); diff --git a/packages/web-shared/components/AddToCalendar/AddToCalendar.js b/packages/web-shared/components/AddToCalendar/AddToCalendar.js index 7fbef21a..9b541171 100644 --- a/packages/web-shared/components/AddToCalendar/AddToCalendar.js +++ b/packages/web-shared/components/AddToCalendar/AddToCalendar.js @@ -1,4 +1,5 @@ import React from 'react'; + import { Menu } from '@headlessui/react'; import { CalendarPlus, @@ -7,9 +8,10 @@ import { MicrosoftOutlookLogo, FileArrowDown, } from '@phosphor-icons/react'; -import { ActionIcon, List, MenuLink } from './AddToCalendar.styles'; import { addSeconds, parseISO } from 'date-fns'; +import { ActionIcon, List, MenuLink } from './AddToCalendar.styles'; + function convertToGoogleLink({ start, duration, location, allDay, title }) { const startDate = parseISO(start); const endDate = addSeconds(startDate, duration); diff --git a/packages/web-shared/components/AddToCalendar/AddToCalendar.styles.js b/packages/web-shared/components/AddToCalendar/AddToCalendar.styles.js index e9de00f0..f3e7b043 100644 --- a/packages/web-shared/components/AddToCalendar/AddToCalendar.styles.js +++ b/packages/web-shared/components/AddToCalendar/AddToCalendar.styles.js @@ -1,10 +1,10 @@ import React from 'react'; + import { Menu } from '@headlessui/react'; -import styled from 'styled-components'; -import { withTheme } from 'styled-components'; +import { themeGet } from '@styled-system/theme-get'; import { rgba } from 'polished'; +import styled, { withTheme } from 'styled-components'; -import { themeGet } from '@styled-system/theme-get'; import { system } from '../../ui-kit/_lib/system'; export const ActionIcon = withTheme(styled(Menu.Button)` diff --git a/packages/web-shared/components/AddToCalendar/index.js b/packages/web-shared/components/AddToCalendar/index.js index ad0a8ee8..87cf1a92 100644 --- a/packages/web-shared/components/AddToCalendar/index.js +++ b/packages/web-shared/components/AddToCalendar/index.js @@ -1,2 +1,3 @@ import AddToCalendar from './AddToCalendar'; + export default AddToCalendar; diff --git a/packages/web-shared/components/AppHeader/AppHeader.js b/packages/web-shared/components/AppHeader/AppHeader.js index 850577a2..ab156a67 100644 --- a/packages/web-shared/components/AppHeader/AppHeader.js +++ b/packages/web-shared/components/AppHeader/AppHeader.js @@ -1,11 +1,10 @@ -import Wordmark from '../Wordmark'; -import { useCurrentChurch } from '../../hooks'; -import { Box, Avatar } from '../../ui-kit'; import { User } from '@phosphor-icons/react'; -import SearchStyles from '../Searchbar/Search.styles'; - +import { useCurrentChurch } from '../../hooks'; +import { Box, Avatar } from '../../ui-kit'; import ProfileButton from '../Profile/ProfileButton'; +import SearchStyles from '../Searchbar/Search.styles'; +import Wordmark from '../Wordmark'; function ChurchLogo(props) { const { currentChurch } = useCurrentChurch(); diff --git a/packages/web-shared/components/Auth/AuthConfirm.js b/packages/web-shared/components/Auth/AuthConfirm.js index 444bc485..6ed5ac45 100644 --- a/packages/web-shared/components/Auth/AuthConfirm.js +++ b/packages/web-shared/components/Auth/AuthConfirm.js @@ -2,14 +2,11 @@ import React, { useEffect, useState } from 'react'; import isEmpty from 'lodash/isEmpty'; import { useValidateLogin, useValidateRegister } from '../../hooks'; -// import amplitude from '../../libs/amplitude'; +import { useAnalytics } from '../../providers/AnalyticsProvider'; import { update as updateAuth, useAuth } from '../../providers/AuthProvider'; - import { Box, Button, Input } from '../../ui-kit'; import AuthLayout from './AuthLayout'; - import authSteps from './authSteps'; -import { useAnalytics } from '../../providers/AnalyticsProvider'; const AuthConfirm = (props) => { const [status, setStatus] = useState('IDLE'); @@ -148,6 +145,7 @@ const AuthConfirm = (props) => {