Repository: vuejs/eslint-plugin-vue
Pull request #655 (2018-11-13 00:24:01)

Fix issues with `require-render-return` and `return-in-computed-property`
i found this issue while doing: 
https://armano2.github.io/eslint-plugin-vue/rules/require-render-return.html#rule-details
and
http://armano2.github.io/eslint-plugin-vue/rules/return-in-computed-property.html#rule-details


Patch:
diff --git a/lib/rules/component-name-in-template-casing.js b/lib/rules/component-name-in-template-casing.js
index 6de8e668..eb85e8a9 100644
--- a/lib/rules/component-name-in-template-casing.js
+++ b/lib/rules/component-name-in-template-casing.js
@@ -22,7 +22,7 @@ module.exports = {
   meta: {
     docs: {
       description: 'enforce specific casing for the component naming style in template',
-      category: undefined, // strongly-recommended
+      category: 'strongly-recommended',
       url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/component-name-in-template-casing.md'
     },
     fixable: 'code',
diff --git a/lib/rules/multiline-html-element-content-newline.js b/lib/rules/multiline-html-element-content-newline.js
index 415c8ddf..c32db8e6 100644
--- a/lib/rules/multiline-html-element-content-newline.js
+++ b/lib/rules/multiline-html-element-content-newline.js
@@ -51,7 +51,7 @@ module.exports = {
   meta: {
     docs: {
       description: 'require a line break before and after the contents of a multiline element',
-      category: undefined,
+      category: 'strongly-recommended',
       url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/multiline-html-element-content-newline.md'
     },
     fixable: 'whitespace',
diff --git a/lib/rules/no-spaces-around-equal-signs-in-attribute.js b/lib/rules/no-spaces-around-equal-signs-in-attribute.js
index 3a2dbb89..eefe09e8 100644
--- a/lib/rules/no-spaces-around-equal-signs-in-attribute.js
+++ b/lib/rules/no-spaces-around-equal-signs-in-attribute.js
@@ -18,7 +18,7 @@ module.exports = {
   meta: {
     docs: {
       description: 'disallow spaces around equal signs in attribute',
-      category: undefined,
+      category: 'strongly-recommended',
       url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/no-spaces-around-equal-signs-in-attribute.md'
     },
     fixable: 'whitespace',
diff --git a/lib/rules/singleline-html-element-content-newline.js b/lib/rules/singleline-html-element-content-newline.js
index 309f789d..f444a990 100644
--- a/lib/rules/singleline-html-element-content-newline.js
+++ b/lib/rules/singleline-html-element-content-newline.js
@@ -46,7 +46,7 @@ module.exports = {
   meta: {
     docs: {
       description: 'require a line break before and after the contents of a singleline element',
-      category: undefined,
+      category: 'strongly-recommended',
       url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/singleline-html-element-content-newline.md'
     },
     fixable: 'whitespace',
diff --git a/lib/rules/use-v-on-exact.js b/lib/rules/use-v-on-exact.js
index 959dec01..8291b9af 100644
--- a/lib/rules/use-v-on-exact.js
+++ b/lib/rules/use-v-on-exact.js
@@ -18,7 +18,7 @@ module.exports = {
   meta: {
     docs: {
       description: 'enforce usage of `exact` modifier on `v-on`',
-      category: undefined, // essential
+      category: 'essential',
       url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v5.0.0-beta.4/docs/rules/use-v-on-exact.md'
     },
     fixable: null,
diff --git a/lib/utils/index.js b/lib/utils/index.js
index 9491117f..cf58a0fc 100644
--- a/lib/utils/index.js
+++ b/lib/utils/index.js
@@ -685,8 +685,12 @@ module.exports = {
       node: null
     }
 
+    function isReachable (segment) {
+      return segment.reachable
+    }
+
     function isValidReturn () {
-      if (!funcInfo.hasReturn) {
+      if (funcInfo.codePath.currentSegments.some(isReachable)) {
         return false
       }
       return !treatUndefinedAsUnspecified || funcInfo.hasReturnValue


Test patch:
diff --git a/tests/lib/rules/require-render-return.js b/tests/lib/rules/require-render-return.js
index 38132b28..e7fde4e6 100644
--- a/tests/lib/rules/require-render-return.js
+++ b/tests/lib/rules/require-render-return.js
@@ -70,6 +70,36 @@ ruleTester.run('require-render-return', rule, {
       }`,
       parserOptions
     },
+    {
+      filename: 'test.vue',
+      code: `export default {
+        render() {
+          const foo = function () {}
+          return foo
+        }
+      }`,
+      parserOptions
+    },
+    {
+      filename: 'test.vue',
+      code: `export default {
+        render() {
+          if (a) {
+            if (b) {
+              
+            }
+            if (c) {
+              return true
+            } else {
+              return foo
+            }
+          } else {
+            return foo
+          }
+        }
+      }`,
+      parserOptions
+    },
     {
       filename: 'test.vue',
       code: `export default {
@@ -119,6 +149,22 @@ ruleTester.run('require-render-return', rule, {
         line: 2
       }]
     },
+    {
+      filename: 'test.vue',
+      code: `export default {
+        render: function () {
+          if (foo) {
+            return h('div', 'hello')
+          }
+        }
+      }`,
+      parserOptions,
+      errors: [{
+        message: 'Expected to return a value in render function.',
+        type: 'Identifier',
+        line: 2
+      }]
+    },
     {
       code: `Vue.component('test', {
         render: function () {
@@ -133,6 +179,38 @@ ruleTester.run('require-render-return', rule, {
         type: 'Identifier',
         line: 2
       }]
+    },
+    {
+      code: `Vue.component('test2', {
+        render: function () {
+          if (a) {
+            return h('div', 'hello')
+          }
+        }
+      })`,
+      parserOptions,
+      errors: [{
+        message: 'Expected to return a value in render function.',
+        type: 'Identifier',
+        line: 2
+      }]
+    },
+    {
+      code: `Vue.component('test2', {
+        render: function () {
+          if (a) {
+            
+          } else {
+            return h('div', 'hello')
+          }
+        }
+      })`,
+      parserOptions,
+      errors: [{
+        message: 'Expected to return a value in render function.',
+        type: 'Identifier',
+        line: 2
+      }]
     }
   ]
 })