Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off prefer-arrow-callback by default #31

Closed
ismail-syed opened this issue Oct 16, 2017 · 6 comments
Closed

Turn off prefer-arrow-callback by default #31

ismail-syed opened this issue Oct 16, 2017 · 6 comments

Comments

@ismail-syed
Copy link

ismail-syed commented Oct 16, 2017

馃憢 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?

@lydell
Copy link
Member

lydell commented Oct 16, 2017

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?

@ismail-syed
Copy link
Author

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.

@ismail-syed
Copy link
Author

@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?

@lydell
Copy link
Member

lydell commented Oct 16, 2017

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?

@lydell lydell reopened this Oct 16, 2017
@ismail-syed
Copy link
Author

ismail-syed commented Oct 16, 2017

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.

@lydell
Copy link
Member

lydell commented Jan 26, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants