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 (legacy class, decorators) #2073

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/lib/rules/no-deprecated-router-transition-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ruleTester = new RuleTester({
sourceType: 'module',
babelOptions: {
configFile: require.resolve('../../../.babelrc'),
plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
},
},
});
Expand Down Expand Up @@ -873,5 +874,39 @@ import Controller from '@ember/controller';
},
],
},

// Legacy .extend Route with decorators
{
filename: 'routes/index.js',
code: `
import Route from '@ember/routing/route';
import { action } from '@ember/object';

export default Route.extend({
@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 default Route.extend({
router: service('router'),
@action
foo() {
this.router.transitionTo('login');
}
});`,
errors: [
{
messageId: 'main',
data: { methodUsed: 'transitionTo', desiredMethod: 'transitionTo', moduleType: 'Route' },
type: 'MemberExpression',
},
],
},
],
});
29 changes: 29 additions & 0 deletions tests/lib/rules/no-implicit-injections.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ruleTester = new RuleTester({
sourceType: 'module',
babelOptions: {
configFile: require.resolve('../../../.babelrc'),
plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
},
},
});
Expand Down Expand Up @@ -879,5 +880,33 @@ actions: {
{ messageId: 'main', data: { serviceName: 'flash-messages' }, type: 'MemberExpression' },
],
},

// Legacy .extend class with decorators
{
filename: 'routes/index.js',
code: `
import Route from '@ember/routing/route';
import { action } from '@ember/object';

export default Route.extend({
@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 default Route.extend({
store: service('store'),
@action
foo() {
this.store.find('test');
}
});`,
errors: [{ messageId: 'main', data: { serviceName: 'store' }, type: 'MemberExpression' }],
},
],
});