Skip to content

add a new lint for preferring throw over return ThrowCompletion(...)#692

Open
michaelficarra wants to merge 1 commit intomainfrom
throw-lint
Open

add a new lint for preferring throw over return ThrowCompletion(...)#692
michaelficarra wants to merge 1 commit intomainfrom
throw-lint

Conversation

@michaelficarra
Copy link
Copy Markdown
Member

Disclaimer: I used AI in the process of creating this PR.

);
const baseOffset = step.contents[0].location.start.offset;

walkExpr(expr => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need walkExpr for this; you only really need that when descending recursively into expressions. Here return ThrowCompletion(...) can only appear at the top level (i.e., not within another expression).

Instead you can just walk over stepSeq directly, looking for text nodes ending in return followed by call ThrowCompletion nodes instead of reading the raw source, which is also better because parsed source accounts for <ins> and <del> and etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants