Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A failing test for no-deprecated-router-transition-methods (multiple classes) #2072

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions tests/lib/rules/no-deprecated-router-transition-methods.js
Expand Up @@ -873,5 +873,59 @@ import Controller from '@ember/controller';
},
],
},

// Multiple classes in a single file
{
filename: 'routes/index.js',
code: `
import Route from '@ember/routing/route';
import { action } from '@ember/object';

export class SettingsRoute extends Route {
@action
foo() {
this.transitionTo('login');
}
}

export class AnotherRoute extends Route {
@action
foo() {
this.transitionTo('login');
}
}`,
output: `
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import { action } from '@ember/object';

export class SettingsRoute extends Route {
@service('router') router;
@action
foo() {
this.router.transitionTo('login');
}
}

export class AnotherRoute extends Route {
@service('router') router;
@action
foo() {
this.router.transitionTo('login');
}
}`,
errors: [
{
messageId: 'main',
data: { methodUsed: 'transitionTo', desiredMethod: 'transitionTo', moduleType: 'Route' },
type: 'MemberExpression',
},
{
messageId: 'main',
data: { methodUsed: 'transitionTo', desiredMethod: 'transitionTo', moduleType: 'Route' },
type: 'MemberExpression',
},
],
},
],
});
46 changes: 46 additions & 0 deletions tests/lib/rules/no-implicit-injections.js
Expand Up @@ -879,5 +879,51 @@ actions: {
{ messageId: 'main', data: { serviceName: 'flash-messages' }, type: 'MemberExpression' },
],
},

// Multiple classes in a single file
{
filename: 'routes/index.js',
code: `
import Route from '@ember/routing/route';
import { action } from '@ember/object';

export class SettingsRoute extends Route {
@action
foo() {
this.store.find('test');
}
}

export class AnotherRoute extends Route {
@action
foo() {
this.store.find('test');
}
}`,
output: `
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import { action } from '@ember/object';

export class SettingsRoute extends Route {
@service('store') store;
@action
foo() {
this.store.find('test');
}
}

export class AnotherRoute extends Route {
@service('store') store;
@action
foo() {
this.store.find('test');
}
}`,
errors: [
{ messageId: 'main', data: { serviceName: 'store' }, type: 'MemberExpression' },
{ messageId: 'main', data: { serviceName: 'store' }, type: 'MemberExpression' },
],
},
],
});