Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed May 10, 2024
1 parent 437a335 commit cdc9d63
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 2 additions & 0 deletions rules/fix/switch-call-expression-to-new-expression.js
@@ -1,8 +1,10 @@
'use strict';
const {isParenthesized} = require('../utils/parentheses.js');
const shouldAddParenthesesToNewExpressionCallee = require('../utils/should-add-parentheses-to-new-expression-callee.js');
const fixSpaceAroundKeyword = require('./fix-space-around-keywords.js');

function * switchCallExpressionToNewExpression(node, sourceCode, fixer) {
yield * fixSpaceAroundKeyword(fixer, node, sourceCode);
yield fixer.insertTextBefore(node, 'new ');

const {callee} = node;
Expand Down
10 changes: 2 additions & 8 deletions rules/throw-new-error.js
@@ -1,8 +1,5 @@
'use strict';
const {
switchCallExpressionToNewExpression,
fixSpaceAroundKeyword,
} = require('./fix/index.js');
const {switchCallExpressionToNewExpression} = require('./fix/index.js');

const messageId = 'throw-new-error';
const messages = {
Expand Down Expand Up @@ -30,10 +27,7 @@ const create = context => ({
return {
node,
messageId,
* fix(fixer) {
yield * fixSpaceAroundKeyword(fixer, node, context.sourceCode);
yield * switchCallExpressionToNewExpression(node, context.sourceCode, fixer);
}
fix: fixer => switchCallExpressionToNewExpression(node, context.sourceCode, fixer),
};
},
});
Expand Down
2 changes: 1 addition & 1 deletion test/snapshots/new-for-builtins.mjs.md
Expand Up @@ -1376,7 +1376,7 @@ Generated by [AVA](https://avajs.dev).
`␊
1 | function foo() {␊
2 | returnnew (globalThis).Map()␊
2 | return new (globalThis).Map()␊
3 | }␊
`

Expand Down
Binary file modified test/snapshots/new-for-builtins.mjs.snap
Binary file not shown.

0 comments on commit cdc9d63

Please sign in to comment.