Skip to content

Commit

Permalink
introduce ts-unused-exports in replacement of find-unused-exports (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
znarf authored May 22, 2024
1 parent 5c257fa commit 6e5ab83
Show file tree
Hide file tree
Showing 144 changed files with 322 additions and 302 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ jobs:

- run: npm run depcheck

# find-unused-exports:
# runs-on: ubuntu-latest
ts-unused-exports:
runs-on: ubuntu-latest

# timeout-minutes: 15
timeout-minutes: 15

# steps:
# - name: Checkout
# uses: actions/checkout@v4
steps:
- name: Checkout
uses: actions/checkout@v4

# - name: Setup project
# uses: ./.github/actions/setup-project
# with:
# CACHE_VERSION: ${{ secrets.CACHE_VERSION }}
- name: Setup project
uses: ./.github/actions/setup-project
with:
CACHE_VERSION: ${{ secrets.CACHE_VERSION }}

# - run: npm run find-unused-exports
- run: npm run ts-unused-exports

check-langs:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion components/EditTagsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const tagStatsQuery = gql`
}
`;

export type EditTagsModalProps = {
type EditTagsModalProps = {
collective: Collective;
onClose: () => void;
};
Expand Down
3 changes: 1 addition & 2 deletions components/FormikZod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export const FormikZodContext = React.createContext<{
* component will not work out of the box with `StyledInputFormikField` and other components that rely on Formik context such as `Field` or `FastField`.
* If you are trying to access Formik state via context, use `useFormikContext`. Only use this hook if you are NOT using <Formik> or withFormik.
*/
// ts-unused-exports:disable-next-line
export function useFormikZod<Values extends FormikValues = FormikValues>({
schema,
...props
Expand Down Expand Up @@ -338,5 +339,3 @@ export function FormikZod<Values extends FormikValues = FormikValues>({
</FormikZodContext.Provider>
);
}

// ignore unused exports useFormikZod, FormikZod, getInputAttributesFromZodSchema
8 changes: 7 additions & 1 deletion components/I18nFormatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FormattedMessage } from 'react-intl';
import Link from './Link';
import StyledLink from './StyledLink';

// ignore unused exports
// utility library

// eslint-disable-next-line react/display-name
Expand All @@ -13,9 +12,13 @@ export const getI18nLink = linkProps => chunks => (
);
export const I18nBold = chunks => <strong>{chunks}</strong>;
export const I18nItalic = chunks => <i>{chunks}</i>;
// ts-unused-exports:disable-next-line
export const I18nCode = chunks => <code>{chunks}</code>;
// ts-unused-exports:disable-next-line
export const I18nOrderedList = chunks => <ol className="list-inside list-decimal">{chunks}</ol>;
// ts-unused-exports:disable-next-line
export const I18nUnorderedList = chunks => <ul className="list-inside list-disc">{chunks}</ul>;
// ts-unused-exports:disable-next-line
export const I18nListItem = chunks => <li>{chunks}</li>;

export const I18nUnderline = chunks => <u>{chunks}</u>;
Expand All @@ -33,11 +36,14 @@ export const I18nSignInLink = chunks => (
</StyledLink>
);

// ts-unused-exports:disable-next-line
export const I18nTOSLink = msg => (
<StyledLink as={Link} href="/tos">
<span>{msg}</span>
</StyledLink>
);

// ts-unused-exports:disable-next-line
export const I18nPrivacyLink = msg => (
<StyledLink as={Link} href="/privacypolicy">
<span>{msg}</span>
Expand Down
17 changes: 2 additions & 15 deletions components/ModalContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ const reducer = (state: ModalContextValues, action: ModalAction) => {
}
};

export type CloseComponentType = React.ComponentType<{
onClick: React.MouseEventHandler<any>;
}>;

export type ContentComponentType = React.ComponentType<{
className?: string;
children: React.ReactNode;
}>;

const ModalRoot = () => {
const { modals, hideModal } = useModal();
return modals.map(({ component: Component, modalProps, type, id, open }) => {
Expand All @@ -150,7 +141,7 @@ const ModalRoot = () => {
});
};

const ModalProvider = ({ children }) => {
export const ModalProvider = ({ children }) => {
const initialState = {
modals: [],
showModal: (component, modalProps = {}, modalId) => {
Expand Down Expand Up @@ -178,8 +169,4 @@ const ModalProvider = ({ children }) => {
);
};

const useModal = () => useContext(ModalContext);

// ignore unused exports

export { ModalProvider, useModal };
export const useModal = () => useContext(ModalContext);
1 change: 0 additions & 1 deletion components/StyledDropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import StyledSpinner from './StyledSpinner';
import { P, Span } from './Text';
import UploadedFilePreview from './UploadedFilePreview';

// ignore unused exports DROPZONE_ACCEPT_PDF
export const DROPZONE_ACCEPT_IMAGES = { 'image/*': ['.jpeg', '.png'] };
export const DROPZONE_ACCEPT_PDF = { 'application/pdf': ['.pdf'] };
export const DROPZONE_ACCEPT_ALL = { ...DROPZONE_ACCEPT_IMAGES, ...DROPZONE_ACCEPT_PDF };
Expand Down
3 changes: 2 additions & 1 deletion components/StyledKeyframes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import { keyframes } from 'styled-components';

// ignore unused exports
// utility library

export const rotating = keyframes`
Expand All @@ -16,6 +15,7 @@ export const rotating = keyframes`
}
`;

// ts-unused-exports:disable-next-line
export const fadeIn = keyframes`
from {
opacity: 0;
Expand All @@ -34,6 +34,7 @@ export const slideInUp = keyframes`
}
`;

// ts-unused-exports:disable-next-line
export const fadeInUp = keyframes`
from {
opacity: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { H1, P } from '../Text';

import FindAHostSearch from './FindAHostSearch';

export type StartAcceptingFinancialContributionsPageProps = {
type StartAcceptingFinancialContributionsPageProps = {
collective: Collective;
onChange: (field: string, value: unknown) => void;
};
Expand Down
3 changes: 1 addition & 2 deletions components/budget/DebitCreditList.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const CreditItem = ({ children, ...props }) => {

CreditItem.propTypes = { children: PropTypes.node };

// ignore unused exports default
// used in Stories mdx

// ts-unused-exports:disable-next-line
export default DebitCreditList;
2 changes: 1 addition & 1 deletion components/collective-page/hero/HeroSocialLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function iconForSocialLinkType(type: SocialLinkType) {
return SocialLinkIcon[type] || Globe;
}

export type HeroSocialLinksProps = {
type HeroSocialLinksProps = {
socialLinks: SocialLink[];
relMe?: boolean;
};
Expand Down
2 changes: 1 addition & 1 deletion components/collectives/Banner.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore unused exports default
// keeping the file in case we want to use it in the future

import React from 'react';
Expand Down Expand Up @@ -29,4 +28,5 @@ const Banner = () => (
</Flex>
);

// ts-unused-exports:disable-next-line
export default Banner;
2 changes: 1 addition & 1 deletion components/dashboard/filters/HostsFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const hostsFilterSearchQuery = gql`
${accountHoverCardFields}
`;

export const AccountRenderer = ({
const AccountRenderer = ({
account,
inOptionsList,
}: {
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/filters/PeriodCompareFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Select, SelectContent, SelectItem, SelectValue } from '../../../ui/Sele

import { PeriodFilterCompare, PeriodFilterType, schema } from './schema';

export type PeriodCompareFilterValueType = z.infer<typeof schema>;
type PeriodCompareFilterValueType = z.infer<typeof schema>;

const getAvailableTimeUnits = (value: PeriodCompareFilterValueType): TimeUnit[] => {
const { dateTo, dateFrom } = getPeriodDates(value);
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/sections/contributions/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const schema = z.object({
paymentMethod: z.string().optional(),
});

export type FilterValues = z.infer<typeof schema>;
type FilterValues = z.infer<typeof schema>;

export type FilterMeta = {
currency?: Currency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ PaypalPreApprovalDetailsIcon.propTypes = {
}),
};

// ignore unused exports default
// keep for future use?

// ts-unused-exports:disable-next-line
export default PaypalPreApprovalDetailsIcon;
2 changes: 1 addition & 1 deletion components/dashboard/sections/expenses/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const schema = z.object({
virtualCard: isMulti(z.string()).optional(),
});

export type FilterValues = z.infer<typeof schema>;
type FilterValues = z.infer<typeof schema>;

export type FilterMeta = {
currency?: Currency;
Expand Down
4 changes: 2 additions & 2 deletions components/dashboard/sections/tax-information/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const TaxFormNameFields = z.object({
lastName: z.string().min(1).max(50),
});

export type TaxFormNameValues = z.infer<typeof TaxFormNameFields>;
// type TaxFormNameValues = z.infer<typeof TaxFormNameFields>;

export const TaxFormLocationFields = z.object({
country: z.string(),
Expand All @@ -76,7 +76,7 @@ export const TaxFormLocationFields = z.object({
}),
});

export type TaxFormLocationValues = z.infer<typeof TaxFormLocationFields>;
// type TaxFormLocationValues = z.infer<typeof TaxFormLocationFields>;

export const BaseFormSchema = z.object({
isUSPersonOrEntity: z.boolean(),
Expand Down
2 changes: 1 addition & 1 deletion components/edit-collective/EditVirtualCardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const throttledCall = debounce((searchFunc, variables) => {
return searchFunc({ variables });
}, 750);

export type EditVirtualCardModalProps = {
type EditVirtualCardModalProps = {
host: Account;
collective?: Account;
virtualCard?: VirtualCard;
Expand Down
2 changes: 1 addition & 1 deletion components/edit-collective/SocialLinksFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import StyledInput from '../StyledInput';
import StyledSelect from '../StyledSelect';
import { Span } from '../Text';

export type SocialLinksFormFieldProps = {
type SocialLinksFormFieldProps = {
value?: SocialLink[];
touched?: boolean;
onChange: (value: SocialLinkInput[]) => void;
Expand Down
2 changes: 1 addition & 1 deletion components/expenses/ApproveExpenseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useToast } from '../ui/useToast';

import { editExpenseCategoryMutation } from './graphql/mutations';

export type ConfirmProcessExpenseModalProps = {
type ConfirmProcessExpenseModalProps = {
onClose: () => void;
expense: Expense;
host: Host;
Expand Down
4 changes: 2 additions & 2 deletions components/expenses/ConfirmProcessExpenseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const MessagesPerType: Record<
},
};

export type ConfirmProcessExpenseModalType =
type ConfirmProcessExpenseModalType =
| 'REQUEST_RE_APPROVAL'
| 'MARK_AS_INCOMPLETE'
| 'MARK_AS_SPAM'
Expand All @@ -171,7 +171,7 @@ export type ConfirmProcessExpenseModalType =
| 'HOLD'
| 'RELEASE';

export type ConfirmProcessExpenseModalProps = {
type ConfirmProcessExpenseModalProps = {
type: ConfirmProcessExpenseModalType;
onClose: () => void;
expense: Pick<Expense, 'id' | 'legacyId' | 'permissions'>;
Expand Down
2 changes: 1 addition & 1 deletion components/expenses/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { validateTaxInput } from '../../taxes/TaxesFormikFields';
import { ExpenseItemFormValues } from '../types/FormValues';

// Please adjust the values below based on `prepareItems` from `api/server/graphql/common/expenses.ts`
// ignore unused exports FX_RATE_WARNING_THRESHOLD
// ts-unused-exports:disable-next-line
export const FX_RATE_WARNING_THRESHOLD = 0.02;
export const FX_RATE_ERROR_THRESHOLD = 0.1;

Expand Down
7 changes: 0 additions & 7 deletions components/submit-expense/ExpenseItemsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ import { Button } from '../ui/Button';

import { ExpenseForm } from './useExpenseForm';

export type ExpenseItem = {
description: string;
date: string;
amount: { valueInCents: number; currency: string };
url?: string;
};

type ExpenseItemsFormProps = {
className?: string;
form: ExpenseForm;
Expand Down
4 changes: 2 additions & 2 deletions components/submit-expense/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ExpenseStepOrder = [
ExpenseFlowStep.EXPENSE_SUMMARY,
];

export type StepDefinition<
type StepDefinition<
FormValues extends Record<string, any>,
Form extends ReturnType<typeof useFormik<FormValues>>,
AddProps = never,
Expand All @@ -49,7 +49,7 @@ export type StepDefinition<
Subtitle?: React.FC<{ form: Form } | {}>;
};

export type ExpenseStepDefinition = StepDefinition<ExpenseFormValues, ExpenseForm>;
type ExpenseStepDefinition = StepDefinition<ExpenseFormValues, ExpenseForm>;

export const Steps: Record<ExpenseFlowStep, ExpenseStepDefinition> = {
[ExpenseFlowStep.COLLECTIVE]: {
Expand Down
4 changes: 2 additions & 2 deletions components/submit-expense/useExpenseForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { computeExpenseAmounts, expenseTypeSupportsItemCurrency, getSupportedCur
import { loggedInAccountExpensePayoutFieldsFragment } from '../expenses/graphql/fragments';
import { getCustomZodErrorMap } from '../FormikZod';

export type ExpenseTypeOption = ExpenseType.INVOICE | ExpenseType.RECEIPT;
type ExpenseTypeOption = ExpenseType.INVOICE | ExpenseType.RECEIPT;

export type ExpenseItem = {
description?: string;
Expand Down Expand Up @@ -92,7 +92,7 @@ export type ExpenseFormValues = {
};
};

export type ExpenseFormik = Omit<ReturnType<typeof useFormik<ExpenseFormValues>>, 'setFieldValue'> & {
type ExpenseFormik = Omit<ReturnType<typeof useFormik<ExpenseFormValues>>, 'setFieldValue'> & {
setFieldValue: <F extends Path<ExpenseFormValues>>(
field: F,
value: PathValue<ExpenseFormValues, F>,
Expand Down
3 changes: 1 addition & 2 deletions components/ui/AlertDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ const AlertDialogCancel = React.forwardRef<
));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;

// ignore unused exports
// ui library

// ts-unused-exports:disable-next-line
export {
AlertDialog,
AlertDialogPortal,
Expand Down
2 changes: 1 addition & 1 deletion components/ui/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { cn } from '../../lib/utils';

import { buttonVariants } from './Button';

export type CalendarProps = React.ComponentProps<typeof DayPicker>;
type CalendarProps = React.ComponentProps<typeof DayPicker>;

function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) {
return (
Expand Down
1 change: 0 additions & 1 deletion components/ui/Collapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const CollapsibleContent = React.forwardRef<
));
CollapsibleContent.displayName = CollapsiblePrimitive.CollapsibleContent.displayName;

// ignore unused exports
// ui library

export { Collapsible, CollapsibleTrigger, CollapsibleContent };
Loading

0 comments on commit 6e5ab83

Please sign in to comment.