8000 Rule suggestion: no-constant-binary-expression · Issue #1960 · standard/standard · GitHub
[go: up one dir, main page]

Skip to content

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

@LinusU

Description

@LinusU

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0