question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add autofix to `no-negated-condition`

See original GitHub issue

Sorry for ignoring the template but nothing applied as this doesn’t actually change the behavior.

Can no-negated-condition be autofixable? It seems “relatively easy” to swap the blocks:

if (!foo) {
	alert('❌')
} else {
	alert('✅')
}
if (foo) {
	alert('✅')
} else {
	alert('❌')
}

Keywords: autofixed auto fix fixed fixable

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
bmishcommented, Jul 15, 2021

I’d support a suggestion for this. Perhaps suggestions should be exempt from the stylistic rule freeze:

  • Suggestions are a relatively new feature so there are still many existing rules that could benefit from having them added
  • All new code for a suggestion is typically confined to the suggestion function and not the rule’s primary code path
  • The only behavior change for a suggestion occurs when a user explicitly chooses to accept a suggestion
2reactions
mdjermanoviccommented, Jul 14, 2021

I think it makes sense to provide this fix as a suggestion, but given that stylistic rules are frozen, I’m not in favor of adding any new features to no-negated-condition since it is a stylistic rule.

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-negated-condition - Pluggable JavaScript Linter - ESLint
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
ESLint v1.6.0 released - ESLint中文文档
ESLint v1.6.0 introduces several more autofixing rules to use with the --fix command line ... New: no-negated-condition rule (fixes #3740) (alberto) ...
Read more >
tslint-eslint-rules - npm Package Health Analysis | Snyk
{ "extends": [ "tslint-eslint-rules" ], "rules": { "no-constant-condition": true } }. You can also extend other tslint config packages to combine this ...
Read more >
Basic Usage — Credo v1.6.7 - HexDocs
Refactoring opportunities ┃ ┃ [F] ↗ Avoid negated conditions in ... To find out more about the issue, just append its location to...
Read more >
Ask Question - Stack Overflow
Well according to this page, this rule is discouraged as modern TypeScript does not use it and is slow to compute.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found