Skip to content

Commit 282cbf4

Browse files
authored
Follow no-empty-object-type lint rule (#14694)
This rule comes from `typescript-eslint`: https://typescript-eslint.io/rules/no-empty-object-type/ We don't have it enabled yet, but in v8 it's part of the "recommended" preset: https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/#updated-configuration-rules In order to keep the upgrade to that version as small as possible, this change pre-emptively fixes code considered incorrect by that rule. The issues all relate to empty interfaces, for which the linter points out that: ``` An interface declaring no members is equivalent to its supertype ``` Solutions to this include using the supertype directly, or type aliasing the supertype to the new name. This change opts for the latter: ```ts interface SuperType { a: string }; interface SubType extends SuperType {}; ``` becomes: ```ts interface SuperType { a: string }; type SubType = SuperType; ``` There are some differences between type aliases and interfaces: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces If we prefer to keep the interfaces, we can instead customise this lint rule in DCAR, setting `allowInterfaces` to `'with-single-extends'`: https://typescript-eslint.io/rules/no-empty-object-type/#allowinterfaces The cost would be diverging from our centralised linting rules, and therefore adding some complexity to DCAR.
1 parent 38cb2e1 commit 282cbf4

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

dotcom-rendering/src/components/EditorialButton/EditorialButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ButtonProps as CoreButtonProps } from '@guardian/source/react-comp
22
import { Button as CoreButton } from '@guardian/source/react-components';
33
import { decideBackground, decideBorder, decideFont } from './styles';
44

5-
export interface EditorialButtonProps extends CoreButtonProps {}
5+
export type EditorialButtonProps = CoreButtonProps;
66

77
/**
88
*

dotcom-rendering/src/components/EditorialButton/EditorialLinkButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { LinkButtonProps as CoreLinkButtonProps } from '@guardian/source/re
22
import { LinkButton as CoreLinkButton } from '@guardian/source/react-components';
33
import { decideBackground, decideBorder, decideFont } from './styles';
44

5-
export interface EditorialLinkButtonProps extends CoreLinkButtonProps {}
5+
export type EditorialLinkButtonProps = CoreLinkButtonProps;
66

77
/**
88
*

dotcom-rendering/src/components/ManyNewslettersFormFields.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ const recaptchaContainerStyle = (showRecaptchaContainer: boolean) => css`
4545
}
4646
`;
4747

48-
export interface ManyNewslettersFormFieldsProps
49-
extends Omit<FormProps, 'handleSubmitButton' | 'newsletterCount'> {}
48+
export type ManyNewslettersFormFieldsProps = Omit<
49+
FormProps,
50+
'handleSubmitButton' | 'newsletterCount'
51+
>;
5052

5153
export const ManyNewslettersFormFields: FC<ManyNewslettersFormFieldsProps> = ({
5254
status,

0 commit comments

Comments
 (0)