Skip to content

Commit 3487b20

Browse files
committed
test: cleanup tests for no-side-effects rule
1 parent e9b5069 commit 3487b20

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

lib/rules/no-side-effects.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function isUnallowedMethod(name) {
1111
return ['set', 'setProperties'].includes(name);
1212
}
1313

14+
const ERROR_MESSAGE = "Don't introduce side-effects in computed properties";
15+
1416
module.exports = {
1517
meta: {
1618
type: 'problem',
@@ -25,13 +27,13 @@ module.exports = {
2527
schema: [],
2628
},
2729

30+
ERROR_MESSAGE,
31+
2832
create(context) {
2933
let emberImportAliasName;
3034

31-
const message = "Don't introduce side-effects in computed properties";
32-
3335
const report = function (node) {
34-
context.report(node, message);
36+
context.report(node, ERROR_MESSAGE);
3537
};
3638

3739
return {

tests/lib/rules/no-side-effects.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
const rule = require('../../../lib/rules/no-side-effects');
66
const RuleTester = require('eslint').RuleTester;
77

8+
const { ERROR_MESSAGE } = rule;
9+
810
// ------------------------------------------------------------------------------
911
// Tests
1012
// ------------------------------------------------------------------------------
@@ -30,7 +32,8 @@ eslintTester.run('no-side-effects', rule, {
3032
output: null,
3133
errors: [
3234
{
33-
message: "Don't introduce side-effects in computed properties",
35+
message: ERROR_MESSAGE,
36+
type: 'CallExpression',
3437
},
3538
],
3639
},
@@ -40,7 +43,8 @@ eslintTester.run('no-side-effects', rule, {
4043
output: null,
4144
errors: [
4245
{
43-
message: "Don't introduce side-effects in computed properties",
46+
message: ERROR_MESSAGE,
47+
type: 'CallExpression',
4448
},
4549
],
4650
},
@@ -50,7 +54,8 @@ eslintTester.run('no-side-effects', rule, {
5054
output: null,
5155
errors: [
5256
{
53-
message: "Don't introduce side-effects in computed properties",
57+
message: ERROR_MESSAGE,
58+
type: 'CallExpression',
5459
},
5560
],
5661
},
@@ -60,7 +65,8 @@ eslintTester.run('no-side-effects', rule, {
6065
output: null,
6166
errors: [
6267
{
63-
message: "Don't introduce side-effects in computed properties",
68+
message: ERROR_MESSAGE,
69+
type: 'CallExpression',
6470
},
6571
],
6672
},
@@ -70,7 +76,8 @@ eslintTester.run('no-side-effects', rule, {
7076
output: null,
7177
errors: [
7278
{
73-
message: "Don't introduce side-effects in computed properties",
79+
message: ERROR_MESSAGE,
80+
type: 'CallExpression',
7481
},
7582
],
7683
},
@@ -80,7 +87,8 @@ eslintTester.run('no-side-effects', rule, {
8087
output: null,
8188
errors: [
8289
{
83-
message: "Don't introduce side-effects in computed properties",
90+
message: ERROR_MESSAGE,
91+
type: 'CallExpression',
8492
},
8593
],
8694
},
@@ -90,7 +98,8 @@ eslintTester.run('no-side-effects', rule, {
9098
output: null,
9199
errors: [
92100
{
93-
message: "Don't introduce side-effects in computed properties",
101+
message: ERROR_MESSAGE,
102+
type: 'CallExpression',
94103
},
95104
],
96105
},
@@ -100,7 +109,8 @@ eslintTester.run('no-side-effects', rule, {
100109
output: null,
101110
errors: [
102111
{
103-
message: "Don't introduce side-effects in computed properties",
112+
message: ERROR_MESSAGE,
113+
type: 'CallExpression',
104114
},
105115
],
106116
},
@@ -110,7 +120,8 @@ eslintTester.run('no-side-effects', rule, {
110120
output: null,
111121
errors: [
112122
{
113-
message: "Don't introduce side-effects in computed properties",
123+
message: ERROR_MESSAGE,
124+
type: 'CallExpression',
114125
},
115126
],
116127
},
@@ -120,7 +131,8 @@ eslintTester.run('no-side-effects', rule, {
120131
output: null,
121132
errors: [
122133
{
123-
message: "Don't introduce side-effects in computed properties",
134+
message: ERROR_MESSAGE,
135+
type: 'CallExpression',
124136
},
125137
],
126138
},
@@ -130,7 +142,8 @@ eslintTester.run('no-side-effects', rule, {
130142
output: null,
131143
errors: [
132144
{
133-
message: "Don't introduce side-effects in computed properties",
145+
message: ERROR_MESSAGE,
146+
type: 'CallExpression',
134147
},
135148
],
136149
},
@@ -140,7 +153,8 @@ eslintTester.run('no-side-effects', rule, {
140153
output: null,
141154
errors: [
142155
{
143-
message: "Don't introduce side-effects in computed properties",
156+
message: ERROR_MESSAGE,
157+
type: 'CallExpression',
144158
},
145159
],
146160
},
@@ -150,7 +164,8 @@ eslintTester.run('no-side-effects', rule, {
150164
output: null,
151165
errors: [
152166
{
153-
message: "Don't introduce side-effects in computed properties",
167+
message: ERROR_MESSAGE,
168+
type: 'CallExpression',
154169
},
155170
],
156171
},
@@ -160,7 +175,8 @@ eslintTester.run('no-side-effects', rule, {
160175
output: null,
161176
errors: [
162177
{
163-
message: "Don't introduce side-effects in computed properties",
178+
message: ERROR_MESSAGE,
179+
type: 'CallExpression',
164180
},
165181
],
166182
},

0 commit comments

Comments
 (0)