Closed KurtPreston closed 1 day ago
I am not sure how we should address this issue.
I first thought we should add an exception in noUndeclaredVariables
. However, very complex cases could be difficult or impossible to handle. Just to give an example:
enum Enum {
X = 0,
Y = ((): X => X)()
}
It seems that it would be better to solve the problem by modifying the semantic model.
However, this will mean adding a binding for every member name, including classes and objects.
This could be useful if we decide to handle private class members in the semantic model.
However, this will create many declarations (class methods, object keys, ...) that we won't need because they will never be bound to references.
Alternatively we could create a new node for literal enum member names JsLiteralEnumMemberName
.
Any opinion?
Environment information
Rule name
lint/correctness/noUndeclaredVariables
Playground link
https://biomejs.dev/playground/?lintRules=all&code=ZQB4AHAAbwByAHQAIABlAG4AdQBtACAAVQBzAGUAcgBBAGMAdABpAG8AbgBUAHkAcABlACAAewAKACAAIABOAG8AbgBlACAAPQAgADAALAAKACAAIABMAGUAZgB0AEMAbABpAGMAawAgAD0AIAAxACwACgAgACAATQBpAGQAZABsAGUAQwBsAGkAYwBrACAAPQAgADIALAAKACAAIABSAGkAZwBoAHQAQwBsAGkAYwBrACAAPQAgADQALAAKACAAIABMAGUAZgB0AEQAcgBhAGcAIAA9ACAAOAAsAAoAIAAgAE0AaQBkAGQAbABlAEQAcgBhAGcAIAA9ACAAMQA2ACwACgAgACAAUgBpAGcAaAB0AEQAcgBhAGcAIAA9ACAAMwAyACwACgAgACAAQQBsAGwAQwBsAGkAYwBrAHMAIAA9ACAATABlAGYAdABDAGwAaQBjAGsAIAB8ACAATQBpAGQAZABsAGUAQwBsAGkAYwBrACAAfAAgAFIAaQBnAGgAdABDAGwAaQBjAGsALAAKACAAIABBAGwAbABEAHIAYQBnAHMAIAA9ACAATABlAGYAdABEAHIAYQBnACAAfAAgAE0AaQBkAGQAbABlAEQAcgBhAGcAIAB8ACAAUgBpAGcAaAB0AEQAcgBhAGcALAAKACAAIABBAGwAbAAgAD0AIABMAGUAZgB0AEMAbABpAGMAawAgAHwAIABNAGkAZABkAGwAZQBDAGwAaQBjAGsAIAB8ACAAUgBpAGcAaAB0AEMAbABpAGMAawAgAHwAIABMAGUAZgB0AEQAcgBhAGcAIAB8ACAATQBpAGQAZABsAGUARAByAGEAZwAgAHwAIABSAGkAZwBoAHQARAByAGEAZwAKAH0A
Expected result
I am declaring a self-referential TypeScript enum like this:
This is considered valid TypeScript syntax, however, Biome reports the errors:
Code of Conduct