-
Notifications
You must be signed in to change notification settings - Fork 887
Add a rule to ban specified types from being used in type annotations or type assertions. #2175
Conversation
… or type assertions.
Thanks for your interest in palantir/tslint, @calebegg! 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. |
I am covered by the Google corporate CLA. |
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.
can you make the ban type a regex instead? I can see cases where exact matches might not be enough, like with imported types
src/rules/banTypesRule.ts
Outdated
public static metadata: Lint.IRuleMetadata = { | ||
ruleName: "ban-types", | ||
description: Lint.Utils.dedent` | ||
Bans specific global types from being used. Does not ban the |
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.
indent
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.
Done.
src/rules/banTypesRule.ts
Outdated
}, | ||
}, | ||
optionsDescription: Lint.Utils.dedent` | ||
A list of \`["type", "optional explanation here"]\`, which bans |
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.
indent
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.
Done.
Makes sense. Done. |
@calebegg thanks! |
It looks like I can't merge this because the CLA bot doesn't understand corporate CLAs. |
Ah, no problem. I guess I didn't realize my membership wasn't public until now. I'll look into that on my end. |
Figured it out, so it should work next time. |
PR checklist
What changes did you make?
I added a new rule,
ban-types
, that allows a list of specified global types to be banned from use, similar to the existingban
rule for functions.