Repository: eslint/eslint (js)

Issue:
func-names: Allow unnamed generators (option)
**What rule do you want to change?**
func-names

**Does this change cause the rule to produce more or fewer warnings?**
Fewer

**How will the change be implemented? (New option, new default behavior, etc.)?**
New option

**Please provide some example code that this change will affect:**

```js
const parse = coroutinify(function* (input) { ... })
```

**What does the rule currently do for this code?**
"Unexpected unnamed generator function" unless the option is set to `"never"`

**What will the rule do after it's changed?**
Allow unnamed generator functions if a second option is set to `{ generators: false }` or similar

Pull request description:
Update: Added generators option to func-names (fixes #9511)
<!--
    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)**

[x] 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:

<!--
    If the item you've checked above has a template, please paste the template questions below and answer them. (If this pull request is addressing an issue, you can just paste a link to the issue here instead.)
-->

See #9511 

<!--
    Please ensure your pull request is ready:

    - Read the pull request guide (https://eslint.org/docs/developer-guide/contributing/pull-requests)
    - Include tests for this change
    - Update documentation for this change (if appropriate)
-->

<!--
    The following is required for all pull requests:
-->

**What changes did you make? (Give an overview)**
Added a `generators` object option to func-names. When a value for `generators` is not provided the behavior for generator functions falls back to the base option.

The `generators` object option has the following effect:
- `"always"` require named generators
- `"as-needed"` require named generators if the name cannot be assigned automatically in an ES6 environment. In practice this is everywhere.
- `"never"` disallow named generators where possible.

**Is there anything you'd like reviewers to focus on?**


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8a1682df..71396bc15 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,14 @@
+v5.5.0 - August 31, 2018
+
+* 6e110e6 Fix: camelcase duplicate warning bug (fixes #10801) (#10802) (Julian Rosse)
+* 5103ee7 Docs: Add Brackets integration (#10813) (Jan Pilzer)
+* b61d2cd Update: max-params to only highlight function header (#10815) (Ian Obermiller)
+* 2b2f11d Upgrade: babel-code-frame to version 7 (#10808) (Rouven Weßling)
+* 2824d43 Docs: fix comment placement in a code example (#10799) (Vse Mozhet Byt)
+* 10690b7 Upgrade: devdeps and deps to latest (#10622) (薛定谔的猫)
+* 80c8598 Docs: gitignore syntax updates (fixes #8139) (#10776) (Gustavo Santana)
+* cb946af Chore: use meta.messages in some rules (1/4) (#10764) (薛定谔的猫)
+
 v5.4.0 - August 17, 2018
 
 * a70909f Docs: Add jscs-dev.github.io links (#10771) (Gustavo Santana)
diff --git a/docs/rules/func-names.md b/docs/rules/func-names.md
index 31b70198e..60a0910e5 100644
--- a/docs/rules/func-names.md
+++ b/docs/rules/func-names.md
@@ -20,6 +20,15 @@ This rule has a string option:
 * `"as-needed"` requires function expressions to have a name, if the name cannot be assigned automatically in an ES6 environment
 * `"never"` disallows named function expressions, except in recursive functions, where a name is needed
 
+This rule has an object option:
+
+* `"generators": "always" | "as-needed" | "never"`
+    * `"always"` require named generators
+    * `"as-needed"` require named generators if the name cannot be assigned automatically in an ES6 environment.
+    * `"never"` disallow named generators where possible.
+
+When a value for `generators` is not provided the behavior for generator functions falls back to the base option.
+
 ### always
 
 Examples of **incorrect** code for this rule with the default `"always"` option:
@@ -100,6 +109,74 @@ Foo.prototype.bar = function() {};
 }())
 ```
 
+### generators
+
+Examples of **incorrect** code for this rule with the `"always", { "generators": "as-needed" }` options:
+
+```js
+/*eslint func-names: ["error", "always", { "generators": "as-needed" }]*/
+
+(function*() {
+    // ...
+}())
+```
+
+Examples of **correct** code for this rule with the `"always", { "generators": "as-needed" }` options:
+
+```js
+/*eslint func-names: ["error", "always", { "generators": "as-needed" }]*/
+
+var foo = function*() {};
+```
+
+Examples of **incorrect** code for this rule with the `"always", { "generators": "never" }` options:
+
+```js
+/*eslint func-names: ["error", "always", { "generators": "never" }]*/
+
+var foo = bar(function *baz() {});
+```
+
+Examples of **correct** code for this rule with the `"always", { "generators": "never" }` options:
+
+```js
+/*eslint func-names: ["error", "always", { "generators": "never" }]*/
+
+var foo = bar(function *() {});
+```
+
+Examples of **incorrect** code for this rule with the `"as-needed", { "generators": "never" }` options:
+
+```js
+/*eslint func-names: ["error", "as-needed", { "generators": "never" }]*/
+
+var foo = bar(function *baz() {});
+```
+
+Examples of **correct** code for this rule with the `"as-needed", { "generators": "never" }` options:
+
+```js
+/*eslint func-names: ["error", "as-needed", { "generators": "never" }]*/
+
+var foo = bar(function *() {});
+```
+
+Examples of **incorrect** code for this rule with the `"never", { "generators": "always" }` options:
+
+```js
+/*eslint func-names: ["error", "never", { "generators": "always" }]*/
+
+var foo = bar(function *() {});
+```
+
+Examples of **correct** code for this rule with the `"never", { "generators": "always" }` options:
+
+```js
+/*eslint func-names: ["error", "never", { "generators": "always" }]*/
+
+var foo = bar(function *baz() {});
+```
+
 ## Further Reading
 
 * [Functions Explained](http://markdaggett.com/blog/2013/02/15/functions-explained/)
diff --git a/docs/user-guide/integrations.md b/docs/user-guide/integrations.md
index 17d037860..582f77e3e 100644
--- a/docs/user-guide/integrations.md
+++ b/docs/user-guide/integrations.md
@@ -10,11 +10,12 @@
     * [Syntastic](https://github.com/vim-syntastic/syntastic/tree/master/syntax_checkers/javascript)
 * Emacs: [Flycheck](http://www.flycheck.org/) supports ESLint with the [javascript-eslint](http://www.flycheck.org/en/latest/languages.html#javascript) checker.
 * Eclipse Orion: ESLint is the [default linter](https://dev.eclipse.org/mhonarc/lists/orion-dev/msg02718.html)
-* Eclipse IDE with [Tern ESLint linter](https://github.com/angelozerr/tern.java/wiki/Tern-Linter-ESLint)
-* [TextMate 2](https://github.com/natesilva/javascript-eslint.tmbundle)
+* Eclipse IDE: [Tern ESLint linter](https://github.com/angelozerr/tern.java/wiki/Tern-Linter-ESLint)
+* TextMate 2: [ESLint Bundle](https://github.com/natesilva/javascript-eslint.tmbundle)
 * Atom: [linter-eslint](https://atom.io/packages/linter-eslint)
-* [IntelliJ IDEA, RubyMine, WebStorm, PhpStorm, PyCharm, AppCode, Android Studio, 0xDBE](https://plugins.jetbrains.com/plugin/7494-eslint)
-* [Visual Studio Code](https://code.visualstudio.com) with the [ESLint Extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
+* IntelliJ IDEA, RubyMine, WebStorm, PhpStorm, PyCharm, AppCode, Android Studio, 0xDBE: [ESLint Plugin](https://plugins.jetbrains.com/plugin/7494-eslint)
+* Visual Studio Code: [ESLint Extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
+* Brackets: Included and [Brackets ESLint](https://github.com/brackets-userland/brackets-eslint)
 
 ## Build tools
 
diff --git a/lib/formatters/codeframe.js b/lib/formatters/codeframe.js
index 0b97a0d81..a42872c5a 100644
--- a/lib/formatters/codeframe.js
+++ b/lib/formatters/codeframe.js
@@ -5,7 +5,7 @@
 "use strict";
 
 const chalk = require("chalk");
-const codeFrame = require("babel-code-frame");
+const { codeFrameColumns } = require("@babel/code-frame");
 const path = require("path");
 
 //------------------------------------------------------------------------------
@@ -63,7 +63,7 @@ function formatMessage(message, parentResult) {
 
     if (sourceCode) {
         result.push(
-            codeFrame(sourceCode, message.line, message.column, { highlightCode: false })
+            codeFrameColumns(sourceCode, { start: { line: message.line, column: message.column } }, { highlightCode: false })
         );
     }
 
diff --git a/lib/rules/camelcase.js b/lib/rules/camelcase.js
index ec6116621..3005963ab 100644
--- a/lib/rules/camelcase.js
+++ b/lib/rules/camelcase.js
@@ -145,7 +145,7 @@ module.exports = {
                         const assignmentKeyEqualsValue = node.parent.key.name === node.parent.value.name;
 
                         // prevent checking righthand side of destructured object
-                        if (!assignmentKeyEqualsValue && node.parent.key === node) {
+                        if (node.parent.key === node && node.parent.value !== node) {
                             return;
                         }
 
diff --git a/lib/rules/func-names.js b/lib/rules/func-names.js
index a4f5d105d..31f302918 100644
--- a/lib/rules/func-names.js
+++ b/lib/rules/func-names.js
@@ -33,11 +33,31 @@ module.exports = {
             url: "https://eslint.org/docs/rules/func-names"
         },
 
-        schema: [
-            {
-                enum: ["always", "as-needed", "never"]
-            }
-        ],
+        schema: {
+            definitions: {
+                value: {
+                    enum: [
+                        "always",
+                        "as-needed",
+                        "never"
+                    ]
+                }
+            },
+            items: [
+                {
+                    $ref: "#/definitions/value"
+                },
+                {
+                    type: "object",
+                    properties: {
+                        generators: {
+                            $ref: "#/definitions/value"
+                        }
+                    },
+                    additionalProperties: false
+                }
+            ]
+        },
         messages: {
             unnamed: "Unexpected unnamed {{name}}.",
             named: "Unexpected named {{name}}."
@@ -45,8 +65,23 @@ module.exports = {
     },
 
     create(context) {
-        const never = context.options[0] === "never";
-        const asNeeded = context.options[0] === "as-needed";
+
+        /**
+         * Returns the config option for the given node.
+         * @param {ASTNode} node - A node to get the config for.
+         * @returns {string} The config option.
+         */
+        function getConfigForNode(node) {
+            if (
+                node.generator &&
+                context.options.length > 1 &&
+                context.options[1].generators
+            ) {
+                return context.options[1].generators;
+            }
+
+            return context.options[0] || "always";
+        }
 
         /**
          * Determines whether the current FunctionExpression node is a get, set, or
@@ -83,6 +118,32 @@ module.exports = {
                 (parent.type === "AssignmentPattern" && parent.right === node);
         }
 
+        /**
+         * Reports that an unnamed function should be named
+         * @param {ASTNode} node - The node to report in the event of an error.
+         * @returns {void}
+         */
+        function reportUnexpectedUnnamedFunction(node) {
+            context.report({
+                node,
+                messageId: "unnamed",
+                data: { name: astUtils.getFunctionNameWithKind(node) }
+            });
+        }
+
+        /**
+         * Reports that a named function should be unnamed
+         * @param {ASTNode} node - The node to report in the event of an error.
+         * @returns {void}
+         */
+        function reportUnexpectedNamedFunction(node) {
+            context.report({
+                node,
+                messageId: "named",
+                data: { name: astUtils.getFunctionNameWithKind(node) }
+            });
+        }
+
         return {
             "FunctionExpression:exit"(node) {
 
@@ -94,23 +155,19 @@ module.exports = {
                 }
 
                 const hasName = Boolean(node.id && node.id.name);
-                const name = astUtils.getFunctionNameWithKind(node);
+                const config = getConfigForNode(node);
 
-                if (never) {
+                if (config === "never") {
                     if (hasName) {
-                        context.report({
-                            node,
-                            messageId: "named",
-                            data: { name }
-                        });
+                        reportUnexpectedNamedFunction(node);
+                    }
+                } else if (config === "as-needed") {
+                    if (!hasName && !hasInferredName(node)) {
+                        reportUnexpectedUnnamedFunction(node);
                     }
                 } else {
-                    if (!hasName && (asNeeded ? !hasInferredName(node) : !isObjectOrClassMethod(node))) {
-                        context.report({
-                            node,
-                            messageId: "unnamed",
-                            data: { name }
-                        });
+                    if (!hasName && !isObjectOrClassMethod(node)) {
+                        reportUnexpectedUnnamedFunction(node);
                     }
                 }
             }
diff --git a/lib/rules/max-params.js b/lib/rules/max-params.js
index 902391b74..4089e8ae8 100644
--- a/lib/rules/max-params.js
+++ b/lib/rules/max-params.js
@@ -53,7 +53,7 @@ module.exports = {
     },
 
     create(context) {
-
+        const sourceCode = context.getSourceCode();
         const option = context.options[0];
         let numParams = 3;
 
@@ -76,6 +76,7 @@ module.exports = {
         function checkFunction(node) {
             if (node.params.length > numParams) {
                 context.report({
+                    loc: astUtils.getFunctionHeadLoc(node, sourceCode),
                     node,
                     message: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}.",
                     data: {
diff --git a/lib/rules/no-constant-condition.js b/lib/rules/no-constant-condition.js
index 724da9741..48b1fbf68 100644
--- a/lib/rules/no-constant-condition.js
+++ b/lib/rules/no-constant-condition.js
@@ -207,6 +207,8 @@ module.exports = {
             "ForStatement:exit": checkConstantConditionLoopInSet,
             FunctionDeclaration: enterFunction,
             "FunctionDeclaration:exit": exitFunction,
+            FunctionExpression: enterFunction,
+            "FunctionExpression:exit": exitFunction,
             YieldExpression: () => loopsInCurrentScope.clear()
         };
 
diff --git a/package.json b/package.json
index 65681ae36..d50f484f0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "eslint",
-  "version": "5.4.0",
+  "version": "5.5.0",
   "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
   "description": "An AST-based pattern checker for JavaScript.",
   "bin": {
@@ -35,8 +35,8 @@
   "homepage": "https://eslint.org",
   "bugs": "https://github.com/eslint/eslint/issues/",
   "dependencies": {
+    "@babel/code-frame": "^7.0.0",
     "ajv": "^6.5.3",
-    "babel-code-frame": "^6.26.0",
     "chalk": "^2.1.0",
     "cross-spawn": "^6.0.5",
     "debug": "^3.1.0",
diff --git a/packages/eslint-config-eslint/default.yml b/packages/eslint-config-eslint/default.yml
index 73c244bf3..579b53abc 100644
--- a/packages/eslint-config-eslint/default.yml
+++ b/packages/eslint-config-eslint/default.yml
@@ -155,7 +155,7 @@ rules:
     prefer-rest-params: "error"
     prefer-spread: "error"
     prefer-template: "error"
-    quotes: ["error", "double"]
+    quotes: ["error", "double", {avoidEscape: true}]
     quote-props: ["error", "as-needed"]
     radix: "error"
     require-atomic-updates: "error"
diff --git a/templates/bug-report.md b/templates/bug-report.md
index eb64ba737..d31fcde74 100644
--- a/templates/bug-report.md
+++ b/templates/bug-report.md
@@ -8,6 +8,16 @@
 
 **Please show your full configuration:**
 
+<details>
+<summary>Configuration</summary>
+
+<!-- Paste your configuration below: -->
+```js
+
+```
+
+</details>
+
 **What did you do? Please include the actual source code causing the issue.**
 
 **What did you expect to happen?**


Test patch:
diff --git a/tests/lib/rules/camelcase.js b/tests/lib/rules/camelcase.js
index f21459085..481842f97 100644
--- a/tests/lib/rules/camelcase.js
+++ b/tests/lib/rules/camelcase.js
@@ -352,6 +352,17 @@ ruleTester.run("camelcase", rule, {
                 }
             ]
         },
+        {
+            code: "var { category_id: category_id } = query;",
+            parserOptions: { ecmaVersion: 6 },
+            errors: [
+                {
+                    messageId: "notCamelCase",
+                    data: { name: "category_id" },
+                    type: "Identifier"
+                }
+            ]
+        },
         {
             code: "var { category_id = 1 } = query;",
             parserOptions: { ecmaVersion: 6 },
diff --git a/tests/lib/rules/func-names.js b/tests/lib/rules/func-names.js
index 318ef8a3c..0dfc00dd5 100644
--- a/tests/lib/rules/func-names.js
+++ b/tests/lib/rules/func-names.js
@@ -126,6 +126,129 @@ ruleTester.run("func-names", rule, {
             code: "({ foo() {} });",
             options: ["never"],
             parserOptions: { ecmaVersion: 6 }
+        },
+
+        // generators
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["always"],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["always", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["always", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["always", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["as-needed"],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["as-needed"],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["as-needed", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["as-needed", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["as-needed", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["never", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["never", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["never", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["never"],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["never"],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "(function*() {}())",
+            options: ["never"],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["never", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["never", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "(function*() {}())",
+            options: ["never", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["always", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["always", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "(function*() {}())",
+            options: ["always", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["as-needed", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["as-needed", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
+        },
+        {
+            code: "(function*() {}())",
+            options: ["as-needed", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 }
         }
     ],
     invalid: [
@@ -198,6 +321,155 @@ ruleTester.run("func-names", rule, {
             code: "({foo: function foo() {}})",
             options: ["never"],
             errors: [{ messageId: "named", data: { name: "method 'foo'" }, type: "FunctionExpression" }]
+        },
+
+        // generators
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["always"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["always"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "(function*() {}())",
+            options: ["always"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["always", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["always", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "(function*() {}())",
+            options: ["always", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["always", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "(function*() {}())",
+            options: ["always", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["as-needed"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "(function*() {}())",
+            options: ["as-needed"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["as-needed", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["as-needed", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "(function*() {}())",
+            options: ["as-needed", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["as-needed", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "(function*() {}())",
+            options: ["as-needed", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["never", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = function*() {};",
+            options: ["never", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "(function*() {}())",
+            options: ["never", { generators: "always" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "var foo = bar(function *() {});",
+            options: ["never", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+        {
+            code: "(function*() {}())",
+            options: ["never", { generators: "as-needed" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [unnamedError]
+        },
+
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["never"],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{
+                message: "Unexpected named generator function 'baz'."
+            }]
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["never", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{ messageId: "named", data: { name: "generator function 'baz'" }, type: "FunctionExpression" }]
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["always", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{ messageId: "named", data: { name: "generator function 'baz'" }, type: "FunctionExpression" }]
+        },
+        {
+            code: "var foo = bar(function *baz() {});",
+            options: ["as-needed", { generators: "never" }],
+            parserOptions: { ecmaVersion: 6 },
+            errors: [{ messageId: "named", data: { name: "generator function 'baz'" }, type: "FunctionExpression" }]
         }
     ]
 });
diff --git a/tests/lib/rules/max-params.js b/tests/lib/rules/max-params.js
index 3cb47044f..959f5d7b8 100644
--- a/tests/lib/rules/max-params.js
+++ b/tests/lib/rules/max-params.js
@@ -86,6 +86,20 @@ ruleTester.run("max-params", rule, {
                 message: "Function 'test' has too many parameters (3). Maximum allowed is 2.",
                 type: "FunctionDeclaration"
             }]
+        },
+
+        // Error location should not cover the entire function; just the name.
+        {
+            code: `function test(a, b, c) {
+              // Just to make it longer
+            }`,
+            options: [{ max: 2 }],
+            errors: [{
+                line: 1,
+                column: 1,
+                endLine: 1,
+                endColumn: 14
+            }]
         }
     ]
 });
diff --git a/tests/lib/rules/no-constant-condition.js b/tests/lib/rules/no-constant-condition.js
index 1ec03f0e7..69a90dd38 100644
--- a/tests/lib/rules/no-constant-condition.js
+++ b/tests/lib/rules/no-constant-condition.js
@@ -152,6 +152,10 @@ ruleTester.run("no-constant-condition", rule, {
             code: "function foo() {while (true) {function* bar() {while (true) {yield;}}}}",
             errors: [{ messageId: "unexpected", type: "Literal" }]
         },
+        {
+            code: "function foo() {while (true) {const bar = function*() {while (true) {yield;}}}}",
+            errors: [{ messageId: "unexpected", type: "Literal" }]
+        },
         {
             code: "function* foo() { for (let foo = 1 + 2 + 3 + (yield); true; baz) {}}",
             errors: [{ messageId: "unexpected", type: "Literal" }]