From 94ef5f56832895f58b9c519fe979f39aeb32bcfb Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Thu, 17 Sep 2020 07:31:29 +0800 Subject: [PATCH] Test: Fix indexes calculation (#9152) * Test: Fix indexes calculation * Simplify logic * Update snapshots --- .../cursor/__snapshots__/jsfmt.spec.js.snap | 1 + .../range/__snapshots__/jsfmt.spec.js.snap | 1 + .../range/__snapshots__/jsfmt.spec.js.snap | 1 + tests/js/bom/__snapshots__/jsfmt.spec.js.snap | 9 ++ .../cursor/__snapshots__/jsfmt.spec.js.snap | 39 +++++++- tests/js/cursor/range-3.js | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 1 + tests/js/eol/__snapshots__/jsfmt.spec.js.snap | 36 +++++++ .../js/range/__snapshots__/jsfmt.spec.js.snap | 62 ++++++++++++ .../range/__snapshots__/jsfmt.spec.js.snap | 4 + .../js/__snapshots__/jsfmt.spec.js.snap | 4 + .../range/__snapshots__/jsfmt.spec.js.snap | 6 ++ .../range/__snapshots__/jsfmt.spec.js.snap | 2 + tests_config/run_spec.js | 95 +++++++++++++------ .../utils/compose-options-for-snapshot.js | 3 - 15 files changed, 231 insertions(+), 37 deletions(-) diff --git a/tests/css/cursor/__snapshots__/jsfmt.spec.js.snap b/tests/css/cursor/__snapshots__/jsfmt.spec.js.snap index 3453cb8c6..b249ea379 100644 --- a/tests/css/cursor/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css/cursor/__snapshots__/jsfmt.spec.js.snap @@ -2,6 +2,7 @@ exports[`test.css format 1`] = ` ====================================options===================================== +cursorOffset: 19 parsers: ["css"] printWidth: 80 | printWidth diff --git a/tests/css/range/__snapshots__/jsfmt.spec.js.snap b/tests/css/range/__snapshots__/jsfmt.spec.js.snap index 079ae7847..090dfdf59 100644 --- a/tests/css/range/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css/range/__snapshots__/jsfmt.spec.js.snap @@ -4,6 +4,7 @@ exports[`issue2267.css format 1`] = ` ====================================options===================================== parsers: ["css"] printWidth: 80 +rangeEnd: 4 | | printWidth =====================================input====================================== > 1 | .x{} diff --git a/tests/graphql/range/__snapshots__/jsfmt.spec.js.snap b/tests/graphql/range/__snapshots__/jsfmt.spec.js.snap index 48554cbc8..648665abd 100644 --- a/tests/graphql/range/__snapshots__/jsfmt.spec.js.snap +++ b/tests/graphql/range/__snapshots__/jsfmt.spec.js.snap @@ -4,6 +4,7 @@ exports[`issue2296.graphql format 1`] = ` ====================================options===================================== parsers: ["graphql"] printWidth: 80 +rangeEnd: 3 | | printWidth =====================================input====================================== > 1 | {NPC{life}} diff --git a/tests/js/bom/__snapshots__/jsfmt.spec.js.snap b/tests/js/bom/__snapshots__/jsfmt.spec.js.snap index a3dfa748b..ea19003f7 100644 --- a/tests/js/bom/__snapshots__/jsfmt.spec.js.snap +++ b/tests/js/bom/__snapshots__/jsfmt.spec.js.snap @@ -2,6 +2,7 @@ exports[`snippet: cursor-1.js format 1`] = ` ====================================options===================================== +cursorOffset: 27 parsers: ["babel"] printWidth: 80 | printWidth @@ -18,8 +19,11 @@ printWidth: 80 exports[`snippet: cursor-and-range.js format 1`] = ` ====================================options===================================== +cursorOffset: 22 parsers: ["babel"] printWidth: 80 +rangeEnd: 27 +rangeStart: 11 | | printWidth =====================================input====================================== 1 |  @@ -46,6 +50,8 @@ exports[`snippet: range-1.js format 1`] = ` ====================================options===================================== parsers: ["babel"] printWidth: 80 +rangeEnd: 27 +rangeStart: 11 | | printWidth =====================================input====================================== 1 |  @@ -72,8 +78,11 @@ let x exports[`snippet: range-and-cursor-1.js format 1`] = ` ====================================options===================================== +cursorOffset: 23 parsers: ["babel"] printWidth: 80 +rangeEnd: 28 +rangeStart: 12 | | printWidth =====================================input====================================== 1 |  diff --git a/tests/js/cursor/__snapshots__/jsfmt.spec.js.snap b/tests/js/cursor/__snapshots__/jsfmt.spec.js.snap index fe531c478..09262351b 100644 --- a/tests/js/cursor/__snapshots__/jsfmt.spec.js.snap +++ b/tests/js/cursor/__snapshots__/jsfmt.spec.js.snap @@ -2,6 +2,7 @@ exports[`comments-1.js format 1`] = ` ====================================options===================================== +cursorOffset: 7 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -22,6 +23,7 @@ function ehllooo() { exports[`comments-2.js format 1`] = ` ====================================options===================================== +cursorOffset: 0 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -41,6 +43,7 @@ const y = 5; exports[`comments-3.js format 1`] = ` ====================================options===================================== +cursorOffset: 1 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -59,6 +62,7 @@ const y = 5; exports[`comments-4.js format 1`] = ` ====================================options===================================== +cursorOffset: 44 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -79,6 +83,7 @@ const y = 5; exports[`cursor-0.js format 1`] = ` ====================================options===================================== +cursorOffset: 27 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -95,6 +100,7 @@ printWidth: 80 exports[`cursor-1.js format 1`] = ` ====================================options===================================== +cursorOffset: 26 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -111,6 +117,7 @@ printWidth: 80 exports[`cursor-2.js format 1`] = ` ====================================options===================================== +cursorOffset: 6 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -126,6 +133,7 @@ foo<|>(bar); exports[`cursor-3.js format 1`] = ` ====================================options===================================== +cursorOffset: 4 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -144,6 +152,7 @@ printWidth: 80 exports[`cursor-4.js format 1`] = ` ====================================options===================================== +cursorOffset: 19 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -166,6 +175,7 @@ const y = 5; exports[`cursor-5.js format 1`] = ` ====================================options===================================== +cursorOffset: 13 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -180,6 +190,7 @@ const /* h<|>i */ y = 5; exports[`cursor-6.js format 1`] = ` ====================================options===================================== +cursorOffset: 20 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -194,6 +205,7 @@ const y /* h<|>i */ = 5; exports[`cursor-7.js format 1`] = ` ====================================options===================================== +cursorOffset: 12 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -213,6 +225,7 @@ const z = 9; exports[`cursor-8.js format 1`] = ` ====================================options===================================== +cursorOffset: 6 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -226,6 +239,7 @@ func<|>tion banana() {} exports[`cursor-9.js format 1`] = ` ====================================options===================================== +cursorOffset: 26 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -239,6 +253,7 @@ thisWillBeFormatted<|>(2, 3); exports[`cursor-10.js format 1`] = ` ====================================options===================================== +cursorOffset: 16 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -258,6 +273,7 @@ const y = 5; exports[`file-start-with-comment-1.js format 1`] = ` ====================================options===================================== +cursorOffset: 5 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -274,6 +290,7 @@ haha(); exports[`file-start-with-comment-2.js format 1`] = ` ====================================options===================================== +cursorOffset: 16 parsers: ["babel", "typescript", "flow"] printWidth: 80 | printWidth @@ -290,8 +307,11 @@ haha()<|>; exports[`range-0.js format 1`] = ` ====================================options===================================== +cursorOffset: 56 parsers: ["babel", "typescript", "flow"] printWidth: 80 +rangeEnd: 72 +rangeStart: 31 | | printWidth =====================================input====================================== 1 | thisWontBeFormatted ( 1 ,3) @@ -315,8 +335,11 @@ thisWontBeFormatted ( 1 ,3) exports[`range-1.js format 1`] = ` ====================================options===================================== +cursorOffset: 64 parsers: ["babel", "typescript", "flow"] printWidth: 80 +rangeEnd: 72 +rangeStart: 31 | | printWidth =====================================input====================================== 1 | thisWontBeFormatted ( 1 ,3) @@ -340,8 +363,11 @@ thisWontBeFormatted ( 1 ,3) exports[`range-2.js format 1`] = ` ====================================options===================================== +cursorOffset: 67 parsers: ["babel", "typescript", "flow"] printWidth: 80 +rangeEnd: 72 +rangeStart: 31 | | printWidth =====================================input====================================== 1 | thisWontBeFormatted ( 1 ,3) @@ -365,18 +391,20 @@ thisWontBeFormatted ( 1 ,3) exports[`range-3.js format 1`] = ` ====================================options===================================== +cursorOffset: 20 parsers: ["babel", "typescript", "flow"] printWidth: 80 +rangeEnd: 72 +rangeStart: 30 | | printWidth =====================================input====================================== -> 1 | thisWontBeFormatted <|> ( 1 ,3) - | ^ + 1 | thisWontBeFormatted <|> ( 1 ,3) > 2 | | ^ > 3 | thisWillBeFormatted (2 ,3, ) - | ^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 4 | - | ^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 5 | thisWontBeFormatted (2, 90 ,) | ^ 6 | @@ -392,8 +420,11 @@ thisWontBeFormatted <|> ( 1 ,3) exports[`range-4.js format 1`] = ` ====================================options===================================== +cursorOffset: 101 parsers: ["babel", "typescript", "flow"] printWidth: 80 +rangeEnd: 75 +rangeStart: 31 | | printWidth =====================================input====================================== 1 | thisWontBeFormatted ( 1 ,3) diff --git a/tests/js/cursor/range-3.js b/tests/js/cursor/range-3.js index 863d836b9..eab58943f 100644 --- a/tests/js/cursor/range-3.js +++ b/tests/js/cursor/range-3.js @@ -1,5 +1,5 @@ -thisWontBeFormatted <|> ( 1 ,3<<>>) - +thisWontBeFormatted <|> ( 1 ,3) +<<>> thisWillBeFormatted (2 ,3, ) <<>> thisWontBeFormatted (2, 90 ,) diff --git a/tests/js/cursor/require-pragma/__snapshots__/jsfmt.spec.js.snap b/tests/js/cursor/require-pragma/__snapshots__/jsfmt.spec.js.snap index b4fef7f72..0496e72a9 100644 --- a/tests/js/cursor/require-pragma/__snapshots__/jsfmt.spec.js.snap +++ b/tests/js/cursor/require-pragma/__snapshots__/jsfmt.spec.js.snap @@ -2,6 +2,7 @@ exports[`cursor-without-pragma.js - {"requirePragma":true} format 1`] = ` ====================================options===================================== +cursorOffset: 27 parsers: ["babel", "typescript", "flow"] printWidth: 80 requirePragma: true diff --git a/tests/js/eol/__snapshots__/jsfmt.spec.js.snap b/tests/js/eol/__snapshots__/jsfmt.spec.js.snap index c8d4614c1..527b3d550 100644 --- a/tests/js/eol/__snapshots__/jsfmt.spec.js.snap +++ b/tests/js/eol/__snapshots__/jsfmt.spec.js.snap @@ -2,6 +2,7 @@ exports[`cursor-1.js - {"endOfLine":"auto"} format 1`] = ` ====================================options===================================== +cursorOffset: 26 endOfLine: "auto" parsers: ["babel"] printWidth: 80 @@ -19,6 +20,7 @@ printWidth: 80 exports[`cursor-1.js - {"endOfLine":"cr"} format 1`] = ` ====================================options===================================== +cursorOffset: 26 endOfLine: "cr" parsers: ["babel"] printWidth: 80 @@ -36,6 +38,7 @@ printWidth: 80 exports[`cursor-1.js - {"endOfLine":"crlf"} format 1`] = ` ====================================options===================================== +cursorOffset: 26 endOfLine: "crlf" parsers: ["babel"] printWidth: 80 @@ -53,6 +56,7 @@ printWidth: 80 exports[`cursor-1.js - {"endOfLine":"lf"} format 1`] = ` ====================================options===================================== +cursorOffset: 26 endOfLine: "lf" parsers: ["babel"] printWidth: 80 @@ -70,9 +74,12 @@ printWidth: 80 exports[`cursor-and-range.js - {"endOfLine":"auto"} format 1`] = ` ====================================options===================================== +cursorOffset: 21 endOfLine: "auto" parsers: ["babel"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -97,9 +104,12 @@ let x exports[`cursor-and-range.js - {"endOfLine":"cr"} format 1`] = ` ====================================options===================================== +cursorOffset: 21 endOfLine: "cr" parsers: ["babel"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -124,9 +134,12 @@ let x exports[`cursor-and-range.js - {"endOfLine":"crlf"} format 1`] = ` ====================================options===================================== +cursorOffset: 21 endOfLine: "crlf" parsers: ["babel"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -151,9 +164,12 @@ let x exports[`cursor-and-range.js - {"endOfLine":"lf"} format 1`] = ` ====================================options===================================== +cursorOffset: 21 endOfLine: "lf" parsers: ["babel"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -181,6 +197,8 @@ exports[`range-1.js - {"endOfLine":"auto"} format 1`] = ` endOfLine: "auto" parsers: ["babel"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -210,6 +228,8 @@ exports[`range-1.js - {"endOfLine":"cr"} format 1`] = ` endOfLine: "cr" parsers: ["babel"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -239,6 +259,8 @@ exports[`range-1.js - {"endOfLine":"crlf"} format 1`] = ` endOfLine: "crlf" parsers: ["babel"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -268,6 +290,8 @@ exports[`range-1.js - {"endOfLine":"lf"} format 1`] = ` endOfLine: "lf" parsers: ["babel"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -294,9 +318,12 @@ let x exports[`range-and-cursor-1.js - {"endOfLine":"auto"} format 1`] = ` ====================================options===================================== +cursorOffset: 22 endOfLine: "auto" parsers: ["babel"] printWidth: 80 +rangeEnd: 27 +rangeStart: 11 | | printWidth =====================================input====================================== 1 | @@ -325,9 +352,12 @@ let x exports[`range-and-cursor-1.js - {"endOfLine":"cr"} format 1`] = ` ====================================options===================================== +cursorOffset: 22 endOfLine: "cr" parsers: ["babel"] printWidth: 80 +rangeEnd: 27 +rangeStart: 11 | | printWidth =====================================input====================================== 1 | @@ -356,9 +386,12 @@ let x exports[`range-and-cursor-1.js - {"endOfLine":"crlf"} format 1`] = ` ====================================options===================================== +cursorOffset: 22 endOfLine: "crlf" parsers: ["babel"] printWidth: 80 +rangeEnd: 27 +rangeStart: 11 | | printWidth =====================================input====================================== 1 | @@ -387,9 +420,12 @@ let x exports[`range-and-cursor-1.js - {"endOfLine":"lf"} format 1`] = ` ====================================options===================================== +cursorOffset: 22 endOfLine: "lf" parsers: ["babel"] printWidth: 80 +rangeEnd: 27 +rangeStart: 11 | | printWidth =====================================input====================================== 1 | diff --git a/tests/js/range/__snapshots__/jsfmt.spec.js.snap b/tests/js/range/__snapshots__/jsfmt.spec.js.snap index 99e03bb44..339cca526 100644 --- a/tests/js/range/__snapshots__/jsfmt.spec.js.snap +++ b/tests/js/range/__snapshots__/jsfmt.spec.js.snap @@ -4,6 +4,8 @@ exports[`array.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 16 +rangeStart: 8 | | printWidth =====================================input====================================== 1 | a = [ @@ -28,6 +30,8 @@ exports[`class-declaration.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 26 +rangeStart: 10 | | printWidth =====================================input====================================== 1 | @@ -54,6 +58,8 @@ exports[`different-levels.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 48 +rangeStart: 19 | | printWidth =====================================input====================================== 1 | call(1,2,3) @@ -79,6 +85,8 @@ exports[`directive.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 1 +rangeStart: 0 | | printWidth =====================================input====================================== > 1 | 'aaa'; @@ -96,6 +104,8 @@ exports[`function-declaration.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 43 +rangeStart: 16 | | printWidth =====================================input====================================== > 1 | function ugly ( {a=1, b = 2 } ) {} @@ -111,6 +121,8 @@ exports[`ignore-indentation.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 225 +rangeStart: 222 | | printWidth =====================================input====================================== 1 | function ugly ( {a=1, b = 2 } ) { @@ -140,6 +152,8 @@ exports[`issue-3789-1.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 31 +rangeStart: 17 | | printWidth =====================================input====================================== 1 | export class F { @@ -171,6 +185,8 @@ exports[`issue-3789-2.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 18 +rangeStart: 17 | | printWidth =====================================input====================================== 1 | export class F { @@ -202,6 +218,8 @@ exports[`issue-4206-1.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 30 +rangeStart: 16 | | printWidth =====================================input====================================== > 1 | export default class Foo{ @@ -222,6 +240,8 @@ exports[`issue-4206-2.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 30 +rangeStart: 16 | | printWidth =====================================input====================================== > 1 | export default function Foo(){ @@ -241,6 +261,8 @@ exports[`issue-4206-3.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 28 +rangeStart: 16 | | printWidth =====================================input====================================== > 1 | /* */ function Foo(){ @@ -262,6 +284,8 @@ exports[`issue-4206-4.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 23 +rangeStart: 17 | | printWidth =====================================input====================================== 1 | /* */ class Foo{ @@ -282,6 +306,8 @@ exports[`issue-7082.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 42 +rangeStart: 29 | | printWidth =====================================input====================================== > 1 | export const Button = styled.button\` @@ -302,6 +328,8 @@ exports[`large-dict.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 155 +rangeStart: 80 | | printWidth =====================================input====================================== 1 | function ugly() { @@ -333,6 +361,8 @@ exports[`module-export1.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 56 +rangeStart: 45 | | printWidth =====================================input====================================== 1 | import def , {named} from 'x' @@ -364,6 +394,8 @@ exports[`module-export2.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 79 +rangeStart: 57 | | printWidth =====================================input====================================== 1 | import def , {named} from 'x' @@ -396,6 +428,8 @@ exports[`module-export3.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 108 +rangeStart: 104 | | printWidth =====================================input====================================== 1 | import def , {named} from 'x' @@ -427,6 +461,8 @@ exports[`module-import.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 22 +rangeStart: 7 | | printWidth =====================================input====================================== > 1 | import def , {named} from 'x' @@ -458,6 +494,8 @@ exports[`multiple-statements.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 49 +rangeStart: 30 | | printWidth =====================================input====================================== 1 | call( @@ -501,6 +539,8 @@ exports[`multiple-statements2.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 56 +rangeStart: 18 | | printWidth =====================================input====================================== 1 | call( @@ -548,6 +588,8 @@ exports[`nested.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 37 +rangeStart: 0 | | printWidth =====================================input====================================== > 1 | try { @@ -575,6 +617,8 @@ exports[`nested-print-width.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 110 +rangeStart: 28 | | printWidth =====================================input====================================== 1 | function f() { @@ -600,6 +644,8 @@ exports[`nested2.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 37 +rangeStart: 9 | | printWidth =====================================input====================================== 1 | try { @@ -627,6 +673,8 @@ exports[`nested3.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 37 +rangeStart: 9 | | printWidth =====================================input====================================== 1 | try { @@ -654,6 +702,8 @@ exports[`object-expression.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 14 +rangeStart: 11 | | printWidth =====================================input====================================== > 1 | const y = {a:1, b:2} @@ -669,6 +719,8 @@ exports[`object-expression2.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 104 +rangeStart: 53 | | printWidth =====================================input====================================== 1 | @@ -706,6 +758,8 @@ exports[`range.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 227 +rangeStart: 224 | | printWidth =====================================input====================================== 1 | function ugly ( {a=1, b = 2 } ) { @@ -735,6 +789,8 @@ exports[`range-end.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 50 +rangeStart: 32 | | printWidth =====================================input====================================== 1 | // Unchanged @@ -765,6 +821,8 @@ exports[`range-start.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 18 +rangeStart: 0 | | printWidth =====================================input====================================== > 1 | call( @@ -797,6 +855,8 @@ exports[`try-catch.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 8 +rangeStart: 7 | | printWidth =====================================input====================================== 1 | try {} @@ -814,6 +874,8 @@ exports[`whitespace.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] printWidth: 80 +rangeEnd: 1 +rangeStart: 0 | | printWidth =====================================input====================================== > 1 | diff --git a/tests/json/range/__snapshots__/jsfmt.spec.js.snap b/tests/json/range/__snapshots__/jsfmt.spec.js.snap index 546596f95..53f26719a 100644 --- a/tests/json/range/__snapshots__/jsfmt.spec.js.snap +++ b/tests/json/range/__snapshots__/jsfmt.spec.js.snap @@ -4,6 +4,8 @@ exports[`identifier.json format 1`] = ` ====================================options===================================== parsers: ["json"] printWidth: 80 +rangeEnd: 4 +rangeStart: 1 | | printWidth =====================================input====================================== > 1 | {"a":1, "b":2} @@ -19,6 +21,8 @@ exports[`issue2297.json format 1`] = ` ====================================options===================================== parsers: ["json"] printWidth: 80 +rangeEnd: 6 +rangeStart: 5 | | printWidth =====================================input====================================== > 1 | {"a":1, "b":2} diff --git a/tests/misc/require-pragma/js/__snapshots__/jsfmt.spec.js.snap b/tests/misc/require-pragma/js/__snapshots__/jsfmt.spec.js.snap index 144ab6bbc..db7833334 100644 --- a/tests/misc/require-pragma/js/__snapshots__/jsfmt.spec.js.snap +++ b/tests/misc/require-pragma/js/__snapshots__/jsfmt.spec.js.snap @@ -78,6 +78,8 @@ exports[`range-with-pragma.js - {"requirePragma":true} format 1`] = ` ====================================options===================================== parsers: ["flow", "babel", "typescript"] printWidth: 80 +rangeEnd: 36 +rangeStart: 21 requirePragma: true | | printWidth =====================================input====================================== @@ -100,6 +102,8 @@ exports[`range-without-pragma.js - {"requirePragma":true} format 1`] = ` ====================================options===================================== parsers: ["flow", "babel", "typescript"] printWidth: 80 +rangeEnd: 15 +rangeStart: 0 requirePragma: true | | printWidth =====================================input====================================== diff --git a/tests/typescript/range/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/range/__snapshots__/jsfmt.spec.js.snap index 8adf39df2..e3f995949 100644 --- a/tests/typescript/range/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/range/__snapshots__/jsfmt.spec.js.snap @@ -4,6 +4,8 @@ exports[`export-assignment.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 +rangeEnd: 18 +rangeStart: 15 | | printWidth =====================================input====================================== 1 | f ( ); @@ -23,6 +25,8 @@ exports[`issue-4926.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 +rangeEnd: 304 +rangeStart: 102 | | printWidth =====================================input====================================== 1 | class Foo { @@ -61,6 +65,8 @@ exports[`issue-7148.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 +rangeEnd: 59 +rangeStart: 29 | | printWidth =====================================input====================================== 1 | export default class Test { diff --git a/tests/vue/range/__snapshots__/jsfmt.spec.js.snap b/tests/vue/range/__snapshots__/jsfmt.spec.js.snap index 7bf549559..756e01e7b 100644 --- a/tests/vue/range/__snapshots__/jsfmt.spec.js.snap +++ b/tests/vue/range/__snapshots__/jsfmt.spec.js.snap @@ -4,6 +4,8 @@ exports[`example.vue format 1`] = ` ====================================options===================================== parsers: ["vue"] printWidth: 80 +rangeEnd: 145 +rangeStart: 73 | | printWidth =====================================input====================================== 1 |