Skip to content

Commit fad408a

Browse files
authored
Merge pull request #791 from bmish/require-return-from-computed-test-cleanup
Cleanup tests for `require-return-from-computed` rule
2 parents 51114c7 + e853f23 commit fad408a

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

lib/rules/require-return-from-computed.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ function isReachable(segment) {
1010
return segment.reachable;
1111
}
1212

13+
const ERROR_MESSAGE = 'Always return a value from computed properties';
14+
1315
module.exports = {
1416
meta: {
1517
type: 'problem',
@@ -24,11 +26,11 @@ module.exports = {
2426
schema: [],
2527
},
2628

27-
create(context) {
28-
const message = 'Always return a value from computed properties';
29+
ERROR_MESSAGE,
2930

31+
create(context) {
3032
const report = function (node) {
31-
context.report(node, message);
33+
context.report(node, ERROR_MESSAGE);
3234
};
3335

3436
let funcInfo = {

tests/lib/rules/require-return-from-computed.js

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

8+
const { ERROR_MESSAGE } = rule;
9+
810
// ------------------------------------------------------------------------------
911
// Tests
1012
// ------------------------------------------------------------------------------
@@ -40,7 +42,8 @@ eslintTester.run('require-return-from-computed', rule, {
4042
output: null,
4143
errors: [
4244
{
43-
message: 'Always return a value from computed properties',
45+
message: ERROR_MESSAGE,
46+
type: 'FunctionExpression',
4447
},
4548
],
4649
},
@@ -49,7 +52,8 @@ eslintTester.run('require-return-from-computed', rule, {
4952
output: null,
5053
errors: [
5154
{
52-
message: 'Always return a value from computed properties',
55+
message: ERROR_MESSAGE,
56+
type: 'FunctionExpression',
5357
},
5458
],
5559
},
@@ -58,10 +62,12 @@ eslintTester.run('require-return-from-computed', rule, {
5862
output: null,
5963
errors: [
6064
{
61-
message: 'Always return a value from computed properties',
65+
message: ERROR_MESSAGE,
66+
type: 'FunctionExpression',
6267
},
6368
{
64-
message: 'Always return a value from computed properties',
69+
message: ERROR_MESSAGE,
70+
type: 'FunctionExpression',
6571
},
6672
],
6773
},
@@ -70,7 +76,8 @@ eslintTester.run('require-return-from-computed', rule, {
7076
output: null,
7177
errors: [
7278
{
73-
message: 'Always return a value from computed properties',
79+
message: ERROR_MESSAGE,
80+
type: 'FunctionExpression',
7481
},
7582
],
7683
},
@@ -79,7 +86,8 @@ eslintTester.run('require-return-from-computed', rule, {
7986
output: null,
8087
errors: [
8188
{
82-
message: 'Always return a value from computed properties',
89+
message: ERROR_MESSAGE,
90+
type: 'FunctionExpression',
8391
},
8492
],
8593
},

0 commit comments

Comments
 (0)