From d537d85314f88e9f2640232c4fdd9cd11611e511 Mon Sep 17 00:00:00 2001 From: Aaron Harvey Date: Thu, 17 Nov 2016 12:16:09 -0500 Subject: [PATCH] feat: add support carriage return --- src/rules/typeColonSpacing/reporter.js | 2 +- tests/rules/assertions/spaceAfterTypeColon.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rules/typeColonSpacing/reporter.js b/src/rules/typeColonSpacing/reporter.js index 49b186ad..e1c92870 100644 --- a/src/rules/typeColonSpacing/reporter.js +++ b/src/rules/typeColonSpacing/reporter.js @@ -22,7 +22,7 @@ export default (direction, context, {always, allowLineBreak}) => { const charAfter = context.getSourceCode().getText(colon, 0, 1).slice(1); - if (allowLineBreak && (charAfter === '\n' || charAfter === '\r\n')) { + if (allowLineBreak && RegExp(/(\n|\r)+/).test(charAfter)) { spaces = 1; } else { spaces = getSpaces(direction, colon, context); diff --git a/tests/rules/assertions/spaceAfterTypeColon.js b/tests/rules/assertions/spaceAfterTypeColon.js index 13976583..a354cc95 100644 --- a/tests/rules/assertions/spaceAfterTypeColon.js +++ b/tests/rules/assertions/spaceAfterTypeColon.js @@ -124,6 +124,12 @@ const ARROW_FUNCTION_PARAMS = { options: ['always', { allowLineBreak: true }] + }, + { + code: '(foo:\r\n { a: string, b: number }) => {}', + options: ['always', { + allowLineBreak: true + }] } ] };