Bug 1463673 - Member expressions should also be allowed as expected arguments to Assert.throws/rejects. r=mossop
authorMark Banner <standard8@mozilla.com>
Wed, 23 May 2018 08:58:19 +0100
changeset 420260 d4bfc66b1fb9080dd06e33d549d255b61e28aa94
parent 420259 4ad07f3127fe38342e73b49f7cf282950b1ae73f
child 420261 015e8f74e97397b46437f5d22d88d783013e65bf
push id64576
push usermbanner@mozilla.com
push dateTue, 29 May 2018 17:46:42 +0000
treeherderautoland@d73afee801c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1463673
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1463673 - Member expressions should also be allowed as expected arguments to Assert.throws/rejects. r=mossop MozReview-Commit-ID: Jhs3TD60bli
tools/lint/eslint/eslint-plugin-mozilla/lib/rules/require-expected-throws-or-rejects.js
tools/lint/eslint/eslint-plugin-mozilla/tests/require-expected-throws-or-rejects.js
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/require-expected-throws-or-rejects.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/require-expected-throws-or-rejects.js
@@ -18,16 +18,17 @@ function checkArgs(context, node, name) 
       }
     });
     return;
   }
 
   if (!("regex" in node.arguments[1]) &&
       node.arguments[1].type !== "FunctionExpression" &&
       node.arguments[1].type !== "ArrowFunctionExpression" &&
+      node.arguments[1].type !== "MemberExpression" &&
       (node.arguments[1].type !== "Identifier" ||
        node.arguments[1].name === "undefined")) {
     context.report({
       node,
       messageId: "requireExpected",
       data: {
         name
       }
--- a/tools/lint/eslint/eslint-plugin-mozilla/tests/require-expected-throws-or-rejects.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/require-expected-throws-or-rejects.js
@@ -24,17 +24,18 @@ ruleTester.run("no-useless-run-test", ru
   valid: [
     "Assert.throws(() => foo(), /assertion/);",
     "Assert.throws(() => foo(), /assertion/, 'message');",
     "Assert.throws(() => foo(), ex => {}, 'message');",
     "Assert.throws(() => foo(), foo, 'message');",
     "Assert.rejects(foo, /assertion/)",
     "Assert.rejects(foo, /assertion/, 'msg')",
     "Assert.rejects(foo, ex => {}, 'msg')",
-    "Assert.rejects(foo, foo, 'msg')"
+    "Assert.rejects(foo, foo, 'msg')",
+    "Assert.rejects(foo, foo.bar, 'msg')"
   ],
   invalid: [
     invalidCode("Assert.throws(() => foo());",
                 "needsTwoArguments", "throws"),
 
     invalidCode("Assert.throws(() => foo(), 'message');",
                 "requireExpected", "throws"),