You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
For context I have an object literal that I am using as a data store where the keys are CSGO team names. The code above is a sample but the real object is about 100 entries. Storing data in literals like this is not a great idea admittedly but the implication is that the keys can contain pretty much any character (for example capital letters) anywhere in the string.
The actual code sample is the order specified by TSLint. It looks like the rule compares strings by just doing > and JavaScript sorts capitals first IIRC which is what is giving the "almost" alphabetical result.
Another simpler example would be:
// What the rule wantsconstactualAgain={array: [],objList: [{},{}],object: {},}// AlphabeticalconstexpectedAgain={array: [],object: {},objList: [{},{}],}
The result is kind of logical but unexpected. If I were going through the code above and sorting my literals I would do it alphabetically and the fact that the rule told me otherwise would be confusing, it almost reduces you to trial and error unless you understand the comparison logic being used.
So my question is
Should it ideally be sorting alphabetically? (I am thinking .toUpperCase() on both before comparison)
If not by default should it be an option?
Also thinking now about the iffy sample I've given, would it be good to subject object literal keys to the same kind of checks performed on identifiers? That is probably a different issue though.
The text was updated successfully, but these errors were encountered:
Bug (Suggestion?) Report
4.2.0
2.0.7
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
The following ordering is asserted by the rule:
Expected behavior
For context I have an object literal that I am using as a data store where the keys are CSGO team names. The code above is a sample but the real object is about 100 entries. Storing data in literals like this is not a great idea admittedly but the implication is that the keys can contain pretty much any character (for example capital letters) anywhere in the string.
The actual code sample is the order specified by TSLint. It looks like the rule compares strings by just doing
>
and JavaScript sorts capitals first IIRC which is what is giving the "almost" alphabetical result.Another simpler example would be:
The result is kind of logical but unexpected. If I were going through the code above and sorting my literals I would do it alphabetically and the fact that the rule told me otherwise would be confusing, it almost reduces you to trial and error unless you understand the comparison logic being used.
So my question is
Also thinking now about the iffy sample I've given, would it be good to subject object literal keys to the same kind of checks performed on identifiers? That is probably a different issue though.
The text was updated successfully, but these errors were encountered: