-
Notifications
You must be signed in to change notification settings - Fork 176
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
Add quick fix for S4322 ('prefer-type-guard') #3052
Conversation
const closingParenthesis = context | ||
.getSourceCode() | ||
.getTokenBefore(functionBody, token => token.value === ')')!; | ||
const openingBracket = context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's brace
.getFirstToken(functionBody, token => token.value === '{')!; | ||
const [, begin] = closingParenthesis.range; | ||
const [end, _] = openingBracket.range; | ||
fix = fixer => fixer.replaceTextRange([begin, end], `: ${predicate} `); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more reliable to use insertTextAfter
to rely only on closing parenthesis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
SonarQube Quality Gate |
Fixes #3024