eslint-config-xo-typescript icon indicating copy to clipboard operation
eslint-config-xo-typescript copied to clipboard

Consider enabling `strict-boolean-expressions`?

Open justinhelmer opened this issue 2 years ago • 1 comments

I saw your comment and the corresponding discussion thread about this rule.

Well, it seems like it is ready to go! We get tremendous value by enabling it with the following config:

'@typescript-eslint/strict-boolean-expressions': [
    'error',
    {
      allowString: false,
      allowNumber: false,
      allowNullableObject: false,
    },
  ],

I know you have a TODO comment to reconsider enabling it in 2023 - just want to call out that I think we are there!


OK so here is the bad news: the auto-fixing conflicts with other enabled rules (eqeqeq, no-eq-null). I think all three of those rules are super valuable, and I opened a discussion to hopefully bottom out and align on the triple equals / undefined preference. But that might be a good reason not to enable this rule for now - there is no good way to auto-fix.

FWIW we will still be enabling it in our repository, and then be forced to go manually fix all the places that auto-fix themselves to != null to instead be !== undefined (or !== null where appropriate).

justinhelmer avatar Dec 06 '22 16:12 justinhelmer

I think it's a good idea to enable this rule, but the auto-fix thing is kind of a deal breaker.

sindresorhus avatar Dec 08 '22 19:12 sindresorhus