Code Monkey home page Code Monkey logo

Comments (6)

novemberborn avatar novemberborn commented on May 22, 2024 4

strict-boolean-expressions is now available: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md

from typescript-eslint.

bradzacher avatar bradzacher commented on May 22, 2024 1

flow supports this via their sketchy-null rules.
https://flow.org/en/docs/linting/rule-reference/#toc-sketchy-null

Speaking from experience over my last few months at facebook, it's actually really, really annoying; most engineers I've spoken to hate it!

But if there is demand from the community, it's a rule we could look into.

from typescript-eslint.

j-f1 avatar j-f1 commented on May 22, 2024

We’re interested in doing this in GitHub Desktop: desktop/desktop#3538. I tried to add a rule in desktop/desktop#3550, but the type information available was limited, and @iAmWillShepherd suggested that we try to write this rule with TSLint instead.

from typescript-eslint.

novemberborn avatar novemberborn commented on May 22, 2024

the type information available was limited

I suppose you'd need to use the Language Service API to access accurate type information, especially when you're accessing properties that were defined in a separate file. Not sure how easy it'd be to integrate that into ESLint's lifecycle.

from typescript-eslint.

Coder-256 avatar Coder-256 commented on May 22, 2024

Bump! I would love to see this too. This could be added as an option for the no-implicit-coercion rule's boolean property, because if (x) does an implicit boolean conversion, just the same as !!x.

from typescript-eslint.

SpainTrain avatar SpainTrain commented on May 22, 2024

As a temporary workaround, one can use @typescript-eslint/eslint-plugin-tslint with tslint rule strict-boolean-expressions (https://github.com/palantir/tslint/blob/master/src/rules/strictBooleanExpressionsRule.ts).

I miss this feature from Flow and would love to see this as a rule. Chatter I saw on the TypeScript tracker indicated it is unlikely to be added to the compiler.

from typescript-eslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.