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

Rule suggestion: no-constant-binary-expression #1960

Open
LinusU opened this issue Dec 15, 2023 · 0 comments
Open

Rule suggestion: no-constant-binary-expression #1960

LinusU opened this issue Dec 15, 2023 · 0 comments

Comments

@LinusU
Copy link
Member

LinusU commented Dec 15, 2023

I think that this sounds really nice:

https://eslint.org/blog/2022/07/interesting-bugs-caught-by-no-constant-binary-expression/

Ecosystem impact:

  • fastify/fastify:
    • test/internals/reply.test.js:175:
      • reply.serializer((x) => (customSerializerCalled = true) && JSON.stringify(x))
    • test/internals/reply.test.js:184:
      • const context = { [kReplySerializerDefault]: (x) => (customSerializerCalled = true) && JSON.stringify(x) }

The only affected code is the two lines above, where Fastify is using a little trick to do two things on one line. It could be replaced with e.g.

reply.serializer((x) => { customSerializerCalled = true; return JSON.stringify(x) })

or

reply.serializer((x) => {
  customSerializerCalled = true
  return JSON.stringify(x)
})

(ping @mcollina, since your repo is the affected one)

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

No branches or pull requests

1 participant