eslint-plugin-proper-ternary icon indicating copy to clipboard operation
eslint-plugin-proper-ternary copied to clipboard

Allow ternary as an arrow function body

Open ckknight opened this issue 6 years ago • 0 comments

I'd like to be able to configure this plugin such that:

Bad:

const arrow = () => {
  return a ? b : c; // error because it's a return statement
};

function fn() {
  return a ? b : c;
}

Good:

const arrow = () => a ? b : c;

const arrowWithReturn = () => {
  if (a) {
    return b;
  } else {
    return c;
  }
};

function fn() {
  if (a) {
    return b;
  } else {
    return c;
  }
}

I can get almost there with the @getify/proper-ternary/where rule, except that I don't want () => a ? b : c to be an error.

ckknight avatar Jun 25 '19 20:06 ckknight