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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint --fix does not work properly when used with prefer-arrow-callback #74

Closed
pauloborges opened this issue Jan 4, 2018 · 1 comment

Comments

@pauloborges
Copy link

What version of eslint are you using?

4.14.0.

What version of prettier are you using?

1.9.2.

What version of eslint-plugin-prettier are you using?

2.4.0.

Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files)

.eslintrc.yaml:

extends:
  - plugin:prettier/recommended

parserOptions:
  ecmaVersion: 6

rules:
  prefer-arrow-callback: "error"

What source code are you linting?

function func(arg) {
  return Array.isArray(arg.param) && foo.bar.filter(function(baz) {
    return baz.code === 42;
  }).length > 0;
}

What did you expect to happen?

When applying eslint --fix I would expect it to generate valid code.

What actually happened?

It generates invalid code:

function func(arg) {
  return (
    Array.isArray(arg.param) &&
    foo.bar.filter((baz) => {
    return baz.code === 42;
  }).length > 0;
}

I managed to create this minimal reproducible environment, which can be found here.

When I run eslint --fix index.js, it generates invalid code. But if I remove the plugin from the ESLint configuration, run eslint --fix index.js and then run prettier --write index.js it will generate the expected output.

@pauloborges
Copy link
Author

Whoops, I just saw #65 which is the same issue. I'll close this one.

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

1 participant