Commit 282cbf4
authored
Follow
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.no-empty-object-type lint rule (#14694)1 parent 38cb2e1 commit 282cbf4
File tree
3 files changed
+6
-4
lines changed- dotcom-rendering/src/components
- EditorialButton
3 files changed
+6
-4
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
0 commit comments