Skip to content

Commit d37cfb8

Browse files
committed
Fix bug with parens
1 parent 66b3635 commit d37cfb8

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/rules/forward-ref-uses-ref.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,12 @@ module.exports = {
7070
{
7171
* fix(fixer) {
7272
const param = node.params[0];
73-
if (
74-
node.type === 'ArrowFunctionExpression'
75-
&& !isParenthesized(context, param)
76-
) {
73+
// If using shorthand arrow function syntax, add parentheses around the new parameter pair
74+
const shouldAddParentheses = node.type === 'ArrowFunctionExpression' && !isParenthesized(context, param);
75+
if (shouldAddParentheses) {
7776
yield fixer.insertTextBefore(param, '(');
78-
yield fixer.insertTextAfter(param, ')');
7977
}
80-
81-
yield fixer.insertTextAfter(param, ', ref');
78+
yield fixer.insertTextAfter(param, `, ref${shouldAddParentheses ? ')' : ''}`);
8279
},
8380
}
8481
),

0 commit comments

Comments
 (0)