Skip to content
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

fix: produce valid code when when fixing properties accessed with square brackets #1131

Merged
merged 6 commits into from
May 29, 2022
Merged
Prev Previous commit
refactor(prefer-todo): reduce code a little
  • Loading branch information
G-Rath committed May 29, 2022
commit 595e570d528147101e683a19870f6c776183001e
11 changes: 6 additions & 5 deletions src/rules/prefer-todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ function createTodoFixer(
fixer: TSESLint.RuleFixer,
) {
if (jestFnCall.members.length) {
return [replaceAccessorFixer(fixer, jestFnCall.members[0], 'todo')];
return replaceAccessorFixer(fixer, jestFnCall.members[0], 'todo');
}

return [
fixer.replaceText(jestFnCall.head.node, `${jestFnCall.head.local}.todo`),
];
return fixer.replaceText(
jestFnCall.head.node,
`${jestFnCall.head.local}.todo`,
);
}

const isTargetedTestCase = (jestFnCall: ParsedJestFnCall): boolean => {
Expand Down Expand Up @@ -85,7 +86,7 @@ export default createRule({
node,
fix: fixer => [
fixer.removeRange([title.range[1], callback.range[1]]),
...createTodoFixer(jestFnCall, fixer),
createTodoFixer(jestFnCall, fixer),
],
});
}
Expand Down