Skip to content

linter: typescript/prefer-function-type not match some case #11668

Closed
@CoffeeChaton

Description

@CoffeeChaton

What version of Oxlint are you using?

1.1.0

What command did you run?

oxlint

What does your .oxlintrc.json config file look like?

{
    "$schema": "./node_modules/oxlint/configuration_schema.json",
    "ignorePatterns": [
        "node_modules"
    ],
    "rules": {
        // https://oxc.rs/docs/guide/usage/linter/rules/typescript/prefer-function-type.html#typescript-prefer-function-type
        "typescript/prefer-function-type": "error"
    }
}

What happened?

export class CC {
    public foo() {
        //
    }
}

export function FN<T extends CC>(resultClass: { new(): T }): T {
    //                                        ^^^^^^^^^^^^
    //   8:49  error  Type literal only has a call signature, you should use a function type instead  @typescript-eslint/prefer-function-type

    // eslint is match   // https://typescript-eslint.io/rules/prefer-function-type/
    // oxlint not match // https://oxc.rs/docs/guide/usage/linter/rules/typescript/prefer-function-type.html#typescript-prefer-function-type
    return new resultClass();
}

typescript-eslint can find it, and auto-fix
oxlint not find it , and eslint-plugin-oxlint disabled typescript-eslint diagnostics.

https://github.com/CoffeeChaton/oxlint--typescript--prefer-function-type

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions