Feature request: No contradicting checks
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I reported this already to [eslint-plugin-flow ](https://github.com/gajus/eslint-plugin-flowtype/issues/286), but I started to think that Flow core would be correct home for this feature, especially as it's so similar to what 0.58.0 introduced for switch case statements
Some times, especially when defining flow types afterwards the code gets dirty and unnecessary checks are left in place. For example:
```
function myFunc(num?: number): number {
if (num === undefined) {
return 1;
}
return num;
}
```
let's say we modify the code so that the function parameters are required and checked elsewehere:
```
function myFunc(num: number): number {
if (num === undefined) {
return 1;
}
return num;
}
```
Now we are left with unnecessary check. What we really want is to get rid of the check too:
```
function myFunc(num: number): number {
return num;
}
```
However, the check is easily forgotten there as no linter or Flow nags about it.
Having unnecessary checks makes code more error prone, harder to understand and is against the purpose of static typing. Would be good to have a rule against this.
Contributor guide
Assessment
This issue has not been assessed yet.