prettier/eslint-config-prettier

Turn off prefer-arrow-callback by default

ismail-syed opened this issue ยท 6 comments

๐Ÿ‘‹ Would it be appropriate to add prefer-arrow-callback to the list of conflicting rules to be turned off?

I had issues with this rule conflicting with our eslint config (which extends this prettier config). Turning off prefer-arrow-callback solved our issues.

Can I submit a PR?

I use prefer-arrow-callback together with Prettier every day without issues. What problem are you facing? Are you sure that there's no other tool or rule that causes your trouble?

Thanks for the fast reply! Still investigating a bit more, but I believe you're right. I'll keep digging and report back if anything comes up.

@lydell I have a reproducible issue here: https://github.com/ismail-syed/prettier-eslint-config-invalid-code

Could this be the result of perfer-arrow-callback's fix and prettier conflicting with eachother in the specific cases listed in issue1.js and issue2.js?

Thanks!

I managed to reduce the test cases.

.eslintrc.js:

module.exports = {
  env: {es6: true},
  plugins: ["prettier"],
  rules: {
    "prettier/prettier": "error",
    "prefer-arrow-callback": "error",
  }
}

issue1.js:

(
  f(function() {
    return
  })
) ||
1;

issue2.js:

function f() {
  return 1 && g(function() {
    return
  });
}

A strange thing is that if I comment out "prettier/prettier": "error", and run either of these commands:

eslint foo.js --fix && prettier --write foo.js
prettier --write foo.js && eslint foo.js --fix

... the error does not happen. Neither does it if I:

  1. Comment out one of the rules.
  2. eslint --fix foo.js
  3. Uncomment the rule, comment out the other rule.
  4. eslint --fix foo.js

So it seems to only happen when having both rules enabled and fixed at the same time.

You have found a bug somewhere! The solution is not to add prefer-arrow-callback to eslint-config-prettier, but to fix the bug.

@not-an-aardvark Do you have any idea what could be going on?

Yay!

I went ahead and created an issue in eslint-plugin-prettier: prettier/eslint-plugin-prettier#65 as well.

I think the underlying bug exists in eslint-plugin-prettier's fix or prefer-arrow-callback's fix, it would be more appropriate to have issue(s) logged there.

prefer-arrow-callback (and arrow-body-style) are now disabled by default in v4.0.0. See the docs for more information.