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 4a23491 commit 3da4fc4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions rules/throw-new-error.js
@@ -1,5 +1,8 @@
'use strict';
const {switchCallExpressionToNewExpression} = require('./fix/index.js');
const {
switchCallExpressionToNewExpression,
fixSpaceAroundKeyword,
} = require('./fix/index.js');

const messageId = 'throw-new-error';
const messages = {
Expand Down Expand Up @@ -27,7 +30,10 @@ const create = context => ({
return {
node,
messageId,
fix: fixer => switchCallExpressionToNewExpression(node, context.sourceCode, fixer),
* fix(fixer) {
yield * fixSpaceAroundKeyword(fixer, node, context.sourceCode);
yield * switchCallExpressionToNewExpression(node, context.sourceCode, fixer);
}

Check failure on line 36 in rules/throw-new-error.js

View workflow job for this annotation

GitHub Actions / lint-test (ubuntu-latest)

Missing trailing comma.
};
},
});
Expand Down
2 changes: 1 addition & 1 deletion test/snapshots/throw-new-error.mjs.md
Expand Up @@ -549,7 +549,7 @@ Generated by [AVA](https://avajs.dev).
`␊
1 | function foo() {␊
2 | new returnnew [globalThis][0].Error('message');␊
2 | return new [globalThis][0].Error('message');␊
3 | }␊
`

Expand Down
Binary file modified test/snapshots/throw-new-error.mjs.snap
Binary file not shown.

0 comments on commit 3da4fc4

Please sign in to comment.