Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Add a rule to ban specified types from being used in type annotations or type assertions. #2175

Merged
merged 3 commits into from Feb 7, 2017
Merged

Conversation

calebegg
Copy link
Contributor

@calebegg calebegg commented Feb 5, 2017

PR checklist

  • New feature, bugfix, or enhancement
    • Includes tests

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 existing ban rule for functions.

@palantirtech
Copy link
Member

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.

@calebegg
Copy link
Contributor Author

calebegg commented Feb 5, 2017

I am covered by the Google corporate CLA.

Copy link
Contributor

@nchen63 nchen63 left a 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

public static metadata: Lint.IRuleMetadata = {
ruleName: "ban-types",
description: Lint.Utils.dedent`
Bans specific global types from being used. Does not ban the
Copy link
Contributor

Choose a reason for hiding this comment

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

indent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

},
},
optionsDescription: Lint.Utils.dedent`
A list of \`["type", "optional explanation here"]\`, which bans
Copy link
Contributor

Choose a reason for hiding this comment

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

indent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@calebegg
Copy link
Contributor Author

calebegg commented Feb 7, 2017

Makes sense. Done.

@nchen63
Copy link
Contributor

nchen63 commented Feb 7, 2017

@calebegg thanks!

@calebegg
Copy link
Contributor Author

calebegg commented Feb 7, 2017

It looks like I can't merge this because the CLA bot doesn't understand corporate CLAs.

@nchen63 nchen63 merged commit 6cb9369 into palantir:master Feb 7, 2017
@bluekeyes
Copy link
Member

Hey @calebegg, sorry about the CLA problems - the bot currently uses public membership in the google organization to check for the corporate CLA. I filed an internal ticket to look at alternatives or better messaging.

@calebegg
Copy link
Contributor Author

calebegg commented Feb 7, 2017

Ah, no problem. I guess I didn't realize my membership wasn't public until now. I'll look into that on my end.

@calebegg calebegg deleted the ban-type-rule branch February 7, 2017 21:40
@calebegg
Copy link
Contributor Author

calebegg commented Feb 7, 2017

Figured it out, so it should work next time.

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

Successfully merging this pull request may close these issues.

None yet

4 participants