Skip to content

Commit 09e8f47

Browse files
committed
Prevent line breaks in module() invocation
1 parent 0b51014 commit 09e8f47

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

ember-qunit-codemod.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,35 @@ module.exports = function(file, api, options) {
234234
[j.identifier('hooks')],
235235
j.blockStatement([moduleSetupExpression].filter(Boolean))
236236
);
237-
let moduleInvocation = j.expressionStatement(
238-
j.callExpression(j.identifier('module'), [moduleName, callback])
239-
);
237+
238+
function buildModule(moduleName, callback) {
239+
// using j.callExpression() builds this:
240+
241+
// module(
242+
// 'some loooooooooooong name',
243+
// function(hooks) {
244+
// setupTest(hooks);
245+
// }
246+
// );
247+
248+
// but we want to enforce not having line breaks in the module() invocation
249+
// so we'll have to use a little hack to get this:
250+
251+
// module('some loooooooooooong name', function(hooks) {
252+
// setupTest(hooks);
253+
// });
254+
255+
let node = j(`module('moduleName', function(hooks) {})`)
256+
.find(j.CallExpression)
257+
.paths()[0].node;
258+
259+
node.arguments[0] = moduleName;
260+
node.arguments[1] = callback;
261+
262+
return node;
263+
}
264+
265+
let moduleInvocation = j.expressionStatement(buildModule(moduleName, callback));
240266

241267
if (options) {
242268
let customMethodBeforeEachBody, customMethodBeforeEachExpression;

0 commit comments

Comments
 (0)