-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): [no-confusing-void-expression] add an option to ignore void<->void #10067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JoshuaKGoldberg
merged 28 commits into
typescript-eslint:main
from
ronami:ignore-void-void
Nov 4, 2024
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
27126ca
initial implementation
ronami 98830b9
enable rule
ronami 3830a24
improvements and fixes
ronami 5b9655d
use checker.getContextualType over getContextualType
ronami e47395e
more fixes
ronami 4d0bf7c
improve implementation
ronami 117d244
add docs
ronami b4be799
update snapshots
ronami 1c49780
enable rule with option
ronami 5dc7600
rename function names to be a bit less confusing
ronami 2c26323
reword game-plan
ronami 6800dba
move rule def to be under its proper title
ronami 5f7833f
remove invalid tests
ronami 37201b8
add more tests
ronami 5e235c8
add more tests
ronami a8ca492
add more tests
ronami 60dc04c
refactor tests
ronami 3b66043
refactor tests
ronami b788954
wording
ronami d735247
merge conflicts
ronami c5f5e12
Update packages/eslint-plugin/docs/rules/no-confusing-void-expression…
ronami b61ab1f
Update packages/eslint-plugin/docs/rules/no-confusing-void-expression…
ronami af9bf87
Update packages/eslint-plugin/src/rules/no-confusing-void-expression.ts
ronami 7ac4a37
format
ronami dcbb392
format
ronami 1a52c22
add missing test
ronami f190b15
remove code to handle multiple call signatures
ronami 8b85c14
figure out the case of multiple call signatures in a function expression
ronami File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Praise] I like the reuse here 🙂 nice. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { TSESTree } from '@typescript-eslint/utils'; | ||
|
||
import { AST_NODE_TYPES } from '@typescript-eslint/utils'; | ||
|
||
export function getParentFunctionNode( | ||
node: TSESTree.Node, | ||
): | ||
| TSESTree.ArrowFunctionExpression | ||
| TSESTree.FunctionDeclaration | ||
| TSESTree.FunctionExpression | ||
| null { | ||
let current = node.parent; | ||
while (current) { | ||
if ( | ||
current.type === AST_NODE_TYPES.ArrowFunctionExpression || | ||
current.type === AST_NODE_TYPES.FunctionDeclaration || | ||
current.type === AST_NODE_TYPES.FunctionExpression | ||
) { | ||
return current; | ||
} | ||
|
||
current = current.parent; | ||
} | ||
|
||
// this shouldn't happen in correct code, but someone may attempt to parse bad code | ||
// the parser won't error, so we shouldn't throw here | ||
/* istanbul ignore next */ return null; | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/eslint-plugin/tests/docs-eslint-output-snapshots/no-confusing-void-expression.shot
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.