Skip to content

Commit

Permalink
Merge pull request #788 from bmish/no-side-effects-test-cleanup
Browse files Browse the repository at this point in the history
Cleanup tests for `no-side-effects` rule
  • Loading branch information
bmish authored Apr 15, 2020
2 parents e9b5069 + 3487b20 commit 9895554
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
8 changes: 5 additions & 3 deletions lib/rules/no-side-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 {
Expand Down
44 changes: 30 additions & 14 deletions tests/lib/rules/no-side-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
const rule = require('../../../lib/rules/no-side-effects');
const RuleTester = require('eslint').RuleTester;

const { ERROR_MESSAGE } = rule;

// ------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand All @@ -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',
},
],
},
Expand Down

0 comments on commit 9895554

Please sign in to comment.