Skip to content
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

feat(eslint-plugin): [require-types-exports] add rule #10554

Draft
wants to merge 103 commits into
base: main
Choose a base branch
from

Conversation

JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

Continuation of @StyleShit's #8443 as indicated in #8443 (comment).

Co-authored-by: @StyleShit

Copy link

nx-cloud bot commented Dec 26, 2024

View your CI Pipeline Execution ↗ for commit 8dc9607.

Command Status Duration Result
nx test eslint-plugin --coverage=false ❌ Failed 6m 10s View ↗
nx run-many --target=build --exclude website --... ✅ Succeeded 58s View ↗
nx test utils ✅ Succeeded 4s View ↗
nx run types:build ✅ Succeeded <1s View ↗
nx test type-utils ✅ Succeeded 17s View ↗
nx test typescript-estree ✅ Succeeded 58s View ↗
nx test typescript-estree --coverage=false ✅ Succeeded 1m 10s View ↗
nx test visitor-keys --coverage=false ✅ Succeeded 3s View ↗
Additional runs (21) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2024-12-27 20:32:51 UTC

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review December 26, 2024 19:48
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as draft December 26, 2024 19:52
Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 88.94737% with 21 lines in your changes missing coverage. Please review.

Project coverage is 86.88%. Comparing base (3ae4148) to head (e09b7d9).

Current head e09b7d9 differs from pull request most recent head 8dc9607

Please upload reports for the commit 8dc9607 to get more accurate results.

Files with missing lines Patch % Lines
...s/eslint-plugin/src/rules/require-types-exports.ts 88.52% 12 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10554      +/-   ##
==========================================
+ Coverage   86.86%   86.88%   +0.02%     
==========================================
  Files         445      446       +1     
  Lines       15455    15640     +185     
  Branches     4507     4545      +38     
==========================================
+ Hits        13425    13589     +164     
- Misses       1675     1687      +12     
- Partials      355      364       +9     
Flag Coverage Δ
unittest 86.88% <88.94%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...lugin-internal/src/rules/plugin-test-formatting.ts 82.79% <ø> (ø)
packages/eslint-plugin/src/rules/array-type.ts 97.26% <ø> (ø)
packages/eslint-plugin/src/rules/await-thenable.ts 100.00% <ø> (ø)
packages/eslint-plugin/src/rules/ban-ts-comment.ts 100.00% <ø> (ø)
...t-plugin/src/rules/class-literal-property-style.ts 100.00% <ø> (ø)
.../eslint-plugin/src/rules/class-methods-use-this.ts 91.30% <ø> (ø)
...lugin/src/rules/consistent-generic-constructors.ts 90.24% <ø> (ø)
...lugin/src/rules/consistent-indexed-object-style.ts 97.89% <ø> (ø)
...kages/eslint-plugin/src/rules/consistent-return.ts 93.75% <ø> (ø)
...int-plugin/src/rules/consistent-type-assertions.ts 94.82% <ø> (ø)
... and 74 more

@@ -31,9 +31,9 @@ interface Config {
};
}

type Options = [Config];
export type Options = [Config];
Copy link
Contributor

Choose a reason for hiding this comment

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

Side note: Next rule has I lined the options and does not have Config as separate type. Maybe for consistency this type could be inlined too, if you are doing another PR just for these export changes :) Or if the separate Config type is preferred, maybe there could be some follow up
task for unifying these.
I don’t feel like this would matter if they would stay as internal types. But after they are exposed to “public”, it would look better if they had unified names. :)

Copy link
Contributor

@rubiesonthesky rubiesonthesky left a comment

Choose a reason for hiding this comment

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

I know this is a draft, but just few suggestions to not to export empty types.

Edit: I should have left these comments on the another PR which is just about the type
exports 😅

type Options = [];
type MessageIds = 'useTopLevelQualifier';
export type Options = [];
export type MessageIds = 'useTopLevelQualifier';

export default createRule<Options, MessageIds>({
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export default createRule<Options, MessageIds>({
export default createRule<[], MessageIds>({

@@ -10,8 +10,8 @@ import {
NullThrowsReasons,
} from '../util';

type Options = [];
type MessageIds = 'useTopLevelQualifier';
export type Options = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export type Options = [];

(no longer needed)

type Options = [];
type MessageIds = 'unaryMinus';
export type Options = [];
export type MessageIds = 'unaryMinus';

export default util.createRule<Options, MessageIds>({
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export default util.createRule<Options, MessageIds>({
export default util.createRule<[], MessageIds>({

@@ -3,8 +3,8 @@ import * as ts from 'typescript';

import * as util from '../util';

type Options = [];
type MessageIds = 'unaryMinus';
export type Options = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export type Options = [];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule proposal: Export all types used in exports
3 participants