Running ember-modules-codemod
ADD
MODULE_REPORT.md
+## Module Report
+### Unknown Global
+
+**Global**: `Ember.testing`
+
+**Location**: `addon/services/scheduler.js` at line 137
+
+```js
+ this._super(...arguments);
+
+ if (Ember.testing) {
+ this._waiter = () => !this.hasActiveQueue();
+ Ember.Test.registerWaiter(this._waiter);
+```

MODIFY
addon/services/scheduler.js
addon/services/scheduler.js
+import { registerWaiter, unregisterWaiter } from '@ember/test';
+import { run } from '@ember/runloop';
+import RSVP from 'rsvp';
+import Service from '@ember/service';
import Ember from 'ember';
import { DEBUG } from '@glimmer/env';
import TaskQueue from '../task-queue';
-const {
- run,
- RSVP,
- Service,
-} = Ember;
-
const Scheduler = Service.extend({
queueNames: ['afterFirstRoutePaint', 'afterContentPaint'],
@@ -136,7 +134,7 @@ if (DEBUG) {
if (Ember.testing) {
this._waiter = () => !this.hasActiveQueue();
- Ember.Test.registerWaiter(this._waiter);
+ registerWaiter(this._waiter);
}
},
@@ -160,7 +158,7 @@ if (DEBUG) {
willDestroy() {
if (this._waiter) {
- Ember.Test.unregisterWaiter(this._waiter);
+ unregisterWaiter(this._waiter);
this._waiter = null;
}

MODIFY
tests/dummy/app/app.js
tests/dummy/app/app.js
-import Ember from 'ember';
+import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
-const App = Ember.Application.extend({
+const App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver

MODIFY
tests/dummy/app/components/defer-render.js
tests/dummy/app/components/defer-render.js
-import Ember from 'ember';
+import { join } from '@ember/runloop';
+import { inject as service } from '@ember/service';
+import Component from '@ember/component';
-export default Ember.Component.extend({
+export default Component.extend({
shouldRender: false,
- scheduler: Ember.inject.service(),
+ scheduler: service(),
classNames: ['deferred-container'],
init() {
this._super();
this._token = this.get('scheduler').scheduleWork('afterFirstRoutePaint', () => {
- Ember.run.join(() => {
+ join(() => {
this.set('shouldRender', true);
this.isRendered = true;
});

MODIFY
tests/dummy/app/components/right-rail-ad.js
tests/dummy/app/components/right-rail-ad.js
-import Ember from 'ember';
+import { join } from '@ember/runloop';
+import { inject as service } from '@ember/service';
+import Component from '@ember/component';
-export default Ember.Component.extend({
+export default Component.extend({
shouldRender: false,
- scheduler: Ember.inject.service(),
+ scheduler: service(),
classNames: ['ad-container'],
init() {
this._super();
this._token = this.get('scheduler').scheduleWork('afterContentPaint', () => {
- Ember.run.join(() => {
+ join(() => {
this.set('shouldRender', true);
this.isRendered = true;
});

MODIFY
tests/dummy/app/router.js
tests/dummy/app/router.js
-import Ember from 'ember';
+import EmberRouter from '@ember/routing/router';
import config from './config/environment';
-const Router = Ember.Router.extend({
+const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
});

MODIFY
tests/dummy/app/routes/demo.js
tests/dummy/app/routes/demo.js
-import Ember from 'ember';
+import { hash } from 'rsvp';
+import Route from '@ember/routing/route';
-export default Ember.Route.extend({
+export default Route.extend({
model() {
let people = [];
for (let i = 1; i <= 10; i++) {
@@ -16,7 +17,7 @@ export default Ember.Route.extend({
});
}
- return Ember.RSVP.hash({
+ return hash({
people: people,
cats: cats
});

MODIFY
tests/helpers/destroy-app.js
tests/helpers/destroy-app.js
-import Ember from 'ember';
+import { run } from '@ember/runloop';
export default function destroyApp(application) {
- Ember.run(application, 'destroy');
+ run(application, 'destroy');
}

MODIFY
tests/helpers/module-for-acceptance.js
tests/helpers/module-for-acceptance.js
+import { resolve } from 'rsvp';
import { module } from 'qunit';
-import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';
-const { RSVP: { resolve } } = Ember;
-
export default function(name, options = {}) {
module(name, {
beforeEach() {

MODIFY
tests/helpers/start-app.js
tests/helpers/start-app.js
-import Ember from 'ember';
+import { run } from '@ember/runloop';
+import { merge } from '@ember/polyfills';
import Application from '../../app';
import config from '../../config/environment';
export default function startApp(attrs) {
- let attributes = Ember.merge({}, config.APP);
- attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
+ let attributes = merge({}, config.APP);
+ attributes = merge(attributes, attrs); // use defaults, but you can override;
- return Ember.run(() => {
+ return run(() => {
let application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();

MODIFY
tests/unit/initializers/app-scheduler-test.js
tests/unit/initializers/app-scheduler-test.js
-import Ember from 'ember';
+import Application from '@ember/application';
+import { run } from '@ember/runloop';
import { initialize } from 'dummy/initializers/app-scheduler';
import { module, test } from 'qunit';
import destroyApp from '../../helpers/destroy-app';
module('Unit | Initializer | app scheduler', {
beforeEach() {
- Ember.run(() => {
- this.application = Ember.Application.create();
+ run(() => {
+ this.application = Application.create();
this.application.deferReadiness();
});
},

MODIFY
tests/unit/services/scheduler-test.js
tests/unit/services/scheduler-test.js
-import Ember from 'ember';
+import { run } from '@ember/runloop';
+import Evented from '@ember/object/evented';
+import Service from '@ember/service';
import { moduleFor, test } from 'ember-qunit';
-const { run, Evented, Service } = Ember;
const AFTER_CONTENT_PAINT = 'afterContentPaint';
moduleFor('service:scheduler', 'Unit | Service | scheduler', {

Running ember-modules-codemod