eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
prevent-abbreviations: TypeScript type references are not considered by autofixer, interfaces and type aliases not checked
enum Btn {
Hello = 123,
}
const test1 = Btn.Hello
let test2: Btn.Hello
Gets autofixed to:
enum Button {
Hello = 123,
}
const test1 = Button.Hello
let test2: Btn.Hello
function test3(testParameter: Btn): Btn {
return Button.Hello
}
Note how the value positions are fixed, but the type positions are not.
Same with classes:
class Btn {}
const test1 = new Btn()
let test2: Btn
function test3(testParameter: Btn): Btn {
return new Btn()
}
fixed:
class Button {}
const test1 = new Button()
let test2: Btn
function test3(testParameter: Btn): Btn {
return new Button()
}
Interfaces and type aliases do not get flagged at all:
interface Btn {}
type Btn2 = {}
(no error)
This one is more important than it might seem given how much traction typescript is gaining.