Skip to content

docs(eslint-plugin):improve docs [consistent-type-exports] #4792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Apr 11, 2022
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions packages/eslint-plugin/docs/rules/consistent-type-exports.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,37 @@ This rule aims to standardize the use of type exports style across a codebase.

Given a class `Button`, and an interface `ButtonProps`, examples of code:

<!--tabs-->

### ❌ Incorrect

```ts
interface ButtonProps {
onClick: () => void;
}
class Button implements ButtonProps {
onClick() {
console.log('button!');
}
}
export { Button, ButtonProps };
```

### ✅ Correct

```ts
interface ButtonProps {
onClick: () => void;
}
class Button implements ButtonProps {
onClick() {
console.log('button!');
}
}
export { Button };
export type { ButtonProps };
```

## Options

```ts
Expand Down Expand Up @@ -70,15 +101,14 @@ export type { ButtonProps } from 'some-library';
### ✅ Correct

```ts
export { Button } from 'some-library';
export type { ButtonProps } from 'some-library';
export { Button, type ButtonProps } from 'some-library';
```

## When Not To Use It

- If you are using a TypeScript version less than 3.8, then you will not be able to use this rule as type exports are not supported.
- If you specifically want to use both export kinds for stylistic reasons, you can disable this rule.
- If you use `--isolatedModules` the compiler would error if a type is not re-exported using `export type`. If you also don't wish to enforce one style over the other, you can disable this rule.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this into two items


## Attributes

Expand Down