diff --git a/tests/lib/rules/no-deprecated-router-transition-methods.js b/tests/lib/rules/no-deprecated-router-transition-methods.js index ff51b524be..286cd8881b 100644 --- a/tests/lib/rules/no-deprecated-router-transition-methods.js +++ b/tests/lib/rules/no-deprecated-router-transition-methods.js @@ -16,6 +16,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', babelOptions: { configFile: require.resolve('../../../.babelrc'), + plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]], }, }, }); @@ -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', + }, + ], + }, ], }); diff --git a/tests/lib/rules/no-implicit-injections.js b/tests/lib/rules/no-implicit-injections.js index bf85d8e3d4..3fdc4d0bfd 100644 --- a/tests/lib/rules/no-implicit-injections.js +++ b/tests/lib/rules/no-implicit-injections.js @@ -16,6 +16,7 @@ const ruleTester = new RuleTester({ sourceType: 'module', babelOptions: { configFile: require.resolve('../../../.babelrc'), + plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]], }, }, }); @@ -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' }], + }, ], });