diff --git a/packages/eslint-plugin/docs/rules/consistent-type-exports.md b/packages/eslint-plugin/docs/rules/consistent-type-exports.md index 9145d83d29f6..50a6fea96da9 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-exports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-exports.md @@ -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: + + +### ❌ 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 @@ -70,8 +101,6 @@ 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'; ``` @@ -79,6 +108,7 @@ export { Button, type ButtonProps } from 'some-library'; - 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
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: