-
Notifications
You must be signed in to change notification settings - Fork 888
rule suggestion: disallow "I" prefix in interface names #512
Comments
What would you be enforcing? That no interface names start with I? What if the name being used just happened to start with I (like If it did go in to the core rules, it wouldn't be a new rule, it should be an option on the existing rule. |
for example, I want enforce use ServiceProviderClass instead of IServiceProviderClass. rule is simple. If |
I
prefix
👍 |
👍 |
Cool, we'd be open to a PR for disallowing the One option might be to permit regexes for enforcing name formats. However this sounds like it could get complex quickly and has the potential to slow down linting a lot. Having limited options that most people in the community can agree on has the advantages of consistency and fewer decisions to make. |
Another downside to regexes: they're a pain to specify as a string (which is how you have to specify them in a JSON file). Not that we should completely avoid them, and for simple ones (as most would be in this case) it's not too bad either. |
👍 on |
👍 for |
#1037 is merged 😉 |
Why is this in place? Probably the worst linting rule I have ever seen. |
@ORESoftware https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#names It REALLY annoys me when I see an interface name starting with "I". This is TS, not C#. Java has very good arguments against using "I" as a prefix. |
In Java, I is used so you know it's an interface and not a class. It's a useful paradigm. The same paradigm could be used in TS, but "no we want to be special". What is reason to not use I? Literally I can use any letter in the alphabet but I? How dumb is that. |
👍Looks like the default is still to prefix with |
@Fandy I for one would welcome the PR. I had actually carried over the standard I-prefix from C# but after having read through a lot of the current naming conventions and standards it seems that interfaces not being prefixed with "I" has become widespread enough to consider it the standard. Added to the fact that the TS Team does not choose to prefix with "I" for a variety of reasons it just lends more credit to the argument against it. Whether everybody agrees that just because something is the status quo it should be followed, it still doesn't change the fact that it has become the status quo and this linting rule only serves to confuse new TS developers that want to adhere to that. TLDR I think it's time we change this rule's default behavior/setting to not require the "I" prefix. |
https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#names
now, tslint has interface-name rule. but it is not a TypeScript team recommended.
if I create the pull request, will you accept it?
The text was updated successfully, but these errors were encountered: