Repository: ember-cli/eslint-plugin-ember
Pull request #791 (2020-04-15 16:59:12)

Cleanup tests for `require-return-from-computed` rule


Patch:
diff --git a/lib/rules/require-return-from-computed.js b/lib/rules/require-return-from-computed.js
index a968062e..d355d1af 100644
--- a/lib/rules/require-return-from-computed.js
+++ b/lib/rules/require-return-from-computed.js
@@ -10,6 +10,8 @@ function isReachable(segment) {
   return segment.reachable;
 }
 
+const ERROR_MESSAGE = 'Always return a value from computed properties';
+
 module.exports = {
   meta: {
     type: 'problem',
@@ -24,11 +26,11 @@ module.exports = {
     schema: [],
   },
 
-  create(context) {
-    const message = 'Always return a value from computed properties';
+  ERROR_MESSAGE,
 
+  create(context) {
     const report = function (node) {
-      context.report(node, message);
+      context.report(node, ERROR_MESSAGE);
     };
 
     let funcInfo = {


Test patch:
diff --git a/tests/lib/rules/require-return-from-computed.js b/tests/lib/rules/require-return-from-computed.js
index 3765bf38..f48eca29 100644
--- a/tests/lib/rules/require-return-from-computed.js
+++ b/tests/lib/rules/require-return-from-computed.js
@@ -5,6 +5,8 @@
 const rule = require('../../../lib/rules/require-return-from-computed');
 const RuleTester = require('eslint').RuleTester;
 
+const { ERROR_MESSAGE } = rule;
+
 // ------------------------------------------------------------------------------
 // Tests
 // ------------------------------------------------------------------------------
@@ -40,7 +42,8 @@ eslintTester.run('require-return-from-computed', rule, {
       output: null,
       errors: [
         {
-          message: 'Always return a value from computed properties',
+          message: ERROR_MESSAGE,
+          type: 'FunctionExpression',
         },
       ],
     },
@@ -49,7 +52,8 @@ eslintTester.run('require-return-from-computed', rule, {
       output: null,
       errors: [
         {
-          message: 'Always return a value from computed properties',
+          message: ERROR_MESSAGE,
+          type: 'FunctionExpression',
         },
       ],
     },
@@ -58,10 +62,12 @@ eslintTester.run('require-return-from-computed', rule, {
       output: null,
       errors: [
         {
-          message: 'Always return a value from computed properties',
+          message: ERROR_MESSAGE,
+          type: 'FunctionExpression',
         },
         {
-          message: 'Always return a value from computed properties',
+          message: ERROR_MESSAGE,
+          type: 'FunctionExpression',
         },
       ],
     },
@@ -70,7 +76,8 @@ eslintTester.run('require-return-from-computed', rule, {
       output: null,
       errors: [
         {
-          message: 'Always return a value from computed properties',
+          message: ERROR_MESSAGE,
+          type: 'FunctionExpression',
         },
       ],
     },
@@ -79,7 +86,8 @@ eslintTester.run('require-return-from-computed', rule, {
       output: null,
       errors: [
         {
-          message: 'Always return a value from computed properties',
+          message: ERROR_MESSAGE,
+          type: 'FunctionExpression',
         },
       ],
     },