Skip to content

Commit

Permalink
docs(eslint-plugin):improve docs [consistent-type-exports] (#4792)
Browse files Browse the repository at this point in the history
* feat: update repository

* remove duplicate examples

* feat:add about re-exporting --isolatedModules in When Not To Use It

* feat: add exmaples

* fix: remove duplicate examples in correct

* fix:correct words

* fix: fix space-between

* fix: fix code

* fix: fix code space

* fix: check error

* fix:missed examples

* feat: read review and fix them

fix examples and --Isolatedmodules explain

* feat: add two taps

one is correct, another is incorrect

* fix: add <!--tabs-->

* feat: fix explaination about `isolatedmodules`

* fix: fix explain about `isolatedModules`

* fis: modify When no to use it

* fix: revert change log

* fix: add lint

* fix:  add lint

* add: fix code

* fix:fix docs splits

* feat: add lint

* Update packages/eslint-plugin/docs/rules/consistent-type-exports.md

Co-authored-by: Josh Goldberg <me@joshuakgoldberg.com>
  • Loading branch information
kmin-jeong and JoshuaKGoldberg committed Apr 11, 2022
1 parent 4c428c5 commit 255eea8
Showing 1 changed file with 32 additions and 2 deletions.
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.

## Attributes

Expand Down

0 comments on commit 255eea8

Please sign in to comment.