-
Notifications
You must be signed in to change notification settings - Fork 889
promise-function-async: add options to specify function types to check. #3807
promise-function-async: add options to specify function types to check. #3807
Conversation
Thanks for your interest in palantir/tslint, @blair! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
e094ec7
to
cf9028d
Compare
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! Just the one comment regarding default options
minLength: 0, | ||
maxLength: 4, | ||
}, | ||
optionExamples: [[true, OPTION_FUNCTION_DECLARATION, OPTION_METHOD_DECLARATION]], |
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.
maybe we can add two examples here, the one that you added and the other true
?
|
||
type EnabledSyntaxKinds = ReadonlySet<number>; | ||
|
||
function parseOptions(ruleArguments: string[]): EnabledSyntaxKinds { |
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.
i think if this rule is enabled we should default to all kinds. Or else what's the point of turning the rule on in the first place?
This is useful if you only want your function and method declarations to warn, or in other words, one doesn't want each arrow function that is passed to Promise#then() or Promise#catch() to be async.
cf9028d
to
459ee72
Compare
@suchanlee Please take another look, I made the requested changes. BTW, I didn't know if I should have a new commit on top of the original one or replace it, I did the later with a forced push. |
Thanks for the contribution @blair! Replacing the commit is fine. |
…k. (palantir#3807) This is useful if you only want your function and method declarations to warn, or in other words, one doesn't want each arrow function that is passed to Promise#then() or Promise#catch() to be async.
PR checklist
Overview of change:
If one wants to enable the
promise-function-async
warning, then one gets warnings for all functions, including arrow functions that are passed to Promise#then() and Promise#catch(). There's no point in making these async then then() and catch() already handle the given function throwing an exception.This commit allows one to select which function types to check. A useful option is to only check function and method declarations.
Question: after this PR, all the warnings will be disabled by default. Should they all be enabled if there are no options set?
CHANGELOG.md entry:
[rule-change]
promise-function-async
add rules options to enable checks for the four different types of functions.