-
Notifications
You must be signed in to change notification settings - Fork 885
Add array-simple option to array-type rule #1539
Conversation
type: "style", | ||
}; | ||
/* tslint:enable:object-literal-sort-keys */ | ||
|
||
public static FAILURE_STRING_ARRAY = "Array type using 'Array<T>' is forbidden. Use 'T[]' instead."; | ||
public static FAILURE_STRING_GENERIC = "Array type using 'T[]' is forbidden. Use 'Array<T>' instead."; | ||
public static FAILURE_STRING_ARRAY_SIMPLE = "Array type using 'Array<T>' is forbidden for simple types. Use 'T[]' instead."; | ||
public static FAILURE_STRING_GENERIC_SIMPLE = "Array type using 'T[]' is forbidden for simple types. Use 'Array<T>' instead."; |
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.
this one should say "for non-simple types"
thanks, Scott! can't wait to tsunami this one again. |
Thanks for reviewing this @alexeagle! Will merge after corrections |
Just ran this fix across google's codebase. I noticed that |
Hmm, I marked all TypeReferences, so I'm guessing it should only be TypeReferences that are not generics. In that case, should |
If we simply apply to non-generic TypeReferences we get I think the real readability issue is that the syntax sugar is postfix, so if it follows a very long expression, like So on that grounds, I think treating generics as a "non-simple" type is the right thing to do, even if we lose a bit of sugar for |
@evmar comments? |
If I had to vote in the cases you gave above, I prefer the following (bolded) options:
|
@ScottSWu would you like me to take this one over? |
Only use '[]' notation for 'simple' types.
* Nested Arrays are ok as long as their type argument is also simple * Add namespace test case * Fix typos and test cases
e3733eb
to
f51df43
Compare
Sorry - PTAL The new commit follows @jkillian's preferences with |
Thanks @ScottSWu I ran it across all our code again. Looks really good! Found bugs:
became
|
The first is fixable, but the second looks weird - I'll add that as a test case, but could that be a syncing issue? |
I doubt it's sync in this case (I own the code that was mangled and haven't changed it) but as long as there's a test case, tslint is not responsible for what happens :) |
* Add test cases for interface and 'as' keyword * Fix format in test files
Added both test cases. For the first bug, I added a space for the |
LGTM thanks a lot Scott! Looking forward to turning this one on. |
ping @jkillian for LGTM |
thanks @ScottSWu! |
Only use '[]' notation for 'simple' types.
Fixes #1526