Repository: eslint/eslint (js)

Issue:
Make `no-cond-assign` work for ternaries too
**What rule do you want to change?**

`no-cond-assign`

**Does this change cause the rule to produce more or fewer warnings?**

More warnings

**How will the change be implemented? (New option, new default behavior, etc.)?**

I guess new default?

**Please provide some example code that this change will affect:**

<!-- Put your code examples here -->
```js
  const str = (x = 0) ? 'zero' : 'non-zero'
```

**What does the rule currently do for this code?**

No warnings are produced

**What will the rule do after it's changed?**

Produce an "Unexpected assignment" warning for the condition of the ternary

Pull request:
Update: Make no-cond-assign work for ternaries (fixes #10091)
<!--
    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).
-->

**What is the purpose of this pull request? (put an "X" next to item)**

[ ] Documentation update
[ ] Bug fix ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/bug-report.md))
[ ] New rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-proposal.md))
[X] Changes an existing rule ([template](https://raw.githubusercontent.com/eslint/eslint/master/templates/rule-change-proposal.md))
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Addresses issue https://github.com/eslint/eslint/issues/10091


**What changes did you make? (Give an overview)**
Made the `no-cond-assign` rule also check for ternaries.



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14e9227ee..00194b043 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+v4.19.1 - March 21, 2018
+
+* 3ff5d11 Fix: no-invalid-regexp not understand variable for flags (fixes #10112) (#10113) (薛定谔的猫)
+* abc765c Fix: object-curly-newline minProperties w/default export (fixes #10101) (#10103) (Kevin Partington)
+* 6f9e155 Docs: Update ambiguous for...in example for guard-for-in (#10114) (CJ R)
+* 0360cc2 Chore: Adding debug logs on successful plugin loads (#10100) (Kevin Partington)
+* a717c5d Chore: Adding log at beginning of unit tests in Makefile.js (#10102) (Kevin Partington)
+
 v4.19.0 - March 16, 2018
 
 * 55a1593 Update: consecutive option for one-var (fixes #4680) (#9994) (薛定谔的猫)
diff --git a/lib/rules/no-cond-assign.js b/lib/rules/no-cond-assign.js
index f949bcc88..4c7b5722d 100644
--- a/lib/rules/no-cond-assign.js
+++ b/lib/rules/no-cond-assign.js
@@ -139,7 +139,8 @@ module.exports = {
             DoWhileStatement: testForAssign,
             ForStatement: testForAssign,
             IfStatement: testForAssign,
-            WhileStatement: testForAssign
+            WhileStatement: testForAssign,
+            ConditionalExpression: testForAssign
         };
 
     }
diff --git a/lib/rules/no-invalid-regexp.js b/lib/rules/no-invalid-regexp.js
index e57029c9f..7169e0ca7 100644
--- a/lib/rules/no-invalid-regexp.js
+++ b/lib/rules/no-invalid-regexp.js
@@ -98,20 +98,17 @@ module.exports = {
                     return;
                 }
                 const pattern = node.arguments[0].value;
-                let flags = "";
+                let flags = isString(node.arguments[1]) ? node.arguments[1].value : "";
 
-                if (node.arguments[1]) {
-                    flags = isString(node.arguments[1]) ? node.arguments[1].value : null;
-                    if (allowedFlags) {
-                        flags = flags.replace(allowedFlags, "");
-                    }
+                if (allowedFlags) {
+                    flags = flags.replace(allowedFlags, "");
                 }
 
                 // If flags are unknown, check both are errored or not.
                 const message = validateRegExpFlags(flags) || (
-                    (flags === null)
-                        ? validateRegExpPattern(pattern, true) && validateRegExpPattern(pattern, false)
-                        : validateRegExpPattern(pattern, flags.indexOf("u") !== -1)
+                    flags
+                        ? validateRegExpPattern(pattern, flags.indexOf("u") !== -1)
+                        : validateRegExpPattern(pattern, true) && validateRegExpPattern(pattern, false)
                 );
 
                 if (message) {
diff --git a/package.json b/package.json
index 8a79e8135..6bb7690c9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "eslint",
-  "version": "4.19.0",
+  "version": "4.19.1",
   "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
   "description": "An AST-based pattern checker for JavaScript.",
   "bin": {


Test patch:
diff --git a/tests/lib/rules/no-cond-assign.js b/tests/lib/rules/no-cond-assign.js
index b192635c8..8b8e1ae56 100644
--- a/tests/lib/rules/no-cond-assign.js
+++ b/tests/lib/rules/no-cond-assign.js
@@ -40,7 +40,8 @@ ruleTester.run("no-cond-assign", rule, {
         { code: "if ((node => node = parentNode)(someNode)) { }", options: ["always"], parserOptions: { ecmaVersion: 6 } },
         { code: "if (function(node) { return node = parentNode; }) { }", options: ["except-parens"] },
         { code: "if (function(node) { return node = parentNode; }) { }", options: ["always"] },
-        { code: "x = 0;", options: ["always"] }
+        { code: "x = 0;", options: ["always"] },
+        "var x; var b = (x === 0) ? 1 : 0;"
     ],
     invalid: [
         { code: "var x; if (x = 0) { var b = 1; }", errors: [{ messageId: "missing", type: "IfStatement", line: 1, column: 12 }] },
@@ -59,6 +60,7 @@ ruleTester.run("no-cond-assign", rule, {
         { code: "if ((x = 0)) { }", options: ["always"], errors: [{ messageId: "unexpected", data: { type: "an 'if' statement" }, type: "IfStatement" }] },
         { code: "while ((x = 0)) { }", options: ["always"], errors: [{ messageId: "unexpected", data: { type: "a 'while' statement" }, type: "WhileStatement" }] },
         { code: "do { } while ((x = x + 1));", options: ["always"], errors: [{ messageId: "unexpected", data: { type: "a 'do...while' statement" }, type: "DoWhileStatement" }] },
-        { code: "for(; (x = y); ) { }", options: ["always"], errors: [{ messageId: "unexpected", data: { type: "a 'for' statement" }, type: "ForStatement" }] }
+        { code: "for(; (x = y); ) { }", options: ["always"], errors: [{ messageId: "unexpected", data: { type: "a 'for' statement" }, type: "ForStatement" }] },
+        { code: "var x; var b = (x = 0) ? 1 : 0;", errors: [{ messageId: "missing", type: "ConditionalExpression" }] }
     ]
 });
diff --git a/tests/lib/rules/no-invalid-regexp.js b/tests/lib/rules/no-invalid-regexp.js
index 3b9dac536..305f4e0d3 100644
--- a/tests/lib/rules/no-invalid-regexp.js
+++ b/tests/lib/rules/no-invalid-regexp.js
@@ -23,6 +23,7 @@ ruleTester.run("no-invalid-regexp", rule, {
         "new RegExp",
         "new RegExp('.', 'im')",
         "global.RegExp('\\\\')",
+        "new RegExp('.', y)",
         { code: "new RegExp('.', 'y')", options: [{ allowConstructorFlags: ["y"] }] },
         { code: "new RegExp('.', 'u')", options: [{ allowConstructorFlags: ["U"] }] },
         { code: "new RegExp('.', 'yu')", options: [{ allowConstructorFlags: ["y", "u"] }] },