From 199ce48fe64a2d4381c9e1907e51d253e54cb80a Mon Sep 17 00:00:00 2001 From: Filipe Correia Date: Tue, 17 Jan 2017 15:24:04 +0000 Subject: [PATCH] Enforce the newline-before-return rule --- src/index.js | 1 + test/fixtures/correct.js | 11 +++++++++++ test/fixtures/incorrect.js | 10 ++++++++++ test/index.js | 1 + 4 files changed, 23 insertions(+) diff --git a/src/index.js b/src/index.js index 409cc51..3955b16 100644 --- a/src/index.js +++ b/src/index.js @@ -63,6 +63,7 @@ module.exports = { 'new-cap': 'error', 'new-parens': 'error', 'newline-after-var': 'error', + 'newline-before-return': 'error', 'no-alert': 'error', 'no-array-constructor': 'error', 'no-bitwise': 'error', diff --git a/test/fixtures/correct.js b/test/fixtures/correct.js index 8874be3..5852749 100644 --- a/test/fixtures/correct.js +++ b/test/fixtures/correct.js @@ -85,6 +85,17 @@ const newLineAfterVar = 'foo'; noop(newLineAfterVar); +// `newline-before-return`. +function funcThatReturns(bar) { + if (!bar) { + return; + } + + return bar; +} + +funcThatReturns('foo'); + // `no-class-assign`. class NoClassAssign { } diff --git a/test/fixtures/incorrect.js b/test/fixtures/incorrect.js index 809d665..f3dbd7d 100644 --- a/test/fixtures/incorrect.js +++ b/test/fixtures/incorrect.js @@ -78,6 +78,16 @@ const newCap = new cap(); const newLineAfterVar = 'foo'; noop(newLineAfterVar); +// `newline-before-return`. +function funcThatReturns(bar) { + if (!bar) { + return; + } + return bar; +} + +funcThatReturns('foo'); + // `no-class-assign`. class NoClassAssign { } diff --git a/test/index.js b/test/index.js index f99e738..f0021b5 100644 --- a/test/index.js +++ b/test/index.js @@ -48,6 +48,7 @@ describe('eslint-config-seegno', () => { 'mocha/no-exclusive-tests', 'new-cap', 'newline-after-var', + 'newline-before-return', 'no-class-assign', 'no-const-assign', 'no-constant-condition',