Skip to content

linter: eslint(default-param-last) false positive in typescript with optional param #8556

@drvn-mr

Description

@drvn-mr

What version of Oxlint are you using?

0.15.6

What command did you run?

oxlint -c .oxlintrc.json default-param-last-optional.ts

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

{
  "rules": {
    "default-param-last": "error"
  }
}

What happened?

In Typescript files, optional parameters should be allowed after default ones.

According to #2180 the rule is implemented, however doesn't support the TS only exception.
Not sure if this should be classed as bug report or feature request.
See https://typescript-eslint.io/rules/default-param-last.

Code

function fn(a: string = 'a', b?: string) {
  console.log(a, b);
}

fn('b');

oxlint output

oxlint -c .oxlintrc.json default-param-last-optional.ts

  × eslint(default-param-last): Default parameters should be last
   ╭─[default-param-last-optional.ts:1:13]
 1 │ function fn(a: string = 'a', b?: string) {
   ·             ───────────────
 2 │   console.log(a, b);
   ╰────
  help: Enforce default parameters to be last.

Finished in 4ms on 1 file with 99 rules using 8 threads.
Found 0 warnings and 1 error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linterArea - LinterC-bugCategory - Buggood first issueExperience Level - Good for newcomers

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions