0

I'm having a little problem here.

I'm using eslint, and it's making my code broke. Here's some example

const { a, b } = bar()

foo() // return type: void

({a, b} =  bar())

If the code stay in this way, it will work as I want, but the eslint is changing the code to the example below and It's breaking

const { a, b } = bar()

foo()(
  ({a, b} =  bar())
)

There's some rule to stop eslint from doing this?

EDIT

The example is a little confusing, here is the code I'm trying to run

let { getByTestId, getByLabelText, getByText } = render(<TechList />)

fireEvent.change(getByLabelText('Tech'), { target: { value: 'NodeJS' } })
fireEvent.submit(getByTestId('tech-form'))

cleanup()
({ getByTestId, getByLabelText, getByText } = render(<TechList />))

And now I don't know if It's prettier or eslint making this change.. I'm using VS Code with the ESlint and Prettier extensions, and the editor is formating the code on save

let { getByTestId, getByLabelText, getByText } = render(<TechList />)

fireEvent.change(getByLabelText('Tech'), { target: { value: 'NodeJS' } })
fireEvent.submit(getByTestId('tech-form'))

cleanup()(
  ({ getByTestId, getByLabelText, getByText } = render(<TechList />))
)
Ricardo Mendes
  • 329
  • 1
  • 5
  • 13
  • 1
    I doubt it works when you run it. What you have written *is* a function call. Use semicolons! – Bergi Sep 19 '19 at 23:37
  • 1
    It’s confusing what your intention is… `foo` returns `undefined`, right? Why are you trying to call it then ([which is what happens here](https://stackoverflow.com/q/31013221/4642212))? Or are you trying to assign `a` and `b`? They are `const`s; you can’t do that. Your code wouldn’t work either way; it’s already broken. – Sebastian Simon Sep 19 '19 at 23:38
  • http://inimino.org/~inimino/blog/javascript_semicolons – Bergi Sep 19 '19 at 23:39
  • I'm not trying to call foo, I want to reassing `a` and `b` with the response of `bar` – Ricardo Mendes Sep 19 '19 at 23:41
  • @RicardoMendes Then clearly separate your statements with a semicolon! – Bergi Sep 19 '19 at 23:47
  • Oops, I saw now that I used `const`, it should be `let`, sorry guys – Ricardo Mendes Sep 19 '19 at 23:50

0 Answers0