eslint-plugin-unicorn icon indicating copy to clipboard operation
eslint-plugin-unicorn copied to clipboard

prevent-abbreviations: TypeScript type references are not considered by autofixer, interfaces and type aliases not checked

Open felixfbecker opened this issue 4 years ago • 1 comments

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)

felixfbecker avatar Jun 03 '20 08:06 felixfbecker

This one is more important than it might seem given how much traction typescript is gaining.

Shakeskeyboarde avatar Jul 29 '22 16:07 Shakeskeyboarde