Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-tautology-expression should check property access expressions #4593

Closed
DerZyklop opened this issue Mar 21, 2019 · 3 comments
Closed

no-tautology-expression should check property access expressions #4593

DerZyklop opened this issue Mar 21, 2019 · 3 comments

Comments

@DerZyklop
Copy link

DerZyklop commented Mar 21, 2019

Rule Suggestion

Is your rule for a general problem or is it specific to your development style?
General problem.

What does your suggested rule do?
Check if there is a duplicate in a if statement.

List several examples where your rule could be used

const foo = true;
if (foo && foo) { // <- Tslint error/warning at second foo
	console.log('Second foo check was unneccessary.');
}

Additional context
Here an example from real code from my project:

if (this.urlParam.start && this.urlParam.start) {
	...
}

Problem was: The code-block should only be executed if a .start and .end was set. I accidentally checked .start and .start. The suggested rule would have prevented that.

@JoshuaKGoldberg
Copy link
Contributor

@DerZyklop agreed! The first foo && foo case should be covered by the new no-tautology-expression rule. As for this.urlParam.start && this.urlParam.start, it looks like it's not yet covered by the rule's test cases, but should be.

@adidahiya adidahiya changed the title Rule suggestion: no-duplicate-statement no-tautology-expression should check property access expressions Mar 22, 2019
@JoshuaKGoldberg
Copy link
Contributor

☠️ TSLint's time has come! ☠️

TSLint is no longer accepting most feature requests per #4534. See typescript-eslint.io for the new, shiny way to lint your TypeScript code with ESLint. ✨

It was a pleasure open sourcing with you all!

@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 (#4534) and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants