-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
docs(eslint-plugin):improve docs [consistent-type-exports] #4792
Conversation
Thanks for the PR, @kmin-jeong! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing the example in the "rule details" section
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. | ||
- Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a minor rewording so it goes more along the lines of "If you use --isolatedModules
you don't need this rule since TS would enforce type-export specifiers"
packages/eslint-plugin/CHANGELOG.md
Outdated
@@ -5,7 +5,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline | |||
|
|||
# [5.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.17.0...v5.18.0) (2022-04-04) | |||
|
|||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this?
export interface ButtonProps{ | ||
onClick: () => void; | ||
} | ||
|
||
class Button implements ButtonProps { | ||
onClick(){ | ||
console.log('button!') | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example should illustrated re-exporting types. For example:
export interface ButtonProps{ | |
onClick: () => void; | |
} | |
class Button implements ButtonProps { | |
onClick(){ | |
console.log('button!') | |
} | |
} | |
interface ButtonProps { | |
onClick: () => void; | |
} | |
class Button implements ButtonProps { | |
onClick() { | |
console.log('button!'); | |
} | |
} | |
export { Button }; | |
export type { ButtonProps }; |
Probably we should also give an invalid example, like export { Button, ButtonProps };
Also, I believe code style can be fixed with Prettier. Please remember to format files before committing.
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, you don't need this rule since TS would enforce type-export specifiers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not critical, but I think it's clearer this way:
- If you use --isolatedModules, you don't need this rule since TS would enforce type-export specifiers. | |
- If you use `--isolatedModules`, you don't need this rule since the compiler would error if a type is not re-exported using `export type`. |
fix examples and --Isolatedmodules explain
//invalid example | ||
export { Button, ButtonProps }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to how other rule docs are written. You should use two tabs, one incorrect and one correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Josh-Cena Should I write more explanations about the wrong example?
one is correct, another is incorrect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sending! +1 to what Josh-Cena said, and one little change from me please. 🙂
@JoshuaKGoldberg @Josh-Cena @bradzacher |
packages/eslint-plugin/CHANGELOG.md
Outdated
@@ -5,7 +5,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline | |||
|
|||
# [5.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.17.0...v5.18.0) (2022-04-04) | |||
|
|||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I think this needs to be reverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Josh-Cena ok! I revert the change log and modify the When Not To Use It part splitting two items now!
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. |
There was a problem hiding this comment.
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
@Josh-Cena Does it still look reverted in changelog.md? |
You can check yourself in https://github.com/typescript-eslint/typescript-eslint/pull/4792/files :) |
@Josh-Cena I commit the code with the message "fix: revert change log" yesterday after reverting changelog.md. |
You shouldn't change changelog.md at all. |
@Josh-Cena |
Yes, this looks good to me. Just waiting for one of the maintainers to review it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kmin-jeong and @Josh-Cena! This looks great! 🙌
PR Checklist
Overview
I remove duplicate exports in the "correct" example for fixMixedExportsWithInlineTypeSpecifier. and I add about 'isolatedModules' to "When Not To Use It".
I wish reviewers check to see if it has been modified to fit the context.