Repository: eslint/eslint (js)

Issue:
TypeError: Cannot read property 'value' of null
<!--
    ESLint adheres to the [JS Foundation Code of Conduct](https://js.foundation/community/code-of-conduct).

    This template is for bug reports. If you are here for another reason, please see below:

    1. To propose a new rule: https://eslint.org/docs/developer-guide/contributing/new-rules
    2. To request a rule change: https://eslint.org/docs/developer-guide/contributing/rule-changes
    3. To request a change that is not a bug fix, rule change, or new rule: https://eslint.org/docs/developer-guide/contributing/changes
    4. If you have any questions, please stop by our chatroom: https://gitter.im/eslint/eslint

    Note that leaving sections blank will make it difficult for us to troubleshoot and we may have to close the issue.
-->

**Tell us about your environment**

* **ESLint Version:** v4.15.0
* **Node Version:** v8.9.4
* **npm Version:** 5.6.0

**What parser (default, Babel-ESLint, etc.) are you using?**
- `babel-eslint`

**Please show your full configuration:**

<details>
<summary>Configuration</summary>

<!-- Paste your configuration below: -->
```js
module.exports = {
	parser: "babel-eslint",
	rules   : {
		'arrow-body-style' : ['warn', 'as-needed'],
	},
};
```

</details>

**What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.**

<!-- Paste the source code below: -->
```js
test = () => { return }
```

<!-- Paste the command you used to run ESLint: -->
```bash
./node_modules/.bin/eslint FILE
```

**What did you expect to happen?**

Eslint to lint the file

**What actually happened? Please include the actual, raw output from ESLint.**

Error received `TypeError: Cannot read property 'value' of null`

```
Cannot read property 'value' of null
TypeError: Cannot read property 'value' of null
    at Object.isOpeningBraceToken (./node_modules/eslint/lib/ast-utils.js:354:18)
    at validate (./node_modules/eslint/lib/rules/arrow-body-style.js:119:41)
    at listeners.(anonymous function).forEach.listener (./node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (./node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (./node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (./node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.leaveNode (./node_modules/eslint/lib/util/node-event-generator.js:303:14)
    at CodePathAnalyzer.leaveNode (./node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:630:23)
    at Traverser.leave [as _leave] (./node_modules/eslint/lib/linter.js:1001:32)
```

Pull request:
Fix: allow no tokens after `return` keyword (fixes #10372)
<!--
    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
[x] 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))
[ ] 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.)
-->
close #10372 
<!--
    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)**
Allow:
```js
test = () => { return }
```

**Is there anything you'd like reviewers to focus on?**




Patch:
diff --git a/lib/rules/arrow-body-style.js b/lib/rules/arrow-body-style.js
index 1f0d1377b..49feb0670 100644
--- a/lib/rules/arrow-body-style.js
+++ b/lib/rules/arrow-body-style.js
@@ -124,6 +124,8 @@ module.exports = {
                         messageId = "unexpectedEmptyBlock";
                     } else if (blockBody.length > 1) {
                         messageId = "unexpectedOtherBlock";
+                    } else if (blockBody[0].argument === null) {
+                        messageId = "unexpectedSingleBlock";
                     } else if (astUtils.isOpeningBraceToken(sourceCode.getFirstToken(blockBody[0], { skip: 1 }))) {
                         messageId = "unexpectedObjectBlock";
                     } else {


Test patch:
diff --git a/tests/lib/rules/arrow-body-style.js b/tests/lib/rules/arrow-body-style.js
index 14572e98a..5e5fbc351 100644
--- a/tests/lib/rules/arrow-body-style.js
+++ b/tests/lib/rules/arrow-body-style.js
@@ -162,6 +162,19 @@ ruleTester.run("arrow-body-style", rule, {
                 }
             ]
         },
+        {
+            code: "var foo = () => { return };",
+            output: null, // not fixed
+            options: ["as-needed", { requireReturnForObjectLiteral: true }],
+            errors: [
+                {
+                    line: 1,
+                    column: 17,
+                    type: "ArrowFunctionExpression",
+                    messageId: "unexpectedSingleBlock"
+                }
+            ]
+        },
         {
             code: "var foo = () => { return; };",
             output: null, // not fixed