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 Apr 27, 2021. It is now read-only.
I have all the HTTP Status Codes in an Enum. This maces it easier to reference them and also immediately see what this code means.
The Enum Looks like this:
enumHTTPStatusCode{/// <ommited>'Bad Request'=400,Unauthorized=401,'Payment Required'=402,Forbidden=403,'Not Found'=404,'Method Not Allowed'=405,'Not Acceptable'=406,/// <ommited>}
As you see, there are spaces in the Keys.
So if i reference them, it looks like this: HTTPStatusCode['Bad Request']
If i use the same Code to often, i'll get the no-duplicate-string warning
Suggested rule-extension:
"no-duplicate-string": true, // Keep current behaivor"no-duplicate-string": [true, "ignore-keynames"], // Ignore strings which are keynames
The text was updated successfully, but these errors were encountered:
Indeed, when there is typo in such string (enum element) TypeScript compiler will complain (not very explicitly but still). Even refactoring (renaming) will work for such strings (tested in VSCode).
Still in order to introduce this exception to the rule we will need to access type information, to know that object on which string index is accessed is a enum. May be we can simply ignore all strings inside [].
If you ignore everything inside [ ], you will also ignore Array declarations.
But you could check for something = ["Test1", "Test2"] and something["key-name"]
I want to request a feature.
I have all the HTTP Status Codes in an Enum. This maces it easier to reference them and also immediately see what this code means.
The Enum Looks like this:
As you see, there are spaces in the Keys.
So if i reference them, it looks like this:
HTTPStatusCode['Bad Request']
If i use the same Code to often, i'll get the no-duplicate-string warning
Suggested rule-extension:
The text was updated successfully, but these errors were encountered: