Skip to content

Commit 1a22a40

Browse files
fix eslint issues to fix the tests
1 parent 02a55f4 commit 1a22a40

8 files changed

Lines changed: 39 additions & 37 deletions

File tree

test/run-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const execOpts = { cwd: inputDir, stderr: 'inherit' };
2020
const emberServe = spawn('yarn', ['start'], execOpts);
2121
emberServe.stderr.pipe(process.stderr);
2222

23-
await new Promise(resolve => {
24-
emberServe.stdout.on('data', data => {
23+
await new Promise((resolve) => {
24+
emberServe.stdout.on('data', (data) => {
2525
if (data.toString().includes('Build successful')) {
2626
resolve();
2727
}

transforms/helpers/EOProp.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class EOProp {
8181
if (
8282
kind === 'init' &&
8383
this.hasDecorators &&
84-
this.decorators.find(d => d.importedName === 'computed')
84+
this.decorators.find((d) => d.importedName === 'computed')
8585
) {
8686
kind = 'get';
8787
}
@@ -122,7 +122,7 @@ class EOProp {
122122
}
123123

124124
get decoratorNames() {
125-
return this.decorators.map(d => d.name);
125+
return this.decorators.map((d) => d.name);
126126
}
127127

128128
get classDecoratorName() {
@@ -157,15 +157,15 @@ class EOProp {
157157
}
158158

159159
get hasModifierWithArgs() {
160-
return this.modifiers.some(modifier => modifier.args.length);
160+
return this.modifiers.some((modifier) => modifier.args.length);
161161
}
162162

163163
get hasVolatile() {
164-
return this.modifiers.some(modifier => get(modifier, 'prop.name') === 'volatile');
164+
return this.modifiers.some((modifier) => get(modifier, 'prop.name') === 'volatile');
165165
}
166166

167167
get hasReadOnly() {
168-
return this.modifiers.some(modifier => get(modifier, 'prop.name') === 'readOnly');
168+
return this.modifiers.some((modifier) => get(modifier, 'prop.name') === 'readOnly');
169169
}
170170

171171
get isVolatileReadOnly() {
@@ -205,11 +205,11 @@ class EOProp {
205205
}
206206

207207
get hasMethodDecorator() {
208-
return this.decorators.find(d => d.isMethodDecorator);
208+
return this.decorators.find((d) => d.isMethodDecorator);
209209
}
210210

211211
get hasMetaDecorator() {
212-
return this.decorators.find(d => d.isMetaDecorator);
212+
return this.decorators.find((d) => d.isMetaDecorator);
213213
}
214214
}
215215

transforms/helpers/decorator-helper.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ function createCallExpressionDecorators(j, decoratorName, instanceProp) {
7979
* @returns {Decorator[]}
8080
*/
8181
function createDecoratorsWithArgs(j, identifier, args) {
82-
return [j.decorator(j.callExpression(j.identifier(identifier), args.map(arg => j.literal(arg))))];
82+
return [
83+
j.decorator(
84+
j.callExpression(
85+
j.identifier(identifier),
86+
args.map((arg) => j.literal(arg))
87+
)
88+
),
89+
];
8390
}
8491

8592
/**
@@ -104,7 +111,7 @@ function createIdentifierDecorators(j, identifier = 'action') {
104111
function createBindingDecorators(j, decoratorName, instanceProp) {
105112
const propList = get(instanceProp, 'propList');
106113
if (propList && propList.length) {
107-
const propArgs = propList.map(prop => j.literal(prop));
114+
const propArgs = propList.map((prop) => j.literal(prop));
108115
return [j.decorator(j.callExpression(j.identifier(decoratorName), propArgs))];
109116
}
110117
return [j.decorator(j.identifier(decoratorName))];

transforms/helpers/import-helper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ function createNewImportDeclarations(
143143

144144
// Create new import statements which do not have any matching existing imports
145145
Object.keys(EMBER_DECORATOR_SPECIFIERS)
146-
.filter(path => !decoratorPathsToIgnore.includes(path))
147-
.forEach(path => {
146+
.filter((path) => !decoratorPathsToIgnore.includes(path))
147+
.forEach((path) => {
148148
const specifiers = createEmberDecoratorSpecifiers(
149149
j,
150150
EMBER_DECORATOR_SPECIFIERS[path],
@@ -219,7 +219,7 @@ function getDecoratorPathSpecifiers(j, root, decoratorsToImport = []) {
219219
existingSpecifier
220220
);
221221
} else {
222-
const isSpecifierPresent = decoratedSpecifiers.some(specifier => {
222+
const isSpecifierPresent = decoratedSpecifiers.some((specifier) => {
223223
return (
224224
!get(specifier, 'local.name') &&
225225
get(specifier, 'imported.name') === get(existingSpecifier, 'imported.name')
@@ -291,7 +291,7 @@ function createDecoratorImportDeclarations(j, root, decoratorsToImport = [], opt
291291
const firstDeclaration = getFirstDeclaration(j, root);
292292
const decoratorPathsImported = Object.keys(decoratorPathSpecifierMap);
293293
// Create import statement replacing the existing ones with specifiers importing from ember-decorators namespace
294-
decoratorPathsImported.forEach(decoratorPath => {
294+
decoratorPathsImported.forEach((decoratorPath) => {
295295
const specifiers = decoratorPathSpecifierMap[decoratorPath];
296296
const existingImport = getExistingImportForPath(j, root, decoratorPath);
297297
if (existingImport) {

transforms/helpers/log-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { createLogger, format, transports } = require('winston');
22
const { combine, timestamp, printf } = format;
33

4-
const logFormatter = printf(info => {
4+
const logFormatter = printf((info) => {
55
return `${info.timestamp} [${info.level}] ${info.message}`;
66
});
77

transforms/helpers/parse-helper.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function getEmberObjectProps(j, eoExpression, importedDecoratedProps = {}, runti
2626

2727
return {
2828
instanceProps: objProps.map(
29-
objProp => new EOProp(objProp, runtimeData, importedDecoratedProps)
29+
(objProp) => new EOProp(objProp, runtimeData, importedDecoratedProps)
3030
),
3131
};
3232
}
@@ -65,7 +65,7 @@ function getEmberObjectCallExpressions(j, root) {
6565
return root
6666
.find(j.CallExpression, { callee: { property: { name: 'extend' } } })
6767
.filter(
68-
eoCallExpression =>
68+
(eoCallExpression) =>
6969
startsWithUpperCaseLetter(get(eoCallExpression, 'value.callee.object.name')) &&
7070
get(eoCallExpression, 'parentPath.value.type') !== 'ClassDeclaration'
7171
);
@@ -155,7 +155,7 @@ function parseEmberObjectCallExpression(eoCallExpression) {
155155
eoExpression: null,
156156
mixins: [],
157157
};
158-
callExpressionArgs.forEach(callExpressionArg => {
158+
callExpressionArgs.forEach((callExpressionArg) => {
159159
if (callExpressionArg.type === 'ObjectExpression') {
160160
props.eoExpression = callExpressionArg;
161161
} else {
@@ -197,7 +197,7 @@ function replaceEmberObjectExpressions(j, root, filePath, options = {}) {
197197
let transformed = false;
198198
let decoratorsToImportMap = {};
199199

200-
getEmberObjectCallExpressions(j, root).forEach(eoCallExpression => {
200+
getEmberObjectCallExpressions(j, root).forEach((eoCallExpression) => {
201201
const { eoExpression, mixins } = parseEmberObjectCallExpression(eoCallExpression);
202202

203203
const eoProps = getEmberObjectProps(
@@ -242,7 +242,7 @@ function replaceEmberObjectExpressions(j, root, filePath, options = {}) {
242242
// one object from a file is transformed and other is not
243243
if (transformed) {
244244
const decoratorsToImport = Object.keys(decoratorsToImportMap).filter(
245-
key => decoratorsToImportMap[key]
245+
(key) => decoratorsToImportMap[key]
246246
);
247247
createDecoratorImportDeclarations(j, root, decoratorsToImport, options);
248248
logger.info(`[${filePath}]: SUCCESS`);

transforms/helpers/transform-helper.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function withComments(to, from) {
3333
* @returns {CommentLine[]}
3434
*/
3535
function createLineComments(j, lines = []) {
36-
return lines.map(line => j.commentLine(line));
36+
return lines.map((line) => j.commentLine(line));
3737
}
3838

3939
/**
@@ -46,7 +46,7 @@ function createLineComments(j, lines = []) {
4646
* @returns {ExpressionStatement[]}
4747
*/
4848
function instancePropsToExpressions(j, instanceProps) {
49-
return instanceProps.map(instanceProp =>
49+
return instanceProps.map((instanceProp) =>
5050
withComments(
5151
j.expressionStatement(
5252
j.assignmentExpression(
@@ -93,7 +93,7 @@ function replaceSuperExpressions(j, methodDefinition, functionProp) {
9393
if (!superExprs.length) {
9494
return methodDefinition;
9595
}
96-
superExprs.forEach(superExpr => {
96+
superExprs.forEach((superExpr) => {
9797
if (replaceWithUndefined) {
9898
j(superExpr).replaceWith(j.identifier('undefined'));
9999
} else {
@@ -279,7 +279,7 @@ function createActionDecoratedProps(j, actionsProp) {
279279
const actionProps = get(actionsProp, 'value.properties');
280280
const overriddenActions = get(actionsProp, 'overriddenActions') || [];
281281
const actionDecorators = createIdentifierDecorators(j);
282-
return actionProps.map(actionProp => {
282+
return actionProps.map((actionProp) => {
283283
if (get(actionProp, 'value.type') === 'Identifier') {
284284
return convertIdentifierActionToMethod(j, actionProp, actionDecorators);
285285
} else {
@@ -318,7 +318,7 @@ function createCallExpressionProp(j, callExprProp) {
318318
};
319319
return [createMethodProp(j, functionExpr, createInstancePropDecorators(j, callExprProp))];
320320
} else if (lastArgType === 'ObjectExpression') {
321-
const callExprMethods = callExprLastArg.properties.map(callExprFunction => {
321+
const callExprMethods = callExprLastArg.properties.map((callExprFunction) => {
322322
callExprFunction.isComputed = true;
323323
callExprFunction.kind = getPropName(callExprFunction);
324324
callExprFunction.key = callExprProp.key;
@@ -382,7 +382,7 @@ function createClass(
382382
classDecorators.push(j.decorator(j.identifier('classic')));
383383
}
384384

385-
instanceProps.forEach(prop => {
385+
instanceProps.forEach((prop) => {
386386
if (prop.isClassDecorator) {
387387
classDecorators.push(createClassDecorator(j, prop));
388388
} else if (prop.type === 'FunctionExpression') {
@@ -428,8 +428,8 @@ function createImportDeclaration(j, specifiers, path) {
428428
*/
429429
function createEmberDecoratorSpecifiers(j, pathSpecifiers = [], decoratorsToImport = []) {
430430
return pathSpecifiers
431-
.filter(specifier => decoratorsToImport.includes(specifier))
432-
.map(specifier => {
431+
.filter((specifier) => decoratorsToImport.includes(specifier))
432+
.map((specifier) => {
433433
const importedSpecifier =
434434
specifier === LAYOUT_DECORATOR_LOCAL_NAME ? LAYOUT_DECORATOR_NAME : specifier;
435435
return j.importSpecifier(j.identifier(importedSpecifier), j.identifier(specifier));

transforms/helpers/util/index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const LIFECYCLE_HOOKS = [
154154
* @returns {Any}
155155
*/
156156
function get(obj, path) {
157-
return path.split('.').reduce(function(currentObject, pathSegment) {
157+
return path.split('.').reduce(function (currentObject, pathSegment) {
158158
return typeof currentObject == 'undefined' || currentObject === null
159159
? currentObject
160160
: currentObject[pathSegment];
@@ -168,12 +168,7 @@ function get(obj, path) {
168168
* @param {File} root
169169
*/
170170
function getFirstDeclaration(j, root) {
171-
return j(
172-
root
173-
.find(j.Declaration)
174-
.at(0)
175-
.get()
176-
);
171+
return j(root.find(j.Declaration).at(0).get());
177172
}
178173

179174
/**
@@ -217,7 +212,7 @@ function shouldSetValue(prop) {
217212
return true;
218213
}
219214
return prop.decoratorNames.every(
220-
decoratorName => decoratorName === 'className' || decoratorName === 'attribute'
215+
(decoratorName) => decoratorName === 'className' || decoratorName === 'attribute'
221216
);
222217
}
223218

0 commit comments

Comments
 (0)