Comments (6)
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.
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.
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.
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.
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.
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)
- Enhancement: [no-explicit-any] value-level only HOT 5
- Docs: no-misused-promises example for "if promise exists" HOT 3
- Bug: [consistent-indexed-object-style] shouldn't suggest `Record` when extending an another type HOT 6
- Docs: broken anchor links in "This rule accepts the following options, and has more strict settings in the strict and strict-type-checked configs." HOT 1
- Base rule extension: [accessor-pairs] HOT 5
- Docs: Better Callouts for `all` / `strict` / `strict-type-checked` Config Stability
- Docs: Consider explicitly mentioning rule report properties as not covered by semver HOT 1
- Enhancement: [no-unnecessary-condition] Check truthiness assertion functions
- Configs: Apply changes to config presets for v8
- Enhancement: [prefer-nullish-coalescing] should ignore Boolean constructor HOT 4
- Repo: Use ESLint v9 for our internal linting HOT 3
- feat(eslint-plugin): remove deprecated no-throw-literal rule
- Docs: Updated typed linting docs for new project service
- Bug: incorrect peer dependencies in v8.0.0-alpha.10 packages HOT 6
- Parser: remove EXPERIMENTAL_useSourceOfProjectReferenceRedirect in favor of project service? HOT 1
- Repo: publishing v8 canary versions failed - "Not Found - PUT https://registry.npmjs.org/@typescript-eslint/types - Not found" HOT 2
- Bug: Broken examples? HOT 1
- Docs: Quickstart guide should be clear on type: module not being a requirement HOT 6
- Repo: Failing to publish new alpha versions of v8 post-v8.0.0-alpha.10 HOT 2
- Bug: [v8.0.0-alpha.10] incorrect error message `Parsing error: "parserOptions.programs"` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-eslint.