-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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): add explicit-module-boundary-types rule #1020
Conversation
Thanks for the PR, @GuyPie! 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. |
6a0d3b6
to
304397c
Compare
36cf7b1
to
96a1ae1
Compare
All the other options are |
@phaux makes sense, I renamed it. |
Hmm. I wonder if this is better suited being combined with I feel like having a single rule that says "ensure the module boundary is explicitly typed" is probably better than a collection of rules with options. |
I agree. How about replacing "no-untyped-public-signature" with a new "explicit-module-boundary-types" rule? |
that sounds like a decent idea. Then it's just a matter of copying the code across. We can delete the old rule in the next major. You can probably make the return type checks a lot simpler as well. Right now To start with, the rule can probably just care about these simple cases: export [default] class Foo {
method(arg) {} // error - need explicit argument type
// error - need explicit function return type
fnMember1 = (arg) => {} // error - need explicit argument type
// error - need explicit function return type
fnMember2 = function foo(arg) {} // error - need explicit argument type
// error - need explicit function return type
get getter() {} // error - need explicit function return type
set setter(arg) {} // error - need explicit argument type
}
export default {
// same as above, but an object
}
export const obj = {
// ditto
}
export [default] function bar1(arg) {} // error - need explicit argument type
// error - need explicit function return type
export const bar2 = function (arg) {} // error - need explicit argument type
// error - need explicit function return type
export const baz = (arg) => {} // error - need explicit argument type
// error - need explicit function return type
export default (arg) => {} // error - need explicit argument type
// error - need explicit function return type is there anything I missed there...? |
2b49f8f
to
e265779
Compare
@bradzacher I added the new
|
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.
one thing that's missing is the argument handling from the no-untyped-public-signature
rule.
Eg:
export default const (arg): void => {} // error - need explicit argument type
export function foo(arg): number { return 1; } // error - need explicit argument type
export class Foo {
bar(arg): string { return '' } // error - need explicit argument type
}
could you please copy that over as well?
packages/eslint-plugin/src/rules/no-untyped-public-signature.ts
Outdated
Show resolved
Hide resolved
packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md
Outdated
Show resolved
Hide resolved
21a581a
to
f474d7e
Compare
👍 will do. |
5360f67
to
52e4d25
Compare
5df0e66
to
6d3d34d
Compare
@bradzacher I added a 'missingArgType' check. |
921c65a
to
e7dfcec
Compare
…ipt-eslint#65) This rule will deprecate no-untyped-public-signatures, as it covers the same functionality but checks exported functions in additio n to class methods.
It is being superseded by explicit-module-boundary-types.
Add 'missingReturnType' check for arguments, add docs for 'allowDirectConstAssertionInArrowFunctions' option, fix readme rule name.
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.
LGTM - thanks for doing this.
Codecov Report
@@ Coverage Diff @@
## master #1020 +/- ##
==========================================
- Coverage 95.56% 95.56% -0.01%
==========================================
Files 144 144
Lines 6568 6567 -1
Branches 1877 1876 -1
==========================================
- Hits 6277 6276 -1
- Misses 109 111 +2
+ Partials 182 180 -2
|
typescript-eslint/typescript-eslint#1020 has introduced `explicit-module-boundary-types`, and deprecated `no-untyped-public-signature`. See also: - https://github.com/typescript-eslint/typescript-eslint/blob/v2.19.0/packages/eslint-plugin/docs/rules/no-untyped-public-signature.md - https://github.com/typescript-eslint/typescript-eslint/blob/v2.19.0/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md
typescript-eslint/typescript-eslint#1020 has introduced `explicit-module-boundary-types`, and deprecated `no-untyped-public-signature`. See also: - https://github.com/typescript-eslint/typescript-eslint/blob/v2.19.0/packages/eslint-plugin/docs/rules/no-untyped-public-signature.md - https://github.com/typescript-eslint/typescript-eslint/blob/v2.19.0/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md
Fixes #65