From 6dc1d085901fa7c5704a07a1ec412d7e83e44293 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Fri, 8 Sep 2023 13:14:41 +0200 Subject: [PATCH] Re-enabled general eslint rules in TS config refs https://github.com/TryGhost/DevOps/issues/50 - when creating a TS config in our `eslint-plugin-ghost` dependency, I only extended the recommended config, which left out a lot of stylistic things we used to enforce in JS - this fixes that by bumping the dependency to a version which extends those shared configs, and fixes all the code that currently goes against those rules --- apps/comments-ui/src/App.tsx | 12 +- apps/comments-ui/src/AuthFrame.tsx | 2 +- apps/comments-ui/src/components/IFrame.tsx | 2 +- .../src/components/content/Pagination.tsx | 2 +- .../components/content/RepliesPagination.tsx | 2 +- apps/comments-ui/src/utils/helpers.ts | 2 +- apps/comments-ui/src/utils/options.ts | 2 +- .../src/BookshelfRepository.ts | 6 +- ghost/collections/src/Collection.ts | 2 +- ghost/collections/src/CollectionRepository.ts | 2 +- ghost/collections/src/CollectionsService.ts | 16 +- .../src/DonationBookshelfRepository.ts | 8 +- ghost/donations/src/DonationRepository.ts | 2 +- ghost/mail-events/src/MailEventService.ts | 2 +- .../src/ModelToDomainEventInterceptor.ts | 2 +- .../src/BookshelfRecommendationRepository.ts | 18 +-- .../src/InMemoryRecommendationRepository.ts | 6 +- ghost/recommendations/src/Recommendation.ts | 40 ++--- .../src/RecommendationController.ts | 61 ++++---- .../src/RecommendationRepository.ts | 8 +- .../src/RecommendationService.ts | 26 ++-- ghost/recommendations/src/WellknownService.ts | 12 +- package.json | 2 +- yarn.lock | 145 ++++++++---------- 24 files changed, 185 insertions(+), 197 deletions(-) diff --git a/apps/comments-ui/src/App.tsx b/apps/comments-ui/src/App.tsx index 0a82a0c4d8..74635aa618 100644 --- a/apps/comments-ui/src/App.tsx +++ b/apps/comments-ui/src/App.tsx @@ -1,3 +1,5 @@ +/* eslint-disable no-shadow */ + import AuthFrame from './AuthFrame'; import ContentBox from './components/ContentBox'; import PopupBox from './components/PopupBox'; @@ -32,7 +34,7 @@ const App: React.FC = ({scriptTag}) => { siteUrl: options.siteUrl, apiUrl: options.apiUrl!, apiKey: options.apiKey! - }) + }); }, [options]); const [adminApi, setAdminApi] = useState(null); @@ -45,7 +47,7 @@ const App: React.FC = ({scriptTag}) => { return { ...state, ...newState - } + }; }); }, [setFullState]); @@ -55,7 +57,7 @@ const App: React.FC = ({scriptTag}) => { // because updates to state may be asynchronous // so calling dispatchAction('counterUp') multiple times, may yield unexpected results if we don't use a callback function setState((state) => { - return SyncActionHandler({action, data, state, api, adminApi: adminApi!, options}) + return SyncActionHandler({action, data, state, api, adminApi: adminApi!, options}); }); return; } @@ -66,7 +68,7 @@ const App: React.FC = ({scriptTag}) => { setState((state) => { ActionHandler({action, data, state, api, adminApi: adminApi!, options}).then((updatedState) => { setState({...updatedState}); - }).catch(console.error); + }).catch(console.error); // eslint-disable-line no-console // No immediate changes return {}; @@ -125,7 +127,7 @@ const App: React.FC = ({scriptTag}) => { pagination: data.meta.pagination, count: count }; - } + }; /** Initialize comments setup on load, fetch data and setup state*/ const initSetup = async () => { diff --git a/apps/comments-ui/src/AuthFrame.tsx b/apps/comments-ui/src/AuthFrame.tsx index a1de1483ec..8410eacb29 100644 --- a/apps/comments-ui/src/AuthFrame.tsx +++ b/apps/comments-ui/src/AuthFrame.tsx @@ -10,5 +10,5 @@ const AuthFrame: React.FC = ({adminUrl, onLoad}) => { return ( ); -} +}; export default AuthFrame; diff --git a/apps/comments-ui/src/components/IFrame.tsx b/apps/comments-ui/src/components/IFrame.tsx index ffb73b8a1c..3dc5e8de0c 100644 --- a/apps/comments-ui/src/components/IFrame.tsx +++ b/apps/comments-ui/src/components/IFrame.tsx @@ -37,7 +37,7 @@ export default class IFrame extends Component { if (this.props.onResize) { // eslint-disable-next-line @typescript-eslint/no-unused-vars - (new ResizeObserver(_ => { + (new ResizeObserver((_) => { window.requestAnimationFrame(() => { this.props.onResize(this.iframeRoot); }); diff --git a/apps/comments-ui/src/components/content/Pagination.tsx b/apps/comments-ui/src/components/content/Pagination.tsx index abf5d200d7..c933737f50 100644 --- a/apps/comments-ui/src/components/content/Pagination.tsx +++ b/apps/comments-ui/src/components/content/Pagination.tsx @@ -18,7 +18,7 @@ const Pagination = () => { return null; } - const text = left === 1 ? t('Show 1 previous comment') : t('Show {{amount}} previous comments', {amount: formatNumber(left)}) + const text = left === 1 ? t('Show 1 previous comment') : t('Show {{amount}} previous comments', {amount: formatNumber(left)}); return (