Skip to content

linter: array-callback-return has different from eslint #13075

@xyhxx

Description

@xyhxx

What version of Oxlint are you using?

1.11.2

What command did you run?

No response

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

{"array-callback-return": "error"}

What happened?

When the map contains switch, it behaves differently from eslint.

type ListType = {type: 'two' | 'three', value: number}[];


const list:ListType = [
  {type: 'two', vlaue: 1},
  {type: 'two', vlaue: 2},
  {type: 'three', vlaue: 3},
  {type: 'three', vlaue: 4},
];

const list2 = list.map(function(item) {
  switch(item.type){
    default:
    case "two":
      return item.value * 2;
    case 'three':
      return item.value * 3;
  }
});

console.log(list2);

oxlint
eslint

Maybe we can remove default,it is better than eslint, because we have type: 'two' | 'three'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions