Repository: ember-cli/eslint-plugin-ember
Pull request #788 (2020-04-15 16:07:17)

Cleanup tests for `no-side-effects` rule


Patch:
diff --git a/lib/rules/no-side-effects.js b/lib/rules/no-side-effects.js
index 9113035e..70dad3ea 100644
--- a/lib/rules/no-side-effects.js
+++ b/lib/rules/no-side-effects.js
@@ -11,6 +11,8 @@ function isUnallowedMethod(name) {
   return ['set', 'setProperties'].includes(name);
 }
 
+const ERROR_MESSAGE = "Don't introduce side-effects in computed properties";
+
 module.exports = {
   meta: {
     type: 'problem',
@@ -25,13 +27,13 @@ module.exports = {
     schema: [],
   },
 
+  ERROR_MESSAGE,
+
   create(context) {
     let emberImportAliasName;
 
-    const message = "Don't introduce side-effects in computed properties";
-
     const report = function (node) {
-      context.report(node, message);
+      context.report(node, ERROR_MESSAGE);
     };
 
     return {


Test patch:
diff --git a/tests/lib/rules/no-side-effects.js b/tests/lib/rules/no-side-effects.js
index f7d2f2a4..651ff8b7 100644
--- a/tests/lib/rules/no-side-effects.js
+++ b/tests/lib/rules/no-side-effects.js
@@ -5,6 +5,8 @@
 const rule = require('../../../lib/rules/no-side-effects');
 const RuleTester = require('eslint').RuleTester;
 
+const { ERROR_MESSAGE } = rule;
+
 // ------------------------------------------------------------------------------
 // Tests
 // ------------------------------------------------------------------------------
@@ -30,7 +32,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -40,7 +43,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -50,7 +54,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -60,7 +65,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -70,7 +76,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -80,7 +87,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -90,7 +98,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -100,7 +109,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -110,7 +120,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -120,7 +131,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -130,7 +142,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -140,7 +153,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -150,7 +164,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },
@@ -160,7 +175,8 @@ eslintTester.run('no-side-effects', rule, {
       output: null,
       errors: [
         {
-          message: "Don't introduce side-effects in computed properties",
+          message: ERROR_MESSAGE,
+          type: 'CallExpression',
         },
       ],
     },