Feature request: No contradicting checks
- Lingua principale
- Rust
- Stelle
- 22.3k
- Fork
- 1.9k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.