From 4eaf6b7c875edae8a049338f9f8690c67fd1ca08 Mon Sep 17 00:00:00 2001 From: SimonLab Date: Wed, 2 Nov 2016 22:11:19 +0000 Subject: [PATCH 1/3] add no-useless-return rule, #261 --- package.json | 2 +- rules/best_practices.js | 3 ++- test/fixtures/best_practices.js | 6 +++++- test/fixtures/no-useless-return.fail.js | 1 + test/fixtures/no-useless-return.pass.js | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/no-useless-return.fail.js create mode 100644 test/fixtures/no-useless-return.pass.js diff --git a/package.json b/package.json index 354bf06..1e2105f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "tape": "^4.6.0" }, "dependencies": { - "eslint": "^3.6.1" + "eslint": "^3.9.1" }, "bin": "./bin/cmd.js", "contributors": [ diff --git a/rules/best_practices.js b/rules/best_practices.js index 5567f58..817eca6 100644 --- a/rules/best_practices.js +++ b/rules/best_practices.js @@ -65,5 +65,6 @@ module.exports = { 'no-useless-escape': 'error', // https://github.com/dwyl/goodparts/issues/116 'no-warning-comments': 'off', // https://github.com/dwyl/goodparts/issues/117 'radix': ['error', 'always'], // https://github.com/dwyl/goodparts/issues/118 - 'wrap-iife': ['error', 'inside'] // https://github.com/dwyl/goodparts/issues/124 + 'wrap-iife': ['error', 'inside'], // https://github.com/dwyl/goodparts/issues/124 + 'no-useless-return': 'error' }; diff --git a/test/fixtures/best_practices.js b/test/fixtures/best_practices.js index fc28794..5969f86 100644 --- a/test/fixtures/best_practices.js +++ b/test/fixtures/best_practices.js @@ -250,5 +250,9 @@ module.exports = { 'no-useless-call': { fail: ['foo.call(null, 1, 2, 3);'] }, 'no-useless-escape': { fail: ['"\\a";'] }, 'no-warning-comments': null, - 'radix': { fail: ['var num = parseInt("071'] } + 'radix': { fail: ['var num = parseInt("071'] }, + 'no-useless-return': { + fail: [read('./no-useless-return.fail')], + pass: [read('./no-useless-return.pass')] + } }; diff --git a/test/fixtures/no-useless-return.fail.js b/test/fixtures/no-useless-return.fail.js new file mode 100644 index 0000000..4b0f7dc --- /dev/null +++ b/test/fixtures/no-useless-return.fail.js @@ -0,0 +1 @@ +function foo() { return; } \ No newline at end of file diff --git a/test/fixtures/no-useless-return.pass.js b/test/fixtures/no-useless-return.pass.js new file mode 100644 index 0000000..eb6a7c1 --- /dev/null +++ b/test/fixtures/no-useless-return.pass.js @@ -0,0 +1 @@ +function foo() { return 5; } \ No newline at end of file From 92007b1fd04390fde226df2bce728efec26d429d Mon Sep 17 00:00:00 2001 From: SimonLab Date: Thu, 3 Nov 2016 07:41:03 +0000 Subject: [PATCH 2/3] update version for #261 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e2105f..07786df 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "goodparts", "description": "An ESLint Style that only allows JavaScript the Good Parts (and \"Better Parts\") in your codebase.", - "version": "1.1.2", + "version": "1.1.3", "main": ".eslintrc.js", "scripts": { "test": "tape test/index.js", From 341a865a52fa2d111908e4eba232f2ceb83ecce8 Mon Sep 17 00:00:00 2001 From: Nelson Date: Thu, 3 Nov 2016 10:32:27 +0000 Subject: [PATCH 3/3] add link to issue where no-useless-return is "discussed" https://github.com/dwyl/goodparts/issues/261 :wink: --- rules/best_practices.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/best_practices.js b/rules/best_practices.js index 817eca6..47bf155 100644 --- a/rules/best_practices.js +++ b/rules/best_practices.js @@ -66,5 +66,5 @@ module.exports = { 'no-warning-comments': 'off', // https://github.com/dwyl/goodparts/issues/117 'radix': ['error', 'always'], // https://github.com/dwyl/goodparts/issues/118 'wrap-iife': ['error', 'inside'], // https://github.com/dwyl/goodparts/issues/124 - 'no-useless-return': 'error' + 'no-useless-return': 'error' // https://github.com/dwyl/goodparts/issues/261 };