From 90cb3c268d4fbb6456975473f3ba7e9b5b3f8798 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 1 Nov 2019 14:49:35 +0800 Subject: [PATCH 01/43] Fix spellcheck script (#6774) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 13a6c3b5a..e7921084a 100644 --- a/package.json +++ b/package.json @@ -128,6 +128,6 @@ "build": "node --max-old-space-size=3072 ./scripts/build/build.js", "build-docs": "node ./scripts/build-docs.js", "check-deps": "node ./scripts/check-deps.js", - "spellcheck": "npx cspell -p cspell@4.0.31 {bin,scripts,src}/**/*.js {docs,website/blog}/**/*.md CHANGELOG.unreleased.md" + "spellcheck": "npx -p cspell@4.0.31 cspell {bin,scripts,src}/**/*.js {docs,website/blog}/**/*.md CHANGELOG.unreleased.md" } } From e66e34a43553dad3c8cd7a4fc29e79552dcec219 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 1 Nov 2019 21:43:12 +0800 Subject: [PATCH 02/43] Update `string-width` to v4 (#6544) --- package.json | 2 +- yarn.lock | 33 ++++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index e7921084a..bfdcd4693 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "remark-parse": "5.0.0", "resolve": "1.12.0", "semver": "6.3.0", - "string-width": "3.1.0", + "string-width": "4.1.0", "typescript": "3.7.1-rc", "unicode-regex": "3.0.0", "unified": "8.4.1", diff --git a/yarn.lock b/yarn.lock index d37a7e146..2b818992c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2528,6 +2528,11 @@ emoji-regex@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.1.tgz#5a132b28ebf84a289ba692862f7d4206ebcd32d0" +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" @@ -3848,6 +3853,11 @@ is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + is-generator-fn@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-1.0.0.tgz#969d49e1bb3329f6bb7f09089be26578b2ddd46a" @@ -6814,14 +6824,14 @@ string-length@^3.1.0: astral-regex "^1.0.0" strip-ansi "^5.2.0" -string-width@3.1.0, string-width@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" - integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== +string-width@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.1.0.tgz#ba846d1daa97c3c596155308063e075ed1c99aff" + integrity sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ== dependencies: - emoji-regex "^7.0.1" - is-fullwidth-code-point "^2.0.0" - strip-ansi "^5.1.0" + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^5.2.0" string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" @@ -6839,6 +6849,15 @@ string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" +string-width@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + string_decoder@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" From ea6ae31ba07e279152fdf1356c4b42b2982a8052 Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Fri, 1 Nov 2019 18:43:03 +0200 Subject: [PATCH 03/43] test: fix a FIXME, add typescript (#6744) * test: fix a FIXME, add typescript * tests/es6modules * tests/no-semi * tests/array_spread --- .../__snapshots__/jsfmt.spec.js.snap | 2 +- tests/array_spread/jsfmt.spec.js | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 160 +----- tests/es6modules/jsfmt.spec.js | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 52 +- tests/jsx_escape/jsfmt.spec.js | 4 +- .../no-semi/__snapshots__/jsfmt.spec.js.snap | 509 +----------------- tests/no-semi/jsfmt.spec.js | 3 +- 8 files changed, 21 insertions(+), 715 deletions(-) diff --git a/tests/array_spread/__snapshots__/jsfmt.spec.js.snap b/tests/array_spread/__snapshots__/jsfmt.spec.js.snap index f9fb0f62c..12ef0c6e6 100644 --- a/tests/array_spread/__snapshots__/jsfmt.spec.js.snap +++ b/tests/array_spread/__snapshots__/jsfmt.spec.js.snap @@ -2,7 +2,7 @@ exports[`multiple.js 1`] = ` ====================================options===================================== -parsers: ["flow", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== diff --git a/tests/array_spread/jsfmt.spec.js b/tests/array_spread/jsfmt.spec.js index a842e1348..eb85eda6b 100644 --- a/tests/array_spread/jsfmt.spec.js +++ b/tests/array_spread/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["flow", "typescript"]); +run_spec(__dirname, ["babel", "flow", "typescript"]); diff --git a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap index 44ea1bf0d..4788c1e67 100644 --- a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap +++ b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap @@ -2,21 +2,7 @@ exports[`export_default_arrow_expression.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default () => {}; - -=====================================output===================================== -export default () => {}; - -================================================================================ -`; - -exports[`export_default_arrow_expression.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -30,21 +16,7 @@ export default () => {}; exports[`export_default_call_expression.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default foo() - -=====================================output===================================== -export default foo(); - -================================================================================ -`; - -exports[`export_default_call_expression.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -58,21 +30,7 @@ export default foo(); exports[`export_default_class_declaration.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default class Foo {} - -=====================================output===================================== -export default class Foo {} - -================================================================================ -`; - -exports[`export_default_class_declaration.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -86,21 +44,7 @@ export default class Foo {} exports[`export_default_class_expression.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default (class foobar {}) - -=====================================output===================================== -export default (class foobar {}); - -================================================================================ -`; - -exports[`export_default_class_expression.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -114,21 +58,7 @@ export default (class foobar {}); exports[`export_default_function_declaration.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default function() {} - -=====================================output===================================== -export default function() {} - -================================================================================ -`; - -exports[`export_default_function_declaration.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -142,21 +72,7 @@ export default function() {} exports[`export_default_function_declaration_async.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default async function foo() {} - -=====================================output===================================== -export default async function foo() {} - -================================================================================ -`; - -exports[`export_default_function_declaration_async.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -170,21 +86,7 @@ export default async function foo() {} exports[`export_default_function_declaration_named.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default function f(){} - -=====================================output===================================== -export default function f() {} - -================================================================================ -`; - -exports[`export_default_function_declaration_named.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -198,21 +100,7 @@ export default function f() {} exports[`export_default_function_expression.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default (function() {}); - -=====================================output===================================== -export default (function() {}); - -================================================================================ -`; - -exports[`export_default_function_expression.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -226,21 +114,7 @@ export default (function() {}); exports[`export_default_function_expression_named.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default (function f(){}) - -=====================================output===================================== -export default (function f() {}); - -================================================================================ -`; - -exports[`export_default_function_expression_named.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -254,21 +128,7 @@ export default (function f() {}); exports[`export_default_new_expression.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -export default new Foo(); - -=====================================output===================================== -export default new Foo(); - -================================================================================ -`; - -exports[`export_default_new_expression.js 2`] = ` -====================================options===================================== -parsers: ["babel", "typescript"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== diff --git a/tests/es6modules/jsfmt.spec.js b/tests/es6modules/jsfmt.spec.js index 9d2f08ad0..eb85eda6b 100644 --- a/tests/es6modules/jsfmt.spec.js +++ b/tests/es6modules/jsfmt.spec.js @@ -1,3 +1 @@ -run_spec(__dirname, ["flow"]); -// FIXME export_default_function_declaration_async.js flow != babel output -run_spec(__dirname, ["babel", "typescript"]); +run_spec(__dirname, ["babel", "flow", "typescript"]); diff --git a/tests/jsx_escape/__snapshots__/jsfmt.spec.js.snap b/tests/jsx_escape/__snapshots__/jsfmt.spec.js.snap index b43f585dc..881ea7cd9 100644 --- a/tests/jsx_escape/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx_escape/__snapshots__/jsfmt.spec.js.snap @@ -2,21 +2,7 @@ exports[`escape.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -
<
- -=====================================output===================================== -
<
; - -================================================================================ -`; - -exports[`escape.js 2`] = ` -====================================options===================================== -parsers: ["babel"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== @@ -30,41 +16,7 @@ printWidth: 80 exports[`nbsp.js 1`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 - | printWidth -=====================================input====================================== -many_nbsp =
   
-single_nbsp =
 
-nbsp_with_newline = -
-   -
- -many_raw_nbsp =
   
-many_raw_spaces =
- - -amp = foo & bar -raw_amp = foo & bar - -=====================================output===================================== -many_nbsp =
   
; -single_nbsp =
 
; -nbsp_with_newline =
 
; - -many_raw_nbsp =
   
; -many_raw_spaces =
; - -amp = foo & bar; -raw_amp = foo & bar; - -================================================================================ -`; - -exports[`nbsp.js 2`] = ` -====================================options===================================== -parsers: ["babel"] +parsers: ["babel", "flow", "typescript"] printWidth: 80 | printWidth =====================================input====================================== diff --git a/tests/jsx_escape/jsfmt.spec.js b/tests/jsx_escape/jsfmt.spec.js index 52f49c4f6..eb85eda6b 100644 --- a/tests/jsx_escape/jsfmt.spec.js +++ b/tests/jsx_escape/jsfmt.spec.js @@ -1,3 +1 @@ -run_spec(__dirname, ["flow"]); -// FIXME nbsp.js flow != babel output, waiting for: https://github.com/babel/babylon/pull/344 -run_spec(__dirname, ["babel"]); +run_spec(__dirname, ["babel", "flow", "typescript"]); diff --git a/tests/no-semi/__snapshots__/jsfmt.spec.js.snap b/tests/no-semi/__snapshots__/jsfmt.spec.js.snap index e0278222d..c4d85ea56 100644 --- a/tests/no-semi/__snapshots__/jsfmt.spec.js.snap +++ b/tests/no-semi/__snapshots__/jsfmt.spec.js.snap @@ -36,42 +36,7 @@ x; exports[`comments.js 2`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 -semi: false - | printWidth -=====================================input====================================== -let error = new Error(response.statusText); -// comment -(error: any).response = response - -x; - -/* comment */ (error: any).response = response - -x; - -(error: any).response = response; /* comment */ - -=====================================output===================================== -let error = new Error(response.statusText) -// comment -;(error: any).response = response - -x - -/* comment */ ;(error: any).response = response - -x - -;(error: any).response = response /* comment */ - -================================================================================ -`; - -exports[`comments.js 3`] = ` -====================================options===================================== -parsers: ["babel"] +parsers: ["babel", "flow"] printWidth: 80 semi: false | printWidth @@ -191,93 +156,7 @@ interface E { exports[`flow-interfaces.js 2`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 -semi: false - | printWidth -=====================================input====================================== -declare class A { - one: boolean; - two: { three: string } - | number; -} - -// NOTE: Flow and Babel both fail to apply ASI here -// declare class B { -// one: boolean -// two: { three: string } -// | number -// } - -declare interface C { - one: boolean; - two: { three: string } - | number; -} - -// NOTE: Flow and Babel both fail to apply ASI here -// declare interface D { -// one: boolean -// two: { three: string } -// | number -// } - -interface E { - one: boolean; - two: { three: string } - | number; -} - -// NOTE: Flow and Babel both fail to apply ASI here -// interface F { -// one: boolean -// two: { three: string } -// | number -// } - -=====================================output===================================== -declare class A { - one: boolean; - two: { three: string } | number; -} - -// NOTE: Flow and Babel both fail to apply ASI here -// declare class B { -// one: boolean -// two: { three: string } -// | number -// } - -declare interface C { - one: boolean; - two: { three: string } | number; -} - -// NOTE: Flow and Babel both fail to apply ASI here -// declare interface D { -// one: boolean -// two: { three: string } -// | number -// } - -interface E { - one: boolean; - two: { three: string } | number; -} - -// NOTE: Flow and Babel both fail to apply ASI here -// interface F { -// one: boolean -// two: { three: string } -// | number -// } - -================================================================================ -`; - -exports[`flow-interfaces.js 3`] = ` -====================================options===================================== -parsers: ["babel"] +parsers: ["babel", "flow"] printWidth: 80 semi: false | printWidth @@ -391,36 +270,7 @@ var c = a.e; exports[`issue2006.js 2`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 -semi: false - | printWidth -=====================================input====================================== -switch (n) { - case 11: - var c = a.e; - (i.a += Ga(c.e)), F(i, c.i, 0); -} - -var c = a.e; -(i.a += Ga(c.e)), F(i, c.i, 0); - -=====================================output===================================== -switch (n) { - case 11: - var c = a.e - ;(i.a += Ga(c.e)), F(i, c.i, 0) -} - -var c = a.e -;(i.a += Ga(c.e)), F(i, c.i, 0) - -================================================================================ -`; - -exports[`issue2006.js 3`] = ` -====================================options===================================== -parsers: ["babel"] +parsers: ["babel", "flow"] printWidth: 80 semi: false | printWidth @@ -799,358 +649,7 @@ aReallyLongLine012345678901234567890123456789012345678901234567890123456789 * exports[`no-semi.js 2`] = ` ====================================options===================================== -parsers: ["flow"] -printWidth: 80 -semi: false - | printWidth -=====================================input====================================== - -// with preexisting semi - -x; [1, 2, 3].forEach(fn) -x; [a, b, ...c] = [1, 2] -x; /r/i.test('r') -x; +1 -x; - 1 -x; ('h' + 'i').repeat(10) -x; (1, 2) -x; (() => {})() -x; ({ a: 1 }).entries() -x; ({ a: 1 }).entries() -x; -x; \`string\` -x; (x, y) => x - -// doesn't have to be preceded by a semicolon - -class X {} [1, 2, 3].forEach(fn) - -// TODO: upgrade parser -// class A { -// async; // The semicolon is *not* necessary -// x(){} -// } -// class B { -// static; // The semicolon *is* necessary -// x(){} -// } - -class C1 { - get; // The semicolon *is* necessary - x(){} -} -class C2 { - get = () => {}; // The semicolon is *not* necessary - x(){} -} -class C3 { - set; // The semicolon *is* necessary - x(){} -} -class C4 { - set = () => {}; // The semicolon is *not* necessary - x(){} -} - - -// don't semicolon if it doesn't start statement - -if (true) (() => {})() - -class A { - a = 0; - [b](){} - - c = 0; - *d(){} - - e = 0; - [f] = 0 - - // none of the semicolons above this comment can be omitted. - // none of the semicolons below this comment are necessary. - - q() {}; - [h](){} - - p() {}; - *i(){} - - a = 1; - get ['y']() {} - - a = 1; - static ['y']() {} - - a = 1; - set ['z'](z) {} - - a = 1; - async ['a']() {} - - a = 1; - async *g() {} - - a = 0; - b = 1; -} - -// being first/last shouldn't break things -class G1 { - x = 1 -} -class G2 { - x() {} -} -class G3 { - *x() {} -} -class G4 { - [x] = 1 -} - -// check indentation - -if (true) { - x; (() => {})() -} - -// flow - -(x: void); -(y: void) - -// check statement clauses - -do break; while (false) -if (true) do break; while (false) - -if (true) 1; else 2 -for (;;) ; -for (x of y) ; - -debugger - -// check that it doesn't break non-ASI - -1 -- 1 - -1 -+ 1 - -1 -/ 1 - -arr -[0] - -fn -(x) - -!1 - -1 -< 1 - -tag -\`string\` - -x; x => x - -x; (a || b).c++ - -x; ++(a || b).c - -while (false) - (function(){}()) - -aReallyLongLine012345678901234567890123456789012345678901234567890123456789 * - (b + c) - -=====================================output===================================== -// with preexisting semi - -x -;[1, 2, 3].forEach(fn) -x -;[a, b, ...c] = [1, 2] -x -;/r/i.test("r") -x -;+1 -x -;-1 -x -;("h" + "i").repeat(10) -x -1, 2 -x -;(() => {})() -x -;({ a: 1 }.entries()) -x -;({ a: 1 }.entries()) -x -; -x -;\`string\` -x -;(x, y) => x - -// doesn't have to be preceded by a semicolon - -class X {} -;[1, 2, 3].forEach(fn) - -// TODO: upgrade parser -// class A { -// async; // The semicolon is *not* necessary -// x(){} -// } -// class B { -// static; // The semicolon *is* necessary -// x(){} -// } - -class C1 { - get; // The semicolon *is* necessary - x() {} -} -class C2 { - get = () => {} // The semicolon is *not* necessary - x() {} -} -class C3 { - set; // The semicolon *is* necessary - x() {} -} -class C4 { - set = () => {} // The semicolon is *not* necessary - x() {} -} - -// don't semicolon if it doesn't start statement - -if (true) (() => {})() - -class A { - a = 0; - [b]() {} - - c = 0; - *d() {} - - e = 0; - [f] = 0 - - // none of the semicolons above this comment can be omitted. - // none of the semicolons below this comment are necessary. - - q() {} - [h]() {} - - p() {} - *i() {} - - a = 1 - get ["y"]() {} - - a = 1 - static ["y"]() {} - - a = 1 - set ["z"](z) {} - - a = 1 - async ["a"]() {} - - a = 1 - async *g() {} - - a = 0 - b = 1 -} - -// being first/last shouldn't break things -class G1 { - x = 1 -} -class G2 { - x() {} -} -class G3 { - *x() {} -} -class G4 { - [x] = 1 -} - -// check indentation - -if (true) { - x - ;(() => {})() -} - -// flow - -;(x: void) -;(y: void) - -// check statement clauses - -do break -while (false) -if (true) - do break - while (false) - -if (true) 1 -else 2 -for (;;); -for (x of y); - -debugger - -// check that it doesn't break non-ASI - -1 - 1 - -1 + 1 - -1 / 1 - -arr[0] - -fn(x) - -!1 - -1 < 1 - -tag\`string\` - -x -x => x - -x -;(a || b).c++ - -x -++(a || b).c - -while (false) (function() {})() - -aReallyLongLine012345678901234567890123456789012345678901234567890123456789 * - (b + c) - -================================================================================ -`; - -exports[`no-semi.js 3`] = ` -====================================options===================================== -parsers: ["babel"] +parsers: ["babel", "flow"] printWidth: 80 semi: false | printWidth diff --git a/tests/no-semi/jsfmt.spec.js b/tests/no-semi/jsfmt.spec.js index 4adcd58fa..83f146c82 100644 --- a/tests/no-semi/jsfmt.spec.js +++ b/tests/no-semi/jsfmt.spec.js @@ -1,3 +1,2 @@ run_spec(__dirname, ["flow"]); -run_spec(__dirname, ["flow"], { semi: false }); -run_spec(__dirname, ["babel"], { semi: false }); +run_spec(__dirname, ["babel", "flow"], { semi: false }); From 159566798d37db42b8138ee4ecabb2ba32defc31 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sat, 2 Nov 2019 01:02:34 +0800 Subject: [PATCH 04/43] Move `multiple-patterns` tests to `patterns` (#6777) --- ...iple-patterns.js.snap => patterns.js.snap} | 0 .../{multiple-patterns.js => patterns.js} | 26 +++++++------------ .../directory/file.js | 0 .../nested-directory/nested-directory-file.js | 0 .../node_modules/node-module.js | 0 .../other-directory/file.js | 0 .../nested-directory/nested-directory-file.js | 0 .../other-regular-modules.js | 0 .../regular-module.js | 0 9 files changed, 10 insertions(+), 16 deletions(-) rename tests_integration/__tests__/__snapshots__/{multiple-patterns.js.snap => patterns.js.snap} (100%) rename tests_integration/__tests__/{multiple-patterns.js => patterns.js} (73%) rename tests_integration/cli/{multiple-patterns => patterns}/directory/file.js (100%) rename tests_integration/cli/{multiple-patterns => patterns}/directory/nested-directory/nested-directory-file.js (100%) rename tests_integration/cli/{multiple-patterns => patterns}/node_modules/node-module.js (100%) rename tests_integration/cli/{multiple-patterns => patterns}/other-directory/file.js (100%) rename tests_integration/cli/{multiple-patterns => patterns}/other-directory/nested-directory/nested-directory-file.js (100%) rename tests_integration/cli/{multiple-patterns => patterns}/other-regular-modules.js (100%) rename tests_integration/cli/{multiple-patterns => patterns}/regular-module.js (100%) diff --git a/tests_integration/__tests__/__snapshots__/multiple-patterns.js.snap b/tests_integration/__tests__/__snapshots__/patterns.js.snap similarity index 100% rename from tests_integration/__tests__/__snapshots__/multiple-patterns.js.snap rename to tests_integration/__tests__/__snapshots__/patterns.js.snap diff --git a/tests_integration/__tests__/multiple-patterns.js b/tests_integration/__tests__/patterns.js similarity index 73% rename from tests_integration/__tests__/multiple-patterns.js rename to tests_integration/__tests__/patterns.js index 008c3952f..c51132b69 100644 --- a/tests_integration/__tests__/multiple-patterns.js +++ b/tests_integration/__tests__/patterns.js @@ -5,7 +5,7 @@ const runPrettier = require("../runPrettier"); expect.addSnapshotSerializer(require("../path-serializer")); describe("multiple patterns", () => { - runPrettier("cli/multiple-patterns", [ + runPrettier("cli/patterns", [ "directory/**/*.js", "other-directory/**/*.js", "-l" @@ -15,7 +15,7 @@ describe("multiple patterns", () => { }); describe("multiple patterns with non exists pattern", () => { - runPrettier("cli/multiple-patterns", [ + runPrettier("cli/patterns", [ "directory/**/*.js", "non-existent.js", "-l" @@ -25,7 +25,7 @@ describe("multiple patterns with non exists pattern", () => { }); describe("multiple patterns with ignore nested directories pattern", () => { - runPrettier("cli/multiple-patterns", [ + runPrettier("cli/patterns", [ "**/*.js", "!**/nested-directory/**", "-l" @@ -35,25 +35,19 @@ describe("multiple patterns with ignore nested directories pattern", () => { }); describe("multiple patterns by with ignore pattern, ignores node_modules by default", () => { - runPrettier("cli/multiple-patterns", ["**/*.js", "!directory/**", "-l"]).test( - { - status: 1 - } - ); + runPrettier("cli/patterns", ["**/*.js", "!directory/**", "-l"]).test({ + status: 1 + }); }); describe("multiple patterns by with ignore pattern, ignores node_modules by with ./**/*.js", () => { - runPrettier("cli/multiple-patterns", [ - "./**/*.js", - "!./directory/**", - "-l" - ]).test({ + runPrettier("cli/patterns", ["./**/*.js", "!./directory/**", "-l"]).test({ status: 1 }); }); describe("multiple patterns by with ignore pattern, doesn't ignore node_modules with --with-node-modules flag", () => { - runPrettier("cli/multiple-patterns", [ + runPrettier("cli/patterns", [ "**/*.js", "!directory/**", "-l", @@ -65,13 +59,13 @@ describe("multiple patterns by with ignore pattern, doesn't ignore node_modules describe("no errors on empty patterns", () => { // --parser is mandatory if no filepath is passed - runPrettier("cli/multiple-patterns", ["--parser", "babel"]).test({ + runPrettier("cli/patterns", ["--parser", "babel"]).test({ status: 0 }); }); describe("multiple patterns, throw error and exit with non zero code on non existing files", () => { - runPrettier("cli/multiple-patterns", [ + runPrettier("cli/patterns", [ "non-existent.js", "other-non-existent.js", "-l" diff --git a/tests_integration/cli/multiple-patterns/directory/file.js b/tests_integration/cli/patterns/directory/file.js similarity index 100% rename from tests_integration/cli/multiple-patterns/directory/file.js rename to tests_integration/cli/patterns/directory/file.js diff --git a/tests_integration/cli/multiple-patterns/directory/nested-directory/nested-directory-file.js b/tests_integration/cli/patterns/directory/nested-directory/nested-directory-file.js similarity index 100% rename from tests_integration/cli/multiple-patterns/directory/nested-directory/nested-directory-file.js rename to tests_integration/cli/patterns/directory/nested-directory/nested-directory-file.js diff --git a/tests_integration/cli/multiple-patterns/node_modules/node-module.js b/tests_integration/cli/patterns/node_modules/node-module.js similarity index 100% rename from tests_integration/cli/multiple-patterns/node_modules/node-module.js rename to tests_integration/cli/patterns/node_modules/node-module.js diff --git a/tests_integration/cli/multiple-patterns/other-directory/file.js b/tests_integration/cli/patterns/other-directory/file.js similarity index 100% rename from tests_integration/cli/multiple-patterns/other-directory/file.js rename to tests_integration/cli/patterns/other-directory/file.js diff --git a/tests_integration/cli/multiple-patterns/other-directory/nested-directory/nested-directory-file.js b/tests_integration/cli/patterns/other-directory/nested-directory/nested-directory-file.js similarity index 100% rename from tests_integration/cli/multiple-patterns/other-directory/nested-directory/nested-directory-file.js rename to tests_integration/cli/patterns/other-directory/nested-directory/nested-directory-file.js diff --git a/tests_integration/cli/multiple-patterns/other-regular-modules.js b/tests_integration/cli/patterns/other-regular-modules.js similarity index 100% rename from tests_integration/cli/multiple-patterns/other-regular-modules.js rename to tests_integration/cli/patterns/other-regular-modules.js diff --git a/tests_integration/cli/multiple-patterns/regular-module.js b/tests_integration/cli/patterns/regular-module.js similarity index 100% rename from tests_integration/cli/multiple-patterns/regular-module.js rename to tests_integration/cli/patterns/regular-module.js From a28e5c94c41254f2d88268a488e22ce0e9cab022 Mon Sep 17 00:00:00 2001 From: Mary Date: Sat, 2 Nov 2019 04:17:13 -0400 Subject: [PATCH 05/43] prettier-emacs is actually prettier-js-mode (#6653) --- website/data/editors.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/data/editors.yml b/website/data/editors.yml index b84140d74..5b0fd1b31 100644 --- a/website/data/editors.yml +++ b/website/data/editors.yml @@ -7,7 +7,7 @@ - image: "/images/editors/editor_emacs.svg" name: Emacs content: | - [`prettier-emacs`](https://github.com/prettier/prettier-emacs) + [`prettier-js`](https://github.com/prettier/prettier-emacs) - image: /images/editors/editor_espresso.svg name: Espresso content: | From cf32f29d413fa90d6ffd0de4c9065e01b2b0bd7d Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sat, 2 Nov 2019 17:39:18 +0900 Subject: [PATCH 06/43] Flow: Keep parentheses wrap specific FunctionTypeAnnotation (#6717) Co-Authored-By: Georgii Dolzhykov --- CHANGELOG.unreleased.md | 16 ++++ src/language-js/needs-parens.js | 19 +++- src/language-js/utils.js | 1 + .../__snapshots__/jsfmt.spec.js.snap | 86 +++++++++++++++++-- tests/flow_return_arrow/in_object_type.js | 28 ++++++ tests/flow_return_arrow/parens.js | 9 +- 6 files changed, 146 insertions(+), 13 deletions(-) create mode 100644 tests/flow_return_arrow/in_object_type.js diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index f2d831d03..2683766fb 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -1294,6 +1294,21 @@ export class User { } ``` +#### Flow: Parentheses around arrow functions' return types that have `FunctionTypeAnnotation` nested in `ObjectTypeAnnotation` ([#6717] by [@sosukesuzuki]) + +This is a workaround for a [bug](https://github.com/facebook/flow/pull/8163) in the Flow parser. Without the parentheses, the parser throws an error. + +```js +// Input +const example1 = (): { p: (string => string) } => (0: any); + +// Output (Prettier stable) +const example1 = (): { p: string => string } => (0: any); + +// Output (Prettier master) +const example1 = (): ({ p: string => string }) => (0: any); +``` + [#5682]: https://github.com/prettier/prettier/pull/5682 [#6657]: https://github.com/prettier/prettier/pull/6657 [#5910]: https://github.com/prettier/prettier/pull/5910 @@ -1336,6 +1351,7 @@ export class User { [#6673]: https://github.com/prettier/prettier/pull/6673 [#6695]: https://github.com/prettier/prettier/pull/6695 [#6694]: https://github.com/prettier/prettier/pull/6694 +[#6717]: https://github.com/prettier/prettier/pull/6717 [#6728]: https://github.com/prettier/prettier/pull/6728 [@brainkim]: https://github.com/brainkim [@duailibe]: https://github.com/duailibe diff --git a/src/language-js/needs-parens.js b/src/language-js/needs-parens.js index d82016761..5dafb312d 100644 --- a/src/language-js/needs-parens.js +++ b/src/language-js/needs-parens.js @@ -7,7 +7,8 @@ const comments = require("./comments"); const { getLeftSidePathName, hasFlowShorthandAnnotationComment, - hasNakedLeftSide + hasNakedLeftSide, + hasNode } = require("./utils"); function hasClosureCompilerTypeCastComment(text, path) { @@ -758,6 +759,12 @@ function needsParens(path, options) { parent.type !== "TypeCastExpression" && parent.type !== "VariableDeclarator") ); + case "TypeAnnotation": + return ( + name === "returnType" && + parent.type === "ArrowFunctionExpression" && + includesFunctionTypeInObjectType(node) + ); } return false; @@ -814,6 +821,16 @@ function isStatement(node) { ); } +function includesFunctionTypeInObjectType(node) { + return hasNode( + node, + n1 => + (n1.type === "ObjectTypeAnnotation" && + hasNode(n1, n2 => n2.type === "FunctionTypeAnnotation" || undefined)) || + undefined + ); +} + function endsWithRightBracket(node) { switch (node.type) { case "ObjectExpression": diff --git a/src/language-js/utils.js b/src/language-js/utils.js index 245f84ddd..6fb301d56 100644 --- a/src/language-js/utils.js +++ b/src/language-js/utils.js @@ -912,6 +912,7 @@ module.exports = { hasNakedLeftSide, hasNewlineBetweenOrAfterDecorators, hasNgSideEffect, + hasNode, hasPrettierIgnore, hasTrailingComment, identity, diff --git a/tests/flow_return_arrow/__snapshots__/jsfmt.spec.js.snap b/tests/flow_return_arrow/__snapshots__/jsfmt.spec.js.snap index 43b5dee43..e5140a7e3 100644 --- a/tests/flow_return_arrow/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow_return_arrow/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,73 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`in_object_type.js 1`] = ` +====================================options===================================== +parsers: ["flow"] +printWidth: 80 + | printWidth +=====================================input====================================== +const example1 = (): ({ p: string => string }) => (0: any); +const example2 = (): ({ p: { p: string => string } }) => (0: any); +const example3 = (): ({ p: { p: { p: string => string } } }) => (0: any); +const example4 = (): ({ p: { p: ?{ p: string => string } } }) => (0: any); +const example5 = (): ({ p: { p: { p: string => string } | string } }) => + (0: any); +const example6 = (): ({ p: { p: { p: string => string } & string } }) => + (0: any); +const example7 = (): ({ p: { p: { p: [(string) => string, string] } } }) => + (0: any); +function example8(): { p: string => string } { + return (0: any); +} +function example9(): { p: { p: string => string } } { + return (0: any); +} +function example10(): { p: { p: { p: string => string } } } { + return (0: any); +} +const example11 = (): ({ p: string => string } & string) => (0: any); +const example12 = (): ({ p: string => string } | string) => (0: any); +const example13 = (): ([{ p: string => string }, string]) => (0: any); +const example14 = (): ({ p: string => string }[]) => (0: any); +const example15 = (): ({ p: { p: { p: (string => string) & string } } }) => + (0: any); +const example16 = (): ({ p: { p: { p: (string => string) | string } } }) => + (0: any); +const example17 = (): (?{ p: string => string }) => (0: any); + +=====================================output===================================== +const example1 = (): ({ p: string => string }) => (0: any); +const example2 = (): ({ p: { p: string => string } }) => (0: any); +const example3 = (): ({ p: { p: { p: string => string } } }) => (0: any); +const example4 = (): ({ p: { p: ?{ p: string => string } } }) => (0: any); +const example5 = (): ({ p: { p: { p: string => string } | string } }) => + (0: any); +const example6 = (): ({ p: { p: { p: string => string } & string } }) => + (0: any); +const example7 = (): ({ p: { p: { p: [(string) => string, string] } } }) => + (0: any); +function example8(): { p: string => string } { + return (0: any); +} +function example9(): { p: { p: string => string } } { + return (0: any); +} +function example10(): { p: { p: { p: string => string } } } { + return (0: any); +} +const example11 = (): ({ p: string => string } & string) => (0: any); +const example12 = (): ({ p: string => string } | string) => (0: any); +const example13 = (): ([{ p: string => string }, string]) => (0: any); +const example14 = (): ({ p: string => string }[]) => (0: any); +const example15 = (): ({ p: { p: { p: (string => string) & string } } }) => + (0: any); +const example16 = (): ({ p: { p: { p: (string => string) | string } } }) => + (0: any); +const example17 = (): (?{ p: string => string }) => (0: any); + +================================================================================ +`; + exports[`issue-1249.js 1`] = ` ====================================options===================================== parsers: ["flow"] @@ -60,16 +128,18 @@ parsers: ["flow"] printWidth: 80 | printWidth =====================================input====================================== -const f = (): (string => string) => {}; -const f = (): (a | string => string) => {}; -const f = (): (a & string => string) => {}; -function f(): string => string {} +const f1 = (): (string => string) => {}; +const f2 = (): ?(y => {a: b => c}) => (0: any); +const f3 = (): (a | string => string) => {}; +const f4 = (): (a & string => string) => {}; +function f5(): string => string {} =====================================output===================================== -const f = (): (string => string) => {}; -const f = (): a | (string => string) => {}; -const f = (): a & (string => string) => {}; -function f(): string => string {} +const f1 = (): (string => string) => {}; +const f2 = (): (?(y) => { a: b => c }) => (0: any); +const f3 = (): a | (string => string) => {}; +const f4 = (): a & (string => string) => {}; +function f5(): string => string {} ================================================================================ `; diff --git a/tests/flow_return_arrow/in_object_type.js b/tests/flow_return_arrow/in_object_type.js new file mode 100644 index 000000000..f94c1cd6a --- /dev/null +++ b/tests/flow_return_arrow/in_object_type.js @@ -0,0 +1,28 @@ +const example1 = (): ({ p: string => string }) => (0: any); +const example2 = (): ({ p: { p: string => string } }) => (0: any); +const example3 = (): ({ p: { p: { p: string => string } } }) => (0: any); +const example4 = (): ({ p: { p: ?{ p: string => string } } }) => (0: any); +const example5 = (): ({ p: { p: { p: string => string } | string } }) => + (0: any); +const example6 = (): ({ p: { p: { p: string => string } & string } }) => + (0: any); +const example7 = (): ({ p: { p: { p: [(string) => string, string] } } }) => + (0: any); +function example8(): { p: string => string } { + return (0: any); +} +function example9(): { p: { p: string => string } } { + return (0: any); +} +function example10(): { p: { p: { p: string => string } } } { + return (0: any); +} +const example11 = (): ({ p: string => string } & string) => (0: any); +const example12 = (): ({ p: string => string } | string) => (0: any); +const example13 = (): ([{ p: string => string }, string]) => (0: any); +const example14 = (): ({ p: string => string }[]) => (0: any); +const example15 = (): ({ p: { p: { p: (string => string) & string } } }) => + (0: any); +const example16 = (): ({ p: { p: { p: (string => string) | string } } }) => + (0: any); +const example17 = (): (?{ p: string => string }) => (0: any); diff --git a/tests/flow_return_arrow/parens.js b/tests/flow_return_arrow/parens.js index b944ca314..5b7a5243c 100644 --- a/tests/flow_return_arrow/parens.js +++ b/tests/flow_return_arrow/parens.js @@ -1,4 +1,5 @@ -const f = (): (string => string) => {}; -const f = (): (a | string => string) => {}; -const f = (): (a & string => string) => {}; -function f(): string => string {} +const f1 = (): (string => string) => {}; +const f2 = (): ?(y => {a: b => c}) => (0: any); +const f3 = (): (a | string => string) => {}; +const f4 = (): (a & string => string) => {}; +function f5(): string => string {} From e50ad942b7345caa78a681038949c6c7f99f22a3 Mon Sep 17 00:00:00 2001 From: Chris Brody Date: Sat, 2 Nov 2019 04:44:27 -0400 Subject: [PATCH 07/43] Start JSDoc type linting (#6770) Co-Authored-By: Christopher J. Brody Co-Authored-By: Christopher Quadflieg Co-Authored-By: Georgii Dolzhykov --- .azure-pipelines/jobs/dev-lint.yml | 2 + package.json | 1 + src/doc/doc-builders.js | 74 ++++++++++++++++++++++++++++++ src/doc/doc-printer.js | 2 +- tsconfig.json | 51 ++++++++++++++++++++ 5 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 tsconfig.json diff --git a/.azure-pipelines/jobs/dev-lint.yml b/.azure-pipelines/jobs/dev-lint.yml index 9cc89acf6..76f4fd4f3 100644 --- a/.azure-pipelines/jobs/dev-lint.yml +++ b/.azure-pipelines/jobs/dev-lint.yml @@ -3,6 +3,8 @@ steps: - template: ../steps/install-dependencies.yml - script: yarn check-deps displayName: "Check dependencies" + - script: yarn check-types + displayName: "Check JSDoc types" - script: yarn lint displayName: "Lint code" - script: yarn lint-docs diff --git a/package.json b/package.json index bfdcd4693..e9fbd11b1 100644 --- a/package.json +++ b/package.json @@ -122,6 +122,7 @@ "perf-repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null", "perf-repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null", "perf-benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null", + "check-types": "tsc", "lint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly", "lint-docs": "prettylint {.,docs,website,website/blog}/*.md", "lint-dist": "eslint --no-eslintrc --no-ignore --env=browser \"dist/!(bin-prettier|index|third-party).js\"", diff --git a/src/doc/doc-builders.js b/src/doc/doc-builders.js index 6965fc580..3c005c65f 100644 --- a/src/doc/doc-builders.js +++ b/src/doc/doc-builders.js @@ -1,5 +1,19 @@ "use strict"; +/** + * TBD properly tagged union for Doc object type is needed here. + * + * @typedef {object} DocObject + * @property {string} type + * @property {boolean} [hard] + * @property {boolean} [literal] + * + * @typedef {string | DocObject} Doc + */ + +/** + * @param {Doc} val + */ function assertDoc(val) { /* istanbul ignore if */ if ( @@ -11,6 +25,10 @@ function assertDoc(val) { } } +/** + * @param {Doc[]} parts + * @returns Doc + */ function concat(parts) { if (process.env.NODE_ENV !== "production") { parts.forEach(assertDoc); @@ -25,6 +43,10 @@ function concat(parts) { return { type: "concat", parts }; } +/** + * @param {Doc} contents + * @returns Doc + */ function indent(contents) { if (process.env.NODE_ENV !== "production") { assertDoc(contents); @@ -33,6 +55,11 @@ function indent(contents) { return { type: "indent", contents }; } +/** + * @param {number} n + * @param {Doc} contents + * @returns Doc + */ function align(n, contents) { if (process.env.NODE_ENV !== "production") { assertDoc(contents); @@ -41,6 +68,11 @@ function align(n, contents) { return { type: "align", contents, n }; } +/** + * @param {Doc} contents + * @param {object} [opts] - TBD ??? + * @returns Doc + */ function group(contents, opts) { opts = opts || {}; @@ -57,18 +89,36 @@ function group(contents, opts) { }; } +/** + * @param {Doc} contents + * @returns Doc + */ function dedentToRoot(contents) { return align(-Infinity, contents); } +/** + * @param {Doc} contents + * @returns Doc + */ function markAsRoot(contents) { + // @ts-ignore - TBD ???: return align({ type: "root" }, contents); } +/** + * @param {Doc} contents + * @returns Doc + */ function dedent(contents) { return align(-1, contents); } +/** + * @param {Doc[]} states + * @param {object} [opts] - TBD ??? + * @returns Doc + */ function conditionalGroup(states, opts) { return group( states[0], @@ -76,6 +126,10 @@ function conditionalGroup(states, opts) { ); } +/** + * @param {Doc[]} parts + * @returns Doc + */ function fill(parts) { if (process.env.NODE_ENV !== "production") { parts.forEach(assertDoc); @@ -84,6 +138,12 @@ function fill(parts) { return { type: "fill", parts }; } +/** + * @param {Doc} [breakContents] + * @param {Doc} [flatContents] + * @param {object} [opts] - TBD ??? + * @returns Doc + */ function ifBreak(breakContents, flatContents, opts) { opts = opts || {}; @@ -104,6 +164,10 @@ function ifBreak(breakContents, flatContents, opts) { }; } +/** + * @param {Doc} contents + * @returns Doc + */ function lineSuffix(contents) { if (process.env.NODE_ENV !== "production") { assertDoc(contents); @@ -123,6 +187,11 @@ const literalline = concat([ ]); const cursor = { type: "cursor", placeholder: Symbol("cursor") }; +/** + * @param {Doc} sep + * @param {Doc[]} arr + * @returns Doc + */ function join(sep, arr) { const res = []; @@ -137,6 +206,11 @@ function join(sep, arr) { return concat(res); } +/** + * @param {Doc} doc + * @param {number} size + * @param {number} tabWidth + */ function addAlignmentToDoc(doc, size, tabWidth) { let aligned = doc; if (size > 0) { diff --git a/src/doc/doc-printer.js b/src/doc/doc-printer.js index 65e1096cf..0a13f7eda 100644 --- a/src/doc/doc-printer.js +++ b/src/doc/doc-printer.js @@ -4,7 +4,7 @@ const { getStringWidth } = require("../common/util"); const { convertEndOfLineToChars } = require("../common/end-of-line"); const { concat, fill, cursor } = require("./doc-builders"); -/** @type {{[groupId: PropertyKey]: MODE}} */ +/** @type {Record} */ let groupModeMap; const MODE_BREAK = 1; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..8e58946ee --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,51 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "noEmit": true, + "target": "es5", + "module": "commonjs", + "resolveJsonModule": true, + // TBD it is desired to enabled strict type checking at some point: + "strict": false + }, + "exclude": [ + // [TBD] JavaScript sources *not* affected by src/language-*: + "src/main/ast-to-doc.js", + "src/main/core.js", + "src/common/create-ignorer.js", + "src/common/parser-create-error.js", + "src/config/resolve-config.js", + "src/main/options-normalizer.js", + "src/common/get-file-info.js", + "src/main/multiparser.js", + "src/main/options.js", + // [TBD] src/language-* source directory trees with known JSDoc type issues: + "src/language-css", + "src/language-graphql", + "src/language-handlebars", + "src/language-html", + "src/language-js", + "src/language-markdown", + "src/language-yaml", + // [TBD] JavaScript sources affected by JSDoc issues in src/language-*: + "src/common/internal-plugins.js", + "src/common/load-plugins.js", + "src/cli/index.js", + "src/cli/util.js", + // [TBD] top-level JavaScript sources affected by JSDoc issues + // in other sources: + "src/index.js", + "src/standalone.js", + "index.js", + "standalone.js", + "bin/", + "dist/", + "docs/", + "scripts/", + "tests/", + "tests_config/", + "tests_integration/", + "website/" + ] +} From 491038d69392cae2c8d7c4eba488ebaac6790f29 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sat, 2 Nov 2019 16:45:56 +0800 Subject: [PATCH 08/43] Run CI on node 12 (#6738) --- azure-pipelines.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6a994ed82..40df469c2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,69 +9,69 @@ variables: jobs: - job: Dev_Lint - displayName: Dev Lint on Linux Node v10 + displayName: Dev Lint on Linux Node v12 pool: vmImage: "Ubuntu 16.04" variables: - node_version: 10 + node_version: 12 steps: - template: .azure-pipelines/jobs/dev-lint.yml - job: Dev_Test_Windows - displayName: Dev Test on Windows Node v10 + displayName: Dev Test on Windows Node v12 pool: vmImage: vs2017-win2016 variables: - node_version: 10 + node_version: 12 TEST_CRLF: true steps: - template: .azure-pipelines/jobs/dev-test.yml - job: Dev_Test_macOS - displayName: Dev Test on macOS Node v10 + displayName: Dev Test on macOS Node v12 pool: vmImage: macos-10.13 variables: - node_version: 10 + node_version: 12 ENABLE_CODE_COVERAGE: true steps: - template: .azure-pipelines/jobs/dev-test.yml - job: Dev_Test_Linux - displayName: Dev Test on Linux Node v10 + displayName: Dev Test on Linux Node v12 pool: vmImage: "Ubuntu 16.04" variables: - node_version: 10 + node_version: 12 steps: - template: .azure-pipelines/jobs/dev-test.yml - job: Prod_Build - displayName: Prod Build on Linux Node v10 + displayName: Prod Build on Linux Node v12 pool: vmImage: "Ubuntu 16.04" variables: - node_version: 10 + node_version: 12 steps: - template: .azure-pipelines/jobs/prod-build.yml - job: Prod_Pack dependsOn: Prod_Build - displayName: Prod Pack on Linux Node v10 + displayName: Prod Pack on Linux Node v12 pool: vmImage: "Ubuntu 16.04" variables: - node_version: 10 + node_version: 12 steps: - template: .azure-pipelines/jobs/prod-pack.yml - job: Prod_Lint dependsOn: Prod_Build - displayName: Prod Lint on Linux Node v10 + displayName: Prod Lint on Linux Node v12 pool: vmImage: "Ubuntu 16.04" variables: - node_version: 10 + node_version: 12 steps: - template: .azure-pipelines/jobs/prod-lint.yml @@ -85,10 +85,10 @@ jobs: Node_v4: node_version: 4 ENABLE_TEST_RESULTS: "" # jest-junit requires node v6+ - Node_v10: - node_version: 10 - Node_v10_standalone: - node_version: 10 + Node_v12: + node_version: 12 + Node_v12_standalone: + node_version: 12 TEST_STANDALONE: true steps: - template: .azure-pipelines/jobs/prod-test.yml From 545a712dc02df98b1a8c973582185f54b8b43bca Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Sat, 2 Nov 2019 16:47:16 +0800 Subject: [PATCH 09/43] Revert #6333 (#6721) --- docs/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cli.md b/docs/cli.md index d1ef8bae0..5dab730fc 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -17,7 +17,7 @@ In practice, this may look something like: prettier --single-quote --trailing-comma es5 --write "{app,__{tests,mocks}__}/**/*.js" ``` -Don't forget the quotes around the globs! The quotes make sure that Prettier expands the globs rather than your shell, for cross-platform usage. The [glob syntax from the `fast-glob` module](https://github.com/mrmlnc/fast-glob/blob/master/README.md#pattern-syntax) is used. +Don't forget the quotes around the globs! The quotes make sure that Prettier expands the globs rather than your shell, for cross-platform usage. The [glob syntax from the glob module](https://github.com/isaacs/node-glob/blob/master/README.md#glob-primer) is used. Prettier CLI will ignore files located in `node_modules` directory. To opt-out from this behavior use `--with-node-modules` flag. From f6bd59dfd350e035693b41c0902007528e4c272c Mon Sep 17 00:00:00 2001 From: Dang Mai Date: Sat, 2 Nov 2019 04:52:49 -0400 Subject: [PATCH 10/43] Allow plugin to specify option with type `string` (#6219) --- src/main/options-normalizer.js | 3 + .../plugin-options-string.js.snap | 34 +++++++++++ .../__tests__/plugin-options-string.js | 56 +++++++++++++++++++ .../plugins/options-string/config.json | 4 ++ .../plugins/options-string/plugin.js | 31 ++++++++++ 5 files changed, 128 insertions(+) create mode 100644 tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap create mode 100644 tests_integration/__tests__/plugin-options-string.js create mode 100644 tests_integration/plugins/options-string/config.json create mode 100644 tests_integration/plugins/options-string/plugin.js diff --git a/src/main/options-normalizer.js b/src/main/options-normalizer.js index 69fd3384d..a46a579df 100644 --- a/src/main/options-normalizer.js +++ b/src/main/options-normalizer.js @@ -118,6 +118,9 @@ function optionInfoToSchema(optionInfo, { isCLI, optionInfos }) { parameters.preprocess = value => Number(value); } break; + case "string": + SchemaConstructor = vnopts.StringSchema; + break; case "choice": SchemaConstructor = vnopts.ChoiceSchema; parameters.choices = optionInfo.choices.map(choiceInfo => diff --git a/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap b/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap new file mode 100644 index 000000000..77d3ae01f --- /dev/null +++ b/tests_integration/__tests__/__snapshots__/plugin-options-string.js.snap @@ -0,0 +1,34 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` 1`] = ` +"Snapshot Diff: +- First value ++ Second value + +@@ -17,10 +17,12 @@ + Defaults to avoid. + --no-bracket-spacing Do not print spaces between brackets. + --end-of-line + Which end of line characters to apply. + Defaults to auto. ++ --foo-string foo description ++ Defaults to bar. + --html-whitespace-sensitivity + How to handle whitespaces in HTML. + Defaults to css. + --jsx-bracket-same-line Put > on the last line instead of at a new line. + Defaults to false." +`; + +exports[`show detailed external option with \`--help foo-string\` (stderr) 1`] = `""`; + +exports[`show detailed external option with \`--help foo-string\` (stdout) 1`] = ` +"--foo-string + + foo description + +Default: bar +" +`; + +exports[`show detailed external option with \`--help foo-string\` (write) 1`] = `Array []`; diff --git a/tests_integration/__tests__/plugin-options-string.js b/tests_integration/__tests__/plugin-options-string.js new file mode 100644 index 000000000..3c12c1e81 --- /dev/null +++ b/tests_integration/__tests__/plugin-options-string.js @@ -0,0 +1,56 @@ +"use strict"; + +const runPrettier = require("../runPrettier"); +const snapshotDiff = require("snapshot-diff"); + +describe("show external options with `--help`", () => { + const originalStdout = runPrettier("plugins/options-string", ["--help"]) + .stdout; + const pluggedStdout = runPrettier("plugins/options-string", [ + "--help", + "--plugin=./plugin" + ]).stdout; + expect(snapshotDiff(originalStdout, pluggedStdout)).toMatchSnapshot(); +}); + +describe("show detailed external option with `--help foo-string`", () => { + runPrettier("plugins/options-string", [ + "--plugin=./plugin", + "--help", + "foo-string" + ]).test({ + status: 0 + }); +}); + +describe("external options from CLI should work", () => { + runPrettier( + "plugins/options-string", + [ + "--plugin=./plugin", + "--stdin-filepath", + "example.foo", + "--foo-string", + "baz" + ], + { input: "hello-world" } + ).test({ + stdout: "foo:baz", + stderr: "", + status: 0, + write: [] + }); +}); + +describe("external options from config file should work", () => { + runPrettier( + "plugins/options-string", + ["--config=./config.json", "--stdin-filepath", "example.foo"], + { input: "hello-world" } + ).test({ + stdout: "foo:baz", + stderr: "", + status: 0, + write: [] + }); +}); diff --git a/tests_integration/plugins/options-string/config.json b/tests_integration/plugins/options-string/config.json new file mode 100644 index 000000000..b6cca6ceb --- /dev/null +++ b/tests_integration/plugins/options-string/config.json @@ -0,0 +1,4 @@ +{ + "plugins": ["./plugin"], + "fooString": "baz" +} \ No newline at end of file diff --git a/tests_integration/plugins/options-string/plugin.js b/tests_integration/plugins/options-string/plugin.js new file mode 100644 index 000000000..110902001 --- /dev/null +++ b/tests_integration/plugins/options-string/plugin.js @@ -0,0 +1,31 @@ +"use strict"; + +module.exports = { + languages: [ + { + name: "foo", + parsers: ["foo-parser"], + extensions: [".foo"], + since: "1.0.0" + } + ], + options: { + fooString: { + type: "string", + default: "bar", + description: "foo description" + } + }, + parsers: { + "foo-parser": { + parse: text => ({ text }), + astFormat: "foo-ast" + } + }, + printers: { + "foo-ast": { + print: (path, options) => + options.fooString ? `foo:${options.fooString}` : path.getValue().text + } + } +}; From 1490536054dde741f5c54233d7778b4ca260f2ae Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Sat, 2 Nov 2019 11:40:41 +0200 Subject: [PATCH 11/43] merge similar entries in CHANGELOG.unreleased.md (#6782) --- CHANGELOG.unreleased.md | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 2683766fb..c772b4391 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -123,25 +123,28 @@ class C extends B { } ``` -#### TypeScript: Prettier removed `?` from optional computed class fields ([#6657] by [@cryrivers]) +#### TypeScript: Fix optional computed class fields and methods ([#6657] by [@cryrivers], [#6673] by [@thorn0]) -Still happens if the field key is a complex expression, but has been fixed in this case: +Still broken if the key is a complex expression, but has been fixed in these cases: ```ts // Input class Foo { [bar]?: number; + protected [s]?() {} } // Output (Prettier stable) class Foo { [bar]: number; + protected [s?]() {}; } // Output (Prettier master) class Foo { [bar]?: number; + protected [s]?() {} } ``` @@ -1097,26 +1100,6 @@ class A { } ``` -#### TypeScript: Fix optional computed methods ([#6673] by [@thorn0]) - - -```ts -// Input -class A { - protected [s]?() {} -} - -// Output (Prettier stable) -class A { - protected [s?]() {} -} - -// Output (Prettier master) -class A { - protected [s]?() {} -} -``` - #### Angular: Put a closing parenthesis onto a new line after ternaries passed to pipes ([#5682] by [@selvazhagan]) From 0acc3120ef46df957aaad93863eb234c1a6fac51 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 2 Nov 2019 05:53:13 -0700 Subject: [PATCH 12/43] cli: Handle errors when reading stdin (#6708) Co-authored-by: Simon Lydell --- CHANGELOG.unreleased.md | 28 +++++++++++++++++++++++++ package.json | 1 + src/cli/util.js | 36 +++++++++++++++----------------- tests_integration/runPrettier.js | 7 ++++--- yarn.lock | 5 +++++ 5 files changed, 55 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index c772b4391..bd578028f 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -1292,6 +1292,31 @@ const example1 = (): { p: string => string } => (0: any); const example1 = (): ({ p: string => string }) => (0: any); ``` +#### CLI: Handle errors when reading stdin ([#6708] by [@andersk] and [@lydell]) + +If you had an error in your `.prettierrc` Prettier used to crash when formatting stdin. Such errors are now handled properly. + +``` +# Prettier stable +$ prettier --parser babel < test.js +(node:21531) UnhandledPromiseRejectionWarning: Error: Invalid printWidth value. Expected an integer, but received "nope". + at _loop (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:7887:63) + at Normalizer._applyNormalization (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:8000:13) + at applyNormalization (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:7817:49) + at Normalizer.normalize (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:7823:9) + at normalizeOptions$1 (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:8760:31) + at Object.normalizeApiOptions (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:8918:10) + at getOptionsForFile (/home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:44160:69) + at /home/lydell/forks/prettier/node_modules/prettier/bin-prettier.js:44214:22 + at process._tickCallback (internal/process/next_tick.js:68:7) +(node:21531) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) +(node:21531) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. + +# Prettier master +$ prettier --parser babel < test.js +[error] Invalid printWidth value. Expected an integer, but received "nope". +``` + [#5682]: https://github.com/prettier/prettier/pull/5682 [#6657]: https://github.com/prettier/prettier/pull/6657 [#5910]: https://github.com/prettier/prettier/pull/5910 @@ -1336,6 +1361,7 @@ const example1 = (): ({ p: string => string }) => (0: any); [#6694]: https://github.com/prettier/prettier/pull/6694 [#6717]: https://github.com/prettier/prettier/pull/6717 [#6728]: https://github.com/prettier/prettier/pull/6728 +[#6708]: https://github.com/prettier/prettier/pull/6708 [@brainkim]: https://github.com/brainkim [@duailibe]: https://github.com/duailibe [@gavinjoyce]: https://github.com/gavinjoyce @@ -1354,3 +1380,5 @@ const example1 = (): ({ p: string => string }) => (0: any); [@kaicataldo]: https://github.com/kaicataldo [@cryrivers]: https://github.com/Cryrivers [@voithos]: https://github.com/voithos +[@andersk]: https://github.com/andersk +[@lydell]: https://github.com/lydell diff --git a/package.json b/package.json index e9fbd11b1..a83c5d82c 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "shelljs": "0.8.3", "snapshot-diff": "0.4.0", "strip-ansi": "5.2.0", + "synchronous-promise": "2.0.10", "tempy": "0.2.1", "terser-webpack-plugin": "2.1.3", "webpack": "4.41.2" diff --git a/src/cli/util.js b/src/cli/util.js index 44baae1ae..1fa3c5656 100644 --- a/src/cli/util.js +++ b/src/cli/util.js @@ -72,23 +72,21 @@ function handleError(context, filename, error) { } const isParseError = Boolean(error && error.loc); - const isValidationError = /Validation Error/.test(error && error.message); + const isValidationError = /^Invalid \S+ value\./.test(error && error.message); - // For parse errors and validation errors, we only want to show the error - // message formatted in a nice way. `String(error)` takes care of that. Other - // (unexpected) errors are passed as-is as a separate argument to - // `console.error`. That includes the stack trace (if any), and shows a nice - // `util.inspect` of throws things that aren't `Error` objects. (The Flow - // parser has mistakenly thrown arrays sometimes.) if (isParseError) { + // `invalid.js: SyntaxError: Unexpected token (1:1)`. context.logger.error(`${filename}: ${String(error)}`); } else if (isValidationError || error instanceof errors.ConfigError) { - context.logger.error(String(error)); + // `Invalid printWidth value. Expected an integer, but received 0.5.` + context.logger.error(error.message); // If validation fails for one file, it will fail for all of them. process.exit(1); } else if (error instanceof errors.DebugError) { + // `invalid.js: Some debug error message` context.logger.error(`${filename}: ${error.message}`); } else { + // `invalid.js: Error: Some unexpected error\n[stack trace]` context.logger.error(filename + ": " + (error.stack || error)); } @@ -368,24 +366,25 @@ function formatStdin(context) { const ignorer = createIgnorerFromContextOrDie(context); const relativeFilepath = path.relative(process.cwd(), filepath); - thirdParty.getStream(process.stdin).then(input => { - if (relativeFilepath && ignorer.filter([relativeFilepath]).length === 0) { - writeOutput(context, { formatted: input }); - return; - } + thirdParty + .getStream(process.stdin) + .then(input => { + if (relativeFilepath && ignorer.filter([relativeFilepath]).length === 0) { + writeOutput(context, { formatted: input }); + return; + } - const options = getOptionsForFile(context, filepath); + const options = getOptionsForFile(context, filepath); - try { if (listDifferent(context, input, options, "(stdin)")) { return; } writeOutput(context, format(context, input, options), options); - } catch (error) { + }) + .catch(error => { handleError(context, relativeFilepath || "stdin", error); - } - }); + }); } function createIgnorerFromContextOrDie(context) { @@ -458,7 +457,6 @@ function formatFiles(context) { }); if (isTTY()) { - // Don't use `console.log` here since we need to replace this line. context.logger.log(filename, { newline: false }); } diff --git a/tests_integration/runPrettier.js b/tests_integration/runPrettier.js index 27226065a..b258d0931 100644 --- a/tests_integration/runPrettier.js +++ b/tests_integration/runPrettier.js @@ -3,6 +3,7 @@ const fs = require("fs"); const path = require("path"); const stripAnsi = require("strip-ansi"); +const SynchronousPromise = require("synchronous-promise").SynchronousPromise; const isProduction = process.env.NODE_ENV === "production"; const prettierRootDir = isProduction ? process.env.PRETTIER_DIR : "../"; @@ -82,9 +83,9 @@ function runPrettier(dir, args, options) { // We cannot use `jest.setMock("get-stream", impl)` here, because in the // production build everything is bundled into one file so there is no // "get-stream" module to mock. - jest.spyOn(require(thirdParty), "getStream").mockImplementation(() => ({ - then: handler => handler(options.input || "") - })); + jest + .spyOn(require(thirdParty), "getStream") + .mockImplementation(() => SynchronousPromise.resolve(options.input || "")); jest .spyOn(require(thirdParty), "isCI") .mockImplementation(() => process.env.CI); diff --git a/yarn.lock b/yarn.lock index 2b818992c..b6044f5f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6965,6 +6965,11 @@ symbol-tree@^3.2.2: version "3.2.2" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6" +synchronous-promise@2.0.10: + version "2.0.10" + resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.10.tgz#e64c6fd3afd25f423963353043f4a68ebd397fd8" + integrity sha512-6PC+JRGmNjiG3kJ56ZMNWDPL8hjyghF5cMXIFOKg+NiwwEZZIvxTWd0pinWKyD227odg9ygF8xVhhz7gb8Uq7A== + table@^5.2.3: version "5.4.0" resolved "https://registry.yarnpkg.com/table/-/table-5.4.0.tgz#d772a3216e68829920a41a32c18eda286c95d780" From 3d52ab70167fc5a8f21b5ebdaf2cfdb54e5e0471 Mon Sep 17 00:00:00 2001 From: Zaven Muradyan Date: Sat, 2 Nov 2019 07:56:26 -0700 Subject: [PATCH 13/43] Gracefully handle nonexistent paths passed to --stdin-filepath. (#6687) Co-authored-by: Simon Lydell --- CHANGELOG.unreleased.md | 15 +++++ cspell.json | 4 +- src/config/resolve-config-editorconfig.js | 12 +++- .../__snapshots__/stdin-filepath.js.snap | 44 +++++++++++++ tests_integration/__tests__/stdin-filepath.js | 61 +++++++++++++++++++ 5 files changed, 134 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index bd578028f..e4ade133c 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -1317,6 +1317,20 @@ $ prettier --parser babel < test.js [error] Invalid printWidth value. Expected an integer, but received "nope". ``` +#### CLI: Gracefully handle nonexistent paths passed to --stdin-filepath ([#6687] by [@voithos]) + +Previously, if you passed a nonexistent subdirectory to --stdin-filepath, Prettier would throw an error. Now, Prettier gracefully handles this. + +``` +# Prettier stable +$ prettier --stdin-filepath does/not/exist.js < test.js +[error] Invalid configuration file: ENOENT: no such file or directory, scandir '/home/lydell/forks/prettier/does/not' + +# Prettier master +$ prettier --stdin-filepath does/not/exist.js < test.js +test; +``` + [#5682]: https://github.com/prettier/prettier/pull/5682 [#6657]: https://github.com/prettier/prettier/pull/6657 [#5910]: https://github.com/prettier/prettier/pull/5910 @@ -1362,6 +1376,7 @@ $ prettier --parser babel < test.js [#6717]: https://github.com/prettier/prettier/pull/6717 [#6728]: https://github.com/prettier/prettier/pull/6728 [#6708]: https://github.com/prettier/prettier/pull/6708 +[#6687]: https://github.com/prettier/prettier/pull/6687 [@brainkim]: https://github.com/brainkim [@duailibe]: https://github.com/duailibe [@gavinjoyce]: https://github.com/gavinjoyce diff --git a/cspell.json b/cspell.json index dddb81ae6..b57e67bef 100644 --- a/cspell.json +++ b/cspell.json @@ -91,6 +91,7 @@ "editorconfig", "ekkhus", "elektronik", + "ENOENT", "Eneman", "ericsakmar", "Ericsburgh", @@ -303,6 +304,7 @@ "ruleset", "Sapegin", "sbdchd", + "scandir", "schemastore", "serializer", "setlocal", @@ -393,4 +395,4 @@ "\\[`\\w+`\\]", "ve+r+y+(long\\w+)?" ] -} \ No newline at end of file +} diff --git a/src/config/resolve-config-editorconfig.js b/src/config/resolve-config-editorconfig.js index 07c209250..deab857d4 100644 --- a/src/config/resolve-config-editorconfig.js +++ b/src/config/resolve-config-editorconfig.js @@ -1,5 +1,6 @@ "use strict"; +const fs = require("fs"); const path = require("path"); const editorconfig = require("editorconfig"); @@ -8,7 +9,16 @@ const editorConfigToPrettier = require("editorconfig-to-prettier"); const findProjectRoot = require("find-project-root"); const maybeParse = (filePath, config, parse) => { - const root = findProjectRoot(path.dirname(path.resolve(filePath))); + // findProjectRoot will throw an error if we pass a nonexistent directory to + // it, which is possible, for example, when the path is given via + // --stdin-filepath. So, first, traverse up until we find an existing + // directory. + let dirPath = path.dirname(path.resolve(filePath)); + const fsRoot = path.parse(dirPath).root; + while (dirPath !== fsRoot && !fs.existsSync(dirPath)) { + dirPath = path.dirname(dirPath); + } + const root = findProjectRoot(dirPath); return filePath && parse(filePath, { root }); }; diff --git a/tests_integration/__tests__/__snapshots__/stdin-filepath.js.snap b/tests_integration/__tests__/__snapshots__/stdin-filepath.js.snap index a109655c8..2f065a2b1 100644 --- a/tests_integration/__tests__/__snapshots__/stdin-filepath.js.snap +++ b/tests_integration/__tests__/__snapshots__/stdin-filepath.js.snap @@ -1,5 +1,38 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`apply editorconfig for stdin-filepath with nonexistent directory (stderr) 1`] = `""`; + +exports[`apply editorconfig for stdin-filepath with nonexistent directory (stdout) 1`] = ` +"function f() { + console.log(\\"should be indented with a tab\\") +} +" +`; + +exports[`apply editorconfig for stdin-filepath with nonexistent directory (write) 1`] = `Array []`; + +exports[`apply editorconfig for stdin-filepath with nonexistent file (stderr) 1`] = `""`; + +exports[`apply editorconfig for stdin-filepath with nonexistent file (stdout) 1`] = ` +"function f() { + console.log(\\"should be indented with a tab\\") +} +" +`; + +exports[`apply editorconfig for stdin-filepath with nonexistent file (write) 1`] = `Array []`; + +exports[`don’t apply editorconfig outside project for stdin-filepath with nonexistent directory (stderr) 1`] = `""`; + +exports[`don’t apply editorconfig outside project for stdin-filepath with nonexistent directory (stdout) 1`] = ` +"function f() { + console.log(\\"should be indented with 2 spaces\\") +} +" +`; + +exports[`don’t apply editorconfig outside project for stdin-filepath with nonexistent directory (write) 1`] = `Array []`; + exports[`format correctly if stdin content compatible with stdin-filepath (stderr) 1`] = `""`; exports[`format correctly if stdin content compatible with stdin-filepath (stdout) 1`] = ` @@ -11,6 +44,17 @@ exports[`format correctly if stdin content compatible with stdin-filepath (stdou exports[`format correctly if stdin content compatible with stdin-filepath (write) 1`] = `Array []`; +exports[`gracefully handle stdin-filepath with nonexistent directory (stderr) 1`] = `""`; + +exports[`gracefully handle stdin-filepath with nonexistent directory (stdout) 1`] = ` +".name { + display: none; +} +" +`; + +exports[`gracefully handle stdin-filepath with nonexistent directory (write) 1`] = `Array []`; + exports[`output file as-is if stdin-filepath matched patterns in ignore-path (stderr) 1`] = `""`; exports[`output file as-is if stdin-filepath matched patterns in ignore-path (write) 1`] = `Array []`; diff --git a/tests_integration/__tests__/stdin-filepath.js b/tests_integration/__tests__/stdin-filepath.js index bc01b90c8..983b6a64a 100644 --- a/tests_integration/__tests__/stdin-filepath.js +++ b/tests_integration/__tests__/stdin-filepath.js @@ -22,6 +22,67 @@ describe("throw error if stdin content incompatible with stdin-filepath", () => }); }); +describe("gracefully handle stdin-filepath with nonexistent directory", () => { + runPrettier( + "cli", + ["--stdin-filepath", "definitely/nonexistent/path.css"], + { input: ".name { display: none; }" } // css + ).test({ + status: 0 + }); +}); + +describe("apply editorconfig for stdin-filepath with nonexistent file", () => { + runPrettier( + "cli", + ["--stdin-filepath", "config/editorconfig/nonexistent.js"], + { + input: ` +function f() { + console.log("should be indented with a tab"); +} +`.trim() // js + } + ).test({ + status: 0 + }); +}); + +describe("apply editorconfig for stdin-filepath with nonexistent directory", () => { + runPrettier( + "cli", + ["--stdin-filepath", "config/editorconfig/nonexistent/one/two/three.js"], + { + input: ` +function f() { + console.log("should be indented with a tab"); +} +`.trim() // js + } + ).test({ + status: 0 + }); +}); + +describe("don’t apply editorconfig outside project for stdin-filepath with nonexistent directory", () => { + runPrettier( + "cli", + [ + "--stdin-filepath", + "config/editorconfig/repo-root/nonexistent/one/two/three.js" + ], + { + input: ` +function f() { + console.log("should be indented with 2 spaces"); +} +`.trim() // js + } + ).test({ + status: 0 + }); +}); + describe("output file as-is if stdin-filepath matched patterns in ignore-path", () => { runPrettier("cli/stdin-ignore", ["--stdin-filepath", "ignore/example.js"], { input: "hello_world( );" From 677b46df71dc201d3aaf276ba2403c6135ff7869 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 2 Nov 2019 15:58:28 +0100 Subject: [PATCH 14/43] Update angular-html-parser (#6785) Fixes #6749. Closes #6784. --- CHANGELOG.unreleased.md | 21 +++++++++++++++++++ package.json | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 2 ++ .../symbol_entitites.html | 1 + yarn.lock | 7 ++++--- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index e4ade133c..30a4121fb 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -679,6 +679,26 @@ Previously, even if the line length was shorter than `printWidth`, Prettier woul ``` +#### HTML: Add support for `!` and other entities ([#6785] by [@lydell]) + +Previously, Prettier only supported the most common HTML entities, such as ` ` and `"`. Now, Prettier supports every HTML entity in the HTML spec, such as `!` and `⋔`. + + +```html + +

Hi!

+ + + + +

Hi!

+``` + #### JavaScript: Empty lines in destructured arrow function parameters could break indentation and idempotence ([#6301] & [#6382] by [@sosukesuzuki]) Previously, Prettier indented code strangely when an arrow function whose parameters included an object pattern was passed to a function call as an argument. Also, it broke idempotence. Please see [#6294](https://github.com/prettier/prettier/issues/6294) for details. @@ -1343,6 +1363,7 @@ test; [#6236]: https://github.com/prettier/prettier/pull/6236 [#6270]: https://github.com/prettier/prettier/pull/6270 [#6284]: https://github.com/prettier/prettier/pull/6284 +[#6785]: https://github.com/prettier/prettier/pull/6785 [#6289]: https://github.com/prettier/prettier/pull/6289 [#6301]: https://github.com/prettier/prettier/pull/6301 [#6307]: https://github.com/prettier/prettier/pull/6307 diff --git a/package.json b/package.json index a83c5d82c..0fe307bd6 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "@iarna/toml": "2.2.3", "@typescript-eslint/typescript-estree": "2.6.0", "angular-estree-parser": "1.1.5", - "angular-html-parser": "1.2.0", + "angular-html-parser": "1.3.0", "camelcase": "5.3.1", "chalk": "2.4.2", "cjk-regex": "2.0.0", diff --git a/tests/html_symbol_entities/__snapshots__/jsfmt.spec.js.snap b/tests/html_symbol_entities/__snapshots__/jsfmt.spec.js.snap index 4e930fbf8..226b06501 100644 --- a/tests/html_symbol_entities/__snapshots__/jsfmt.spec.js.snap +++ b/tests/html_symbol_entities/__snapshots__/jsfmt.spec.js.snap @@ -7,11 +7,13 @@ printWidth: 80 | printWidth =====================================input======================================

I will display €

+

I will display !

I will display €

I will display €

=====================================output=====================================

I will display €

+

I will display !

I will display €

I will display €

diff --git a/tests/html_symbol_entities/symbol_entitites.html b/tests/html_symbol_entities/symbol_entitites.html index 2ccc4ed19..4ba276d56 100644 --- a/tests/html_symbol_entities/symbol_entitites.html +++ b/tests/html_symbol_entities/symbol_entitites.html @@ -1,3 +1,4 @@

I will display €

+

I will display !

I will display €

I will display €

diff --git a/yarn.lock b/yarn.lock index b6044f5f3..bf7ef034f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1214,9 +1214,10 @@ angular-estree-parser@1.1.5: lines-and-columns "^1.1.6" tslib "^1.9.3" -angular-html-parser@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/angular-html-parser/-/angular-html-parser-1.2.0.tgz#9319b8a9e06389aee2449b3a35977442512eccf3" +angular-html-parser@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/angular-html-parser/-/angular-html-parser-1.3.0.tgz#2b87c3c1b7535a972a00e35604221df3c51e6c6e" + integrity sha512-FCLuM8ZUt30qwiV5KlW8uWL9cwlS2loOIGq8wUQFypkJ1QZqJk829yxTsvp2DvCMZ7uLwfjIaIrKV5N2+RLiSQ== dependencies: tslib "^1.9.3" From 12ba99720714ef965c2c9580a6d922519bc282f8 Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Sun, 3 Nov 2019 14:05:08 +0200 Subject: [PATCH 15/43] disable optimization from #6229 for calls with type arguments (#6791) --- src/language-js/printer-estree.js | 4 +++- .../__snapshots__/jsfmt.spec.js.snap | 20 +++++++++++++++++++ tests/break-calls/type_args.js | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/break-calls/type_args.js diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 4bbb91934..5000bde1c 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -4024,7 +4024,9 @@ function printArgumentsList(path, options, print) { somePrintedArgumentsWillBreak ? breakParent : "", conditionalGroup( [ - !somePrintedArgumentsWillBreak + !somePrintedArgumentsWillBreak && + !node.typeArguments && + !node.typeParameters ? simpleConcat : ifBreak(allArgsBrokenOut(), simpleConcat), shouldGroupFirst diff --git a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap index 5eddc00ee..033f231d7 100644 --- a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap +++ b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap @@ -231,3 +231,23 @@ function MyComponent(props) { ================================================================================ `; + +exports[`type_args.js 1`] = ` +====================================options===================================== +parsers: ["flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +const response = something.$http.get( + \`api/foo.ashx/foo-details/\${myId}\`, + { cache: quux.httpCache, timeout } +); + +=====================================output===================================== +const response = something.$http.get( + \`api/foo.ashx/foo-details/\${myId}\`, + { cache: quux.httpCache, timeout } +); + +================================================================================ +`; diff --git a/tests/break-calls/type_args.js b/tests/break-calls/type_args.js new file mode 100644 index 000000000..503013f01 --- /dev/null +++ b/tests/break-calls/type_args.js @@ -0,0 +1,4 @@ +const response = something.$http.get( + `api/foo.ashx/foo-details/${myId}`, + { cache: quux.httpCache, timeout } +); From 6ba4be015b3f10be4da13d4252060bc641ccd1a5 Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Mon, 4 Nov 2019 19:21:29 +0200 Subject: [PATCH 16/43] fix: numeric separators were removed from BigInt literals (#6796) --- CHANGELOG.unreleased.md | 15 +++++++++++++++ src/language-js/printer-estree.js | 11 ++--------- tests/big-int/__snapshots__/jsfmt.spec.js.snap | 6 ++++++ tests/big-int/literal.js | 3 +++ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 30a4121fb..438c4ed05 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -1351,6 +1351,20 @@ $ prettier --stdin-filepath does/not/exist.js < test.js test; ``` +#### JavaScript: Numeric separators were removed from BigInt literals ([#6796] by [@thorn0]) + + +```js +// Input +const bigints = [200_000n, 0x0000_000An, 0b0111_1111n]; + +// Output (Prettier stable) +const bigints = [200000n, 0x0000000an, 0b01111111n]; + +// Output (Prettier master) +const bigints = [200_000n, 0x0000_000an, 0b0111_1111n]; +``` + [#5682]: https://github.com/prettier/prettier/pull/5682 [#6657]: https://github.com/prettier/prettier/pull/6657 [#5910]: https://github.com/prettier/prettier/pull/5910 @@ -1398,6 +1412,7 @@ test; [#6728]: https://github.com/prettier/prettier/pull/6728 [#6708]: https://github.com/prettier/prettier/pull/6708 [#6687]: https://github.com/prettier/prettier/pull/6687 +[#6796]: https://github.com/prettier/prettier/pull/6796 [@brainkim]: https://github.com/brainkim [@duailibe]: https://github.com/duailibe [@gavinjoyce]: https://github.com/gavinjoyce diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 5000bde1c..1cd396b61 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -1610,15 +1610,8 @@ function printPathNoParens(path, options, print, args) { case "NumericLiteral": // Babel 6 Literal split return printNumber(n.extra.raw); case "BigIntLiteral": - return concat([ - printNumber( - n.extra - ? n.extra.rawValue - : // TypeScript - n.value - ), - "n" - ]); + // babel: n.extra.raw, typescript: n.raw + return (n.extra ? n.extra.raw : n.raw).toLowerCase(); case "BooleanLiteral": // Babel 6 Literal split case "StringLiteral": // Babel 6 Literal split case "Literal": { diff --git a/tests/big-int/__snapshots__/jsfmt.spec.js.snap b/tests/big-int/__snapshots__/jsfmt.spec.js.snap index 69dededd1..5409b1c54 100644 --- a/tests/big-int/__snapshots__/jsfmt.spec.js.snap +++ b/tests/big-int/__snapshots__/jsfmt.spec.js.snap @@ -14,6 +14,9 @@ printWidth: 80 0XFFF123n 0b101011101n 0B101011101n +200_000n +0x0000_000An +0b0111_1111n =====================================output===================================== 100n; @@ -24,6 +27,9 @@ printWidth: 80 0xfff123n; 0b101011101n; 0b101011101n; +200_000n; +0x0000_000an; +0b0111_1111n; ================================================================================ `; diff --git a/tests/big-int/literal.js b/tests/big-int/literal.js index 4defccb1d..7bb46dde1 100644 --- a/tests/big-int/literal.js +++ b/tests/big-int/literal.js @@ -6,3 +6,6 @@ 0XFFF123n 0b101011101n 0B101011101n +200_000n +0x0000_000An +0b0111_1111n From 65563e0a55d7c03519673f94fa63602f80829c32 Mon Sep 17 00:00:00 2001 From: Christian Oliff Date: Tue, 5 Nov 2019 20:25:28 +0900 Subject: [PATCH 17/43] HTTPS external links (#6811) safer and saves a HTTP requests :-) --- docs/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/index.md b/docs/index.md index 5c3b63dbc..d264093bf 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,12 +11,12 @@ Prettier is an opinionated code formatter with support for: - [Vue](https://vuejs.org/) - [Flow](https://flow.org/) - [TypeScript](https://www.typescriptlang.org/) -- CSS, [Less](http://lesscss.org/), and [SCSS](http://sass-lang.com) +- CSS, [Less](http://lesscss.org/), and [SCSS](https://sass-lang.com) - [HTML](https://en.wikipedia.org/wiki/HTML) - [JSON](http://json.org/) -- [GraphQL](http://graphql.org/) -- [Markdown](http://commonmark.org/), including [GFM](https://github.github.com/gfm/) and [MDX](https://mdxjs.com/) -- [YAML](http://yaml.org/) +- [GraphQL](https://graphql.org/) +- [Markdown](https://commonmark.org/), including [GFM](https://github.github.com/gfm/) and [MDX](https://mdxjs.com/) +- [YAML](https://yaml.org/) It removes all original styling[\*](#footnotes) and ensures that all outputted code conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Prettier-Formatter)) From f059d7a31bf6db6f82877b00767e43667e195268 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Tue, 5 Nov 2019 12:28:44 +0100 Subject: [PATCH 18/43] JSDoc type added in `src/common/util.js` (#6788) * JSDoc type added in `src/common/util.js` * skip can return false * Add TBD for false - 1 not allowed * Define typedef SkipOptions * Use method generic for node param * Define node param for setLocStart and setLocEnd * Copy idx param to local variable * Add @returns false * Update Utility functions docs * hasNewline param index: allow only number * Add condition * Add function keyword to docs * Add prettier-ignore * Improve condition * Remove TBD comment * Use single quotes * Add type to oldIndex * Use singleline JSDocs --- docs/plugins.md | 45 ++--- src/common/util.js | 161 +++++++++++++++++- src/main/comments.js | 3 +- .../versioned_docs/version-stable/plugins.md | 45 ++--- 4 files changed, 203 insertions(+), 51 deletions(-) diff --git a/docs/plugins.md b/docs/plugins.md index c5dd26417..ceee4982a 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -228,28 +228,31 @@ defaultOptions: { A `util` module from Prettier core is considered a private API and is not meant to be consumed by plugins. Instead, the `util-shared` module provides the following limited set of utility functions for plugins: + ```ts -getMaxContinuousCount(str: string, target: string): number; -getStringWidth(text: string): number; -getAlignmentSize(value: string, tabWidth: number, startIndex: number): number; -getIndentSize(value: string, tabWidth: number): number; -skip(chars: string|RegExp): number; -skipWhitespace(text: string, index: number, options: object): number; -skipSpaces(text: string, index: number, options: object): number; -skipToLineEnd(text: string, index: number, options: object): number; -skipEverythingButNewLine(text: string, index: number, options: object): number; -skipInlineComment(text: string, index: number): number; -skipTrailingComment(text: string, index: number): number; -skipNewline(text: string, index: number, options: object): number; -hasNewline(text: string, index: number, options: object): boolean; -hasNewlineInRange(text: string, start: number, start: number): boolean; -hasSpaces(text: string, index: number, options: object): number; -makeString(rawContent: string, enclosingQuote: string, unescapeUnnecessaryEscapes: boolean): string; -getNextNonSpaceNonCommentCharacterIndex(text: string, node: object, options: object): number; -isNextLineEmptyAfterIndex(text: string, index: number): boolean; -isNextLineEmpty(text: string, node: object, options: object): boolean; -isPreviousLineEmpty(text: string, node: object, options: object): boolean; -mapDoc(doc: object, callback: function): void; +type Quote = '"' | "'"; +type SkipOptions = { backwards?: boolean }; +function getMaxContinuousCount(str: string, target: string): number; +function getStringWidth(text: string): number; +function getAlignmentSize(value: string, tabWidth: number, startIndex?: number): number; +function getIndentSize(value: string, tabWidth: number): number; +function skip(chars: string | RegExp): (text: string, index: number | false, opts?: SkipOptions) => number | false; +function skipWhitespace(text: string, index: number | false, opts?: SkipOptions): number | false; +function skipSpaces(text: string, index: number | false, opts?: SkipOptions): number | false; +function skipToLineEnd(text: string, index: number | false, opts?: SkipOptions): number | false; +function skipEverythingButNewLine(text: string, index: number | false, opts?: SkipOptions): number | false; +function skipInlineComment(text: string, index: number | false): number | false; +function skipTrailingComment(text: string, index: number | false): number | false; +function skipNewline(text: string, index: number | false, opts?: SkipOptions): number | false; +function hasNewline(text: string, index: number, opts?: SkipOptions): boolean; +function hasNewlineInRange(text: string, start: number, end: number): boolean; +function hasSpaces(text: string, index: number, opts?: SkipOptions): boolean; +function makeString(rawContent: string, enclosingQuote: Quote, unescapeUnnecessaryEscapes?: boolean): string; +function getNextNonSpaceNonCommentCharacterIndex(text: string, node: N, locEnd: (node: N) => number): number | false; +function isNextLineEmptyAfterIndex(text: string, index: number): boolean; +function isNextLineEmpty(text: string, node: N, locEnd: (node: N) => number): boolean; +function isPreviousLineEmpty(text: string, node: N, locStart: (node: N) => number): boolean; +function mapDoc(doc: object, callback: function): void; ``` ### Tutorials diff --git a/src/common/util.js b/src/common/util.js index 582f76eed..9f13f83c6 100644 --- a/src/common/util.js +++ b/src/common/util.js @@ -38,6 +38,14 @@ function getPenultimate(arr) { return null; } +/** + * @typedef {{backwards?: boolean}} SkipOptions + */ + +/** + * @param {string | RegExp} chars + * @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false} + */ function skip(chars) { return (text, index, opts) => { const backwards = opts && opts.backwards; @@ -74,11 +82,28 @@ function skip(chars) { }; } +/** + * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false} + */ const skipWhitespace = skip(/\s/); +/** + * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false} + */ const skipSpaces = skip(" \t"); +/** + * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false} + */ const skipToLineEnd = skip(",; \t"); +/** + * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false} + */ const skipEverythingButNewLine = skip(/[^\r\n]/); +/** + * @param {string} text + * @param {number | false} index + * @returns {number | false} + */ function skipInlineComment(text, index) { if (index === false) { return false; @@ -94,6 +119,11 @@ function skipInlineComment(text, index) { return index; } +/** + * @param {string} text + * @param {number | false} index + * @returns {number | false} + */ function skipTrailingComment(text, index) { if (index === false) { return false; @@ -108,6 +138,12 @@ function skipTrailingComment(text, index) { // This one doesn't use the above helper function because it wants to // test \r\n in order and `skip` doesn't support ordering and we only // want to skip one newline. It's simple to implement. +/** + * @param {string} text + * @param {number | false} index + * @param {SkipOptions=} opts + * @returns {number | false} + */ function skipNewline(text, index, opts) { const backwards = opts && opts.backwards; if (index === false) { @@ -144,6 +180,12 @@ function skipNewline(text, index, opts) { return index; } +/** + * @param {string} text + * @param {number} index + * @param {SkipOptions=} opts + * @returns {boolean} + */ function hasNewline(text, index, opts) { opts = opts || {}; const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts); @@ -151,6 +193,12 @@ function hasNewline(text, index, opts) { return idx !== idx2; } +/** + * @param {string} text + * @param {number} start + * @param {number} end + * @returns {boolean} + */ function hasNewlineInRange(text, start, end) { for (let i = start; i < end; ++i) { if (text.charAt(i) === "\n") { @@ -161,7 +209,14 @@ function hasNewlineInRange(text, start, end) { } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty +/** + * @template N + * @param {string} text + * @param {N} node + * @param {(node: N) => number} locStart + */ function isPreviousLineEmpty(text, node, locStart) { + /** @type {number | false} */ let idx = locStart(node) - 1; idx = skipSpaces(text, idx, { backwards: true }); idx = skipNewline(text, idx, { backwards: true }); @@ -170,8 +225,15 @@ function isPreviousLineEmpty(text, node, locStart) { return idx !== idx2; } +/** + * @param {string} text + * @param {number} index + * @returns {boolean} + */ function isNextLineEmptyAfterIndex(text, index) { + /** @type {number | false} */ let oldIdx = null; + /** @type {number | false} */ let idx = index; while (idx !== oldIdx) { // We need to skip all the potential trailing inline comments @@ -182,25 +244,47 @@ function isNextLineEmptyAfterIndex(text, index) { } idx = skipTrailingComment(text, idx); idx = skipNewline(text, idx); - return hasNewline(text, idx); + return idx !== false && hasNewline(text, idx); } +/** + * @template N + * @param {string} text + * @param {N} node + * @param {(node: N) => number} locEnd + * @returns {boolean} + */ function isNextLineEmpty(text, node, locEnd) { return isNextLineEmptyAfterIndex(text, locEnd(node)); } +/** + * @param {string} text + * @param {number} idx + * @returns {number | false} + */ function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) { + /** @type {number | false} */ let oldIdx = null; - while (idx !== oldIdx) { - oldIdx = idx; - idx = skipSpaces(text, idx); - idx = skipInlineComment(text, idx); - idx = skipTrailingComment(text, idx); - idx = skipNewline(text, idx); + /** @type {number | false} */ + let nextIdx = idx; + while (nextIdx !== oldIdx) { + oldIdx = nextIdx; + nextIdx = skipSpaces(text, nextIdx); + nextIdx = skipInlineComment(text, nextIdx); + nextIdx = skipTrailingComment(text, nextIdx); + nextIdx = skipNewline(text, nextIdx); } - return idx; + return nextIdx; } +/** + * @template N + * @param {string} text + * @param {N} node + * @param {(node: N) => number} locEnd + * @returns {number | false} + */ function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) { return getNextNonSpaceNonCommentCharacterIndexWithStartIndex( text, @@ -208,18 +292,36 @@ function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) { ); } +/** + * @template N + * @param {string} text + * @param {N} node + * @param {(node: N) => number} locEnd + * @returns {string} + */ function getNextNonSpaceNonCommentCharacter(text, node, locEnd) { return text.charAt( + // @ts-ignore => TBD: can return false, should we define a fallback? getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) ); } +/** + * @param {string} text + * @param {number} index + * @param {SkipOptions=} opts + * @returns {boolean} + */ function hasSpaces(text, index, opts) { opts = opts || {}; const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts); return idx !== index; } +/** + * @param {{range?: [number, number], start?: number}} node + * @param {number} index + */ function setLocStart(node, index) { if (node.range) { node.range[0] = index; @@ -228,6 +330,10 @@ function setLocStart(node, index) { } } +/** + * @param {{range?: [number, number], end?: number}} node + * @param {number} index + */ function setLocEnd(node, index) { if (node.range) { node.range[1] = index; @@ -400,6 +506,12 @@ function getLeftMost(node) { return node; } +/** + * @param {string} value + * @param {number} tabWidth + * @param {number=} startIndex + * @returns {number} + */ function getAlignmentSize(value, tabWidth, startIndex) { startIndex = startIndex || 0; @@ -419,6 +531,11 @@ function getAlignmentSize(value, tabWidth, startIndex) { return size; } +/** + * @param {string} value + * @param {number} tabWidth + * @returns {number} + */ function getIndentSize(value, tabWidth) { const lastNewlineIndex = value.lastIndexOf("\n"); if (lastNewlineIndex === -1) { @@ -432,12 +549,24 @@ function getIndentSize(value, tabWidth) { ); } +/** + * @typedef {'"' | "'"} Quote + */ + +/** + * + * @param {string} raw + * @param {Quote} preferredQuote + * @returns {Quote} + */ function getPreferredQuote(raw, preferredQuote) { // `rawContent` is the string exactly like it appeared in the input source // code, without its enclosing quotes. const rawContent = raw.slice(1, -1); + /** @type {{ quote: '"', regex: RegExp }} */ const double = { quote: '"', regex: /"/g }; + /** @type {{ quote: "'", regex: RegExp }} */ const single = { quote: "'", regex: /'/g }; const preferred = preferredQuote === "'" ? single : double; @@ -474,6 +603,7 @@ function printString(raw, options, isDirectiveLiteral) { const canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'"); + /** @type {Quote} */ const enclosingQuote = options.parser === "json" ? '"' @@ -508,6 +638,12 @@ function printString(raw, options, isDirectiveLiteral) { ); } +/** + * @param {string} rawContent + * @param {Quote} enclosingQuote + * @param {boolean=} unescapeUnnecessaryEscapes + * @returns {string} + */ function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) { const otherQuote = enclosingQuote === '"' ? "'" : '"'; @@ -563,6 +699,11 @@ function printNumber(rawNumber) { ); } +/** + * @param {string} str + * @param {string} target + * @returns {number} + */ function getMaxContinuousCount(str, target) { const results = str.match( new RegExp(`(${escapeStringRegexp(target)})+`, "g") @@ -607,6 +748,10 @@ function getMinNotPresentContinuousCount(str, target) { return max + 1; } +/** + * @param {string} text + * @returns {number} + */ function getStringWidth(text) { if (!text) { return 0; diff --git a/src/main/comments.js b/src/main/comments.js index 895dce48d..84e9dc284 100644 --- a/src/main/comments.js +++ b/src/main/comments.js @@ -510,7 +510,8 @@ function printComments(path, print, options, needsSemi) { leadingParts.push(contents); const text = options.originalText; - if (hasNewline(text, skipNewline(text, options.locEnd(comment)))) { + const index = skipNewline(text, options.locEnd(comment)); + if (index !== false && hasNewline(text, index)) { leadingParts.push(hardline); } } else if (trailing) { diff --git a/website/versioned_docs/version-stable/plugins.md b/website/versioned_docs/version-stable/plugins.md index c1682891b..24c654c3d 100644 --- a/website/versioned_docs/version-stable/plugins.md +++ b/website/versioned_docs/version-stable/plugins.md @@ -228,28 +228,31 @@ defaultOptions: { A `util` module from Prettier core is considered a private API and is not meant to be consumed by plugins. Instead, the `util-shared` module provides the following limited set of utility functions for plugins: + ```ts -getMaxContinuousCount(str: string, target: string): number; -getStringWidth(text: string): number; -getAlignmentSize(value: string, tabWidth: number, startIndex: number): number; -getIndentSize(value: string, tabWidth: number): number; -skip(chars: string|RegExp): number; -skipWhitespace(text: string, index: number, options: object): number; -skipSpaces(text: string, index: number, options: object): number; -skipToLineEnd(text: string, index: number, options: object): number; -skipEverythingButNewLine(text: string, index: number, options: object): number; -skipInlineComment(text: string, index: number): number; -skipTrailingComment(text: string, index: number): number; -skipNewline(text: string, index: number, options: object): number; -hasNewline(text: string, index: number, options: object): boolean; -hasNewlineInRange(text: string, start: number, start: number): boolean; -hasSpaces(text: string, index: number, options: object): number; -makeString(rawContent: string, enclosingQuote: string, unescapeUnnecessarEscapes: boolean): string; -getNextNonSpaceNonCommentCharacterIndex(text: string, node: object, options: object): number; -isNextLineEmptyAfterIndex(text: string, index: number): boolean; -isNextLineEmpty(text: string, node: object, options: object): boolean; -isPreviousLineEmpty(text: string, node: object, options: object): boolean; -mapDoc(doc: object, callback: function): void; +type Quote = '"' | "'"; +type SkipOptions = { backwards?: boolean }; +function getMaxContinuousCount(str: string, target: string): number; +function getStringWidth(text: string): number; +function getAlignmentSize(value: string, tabWidth: number, startIndex?: number): number; +function getIndentSize(value: string, tabWidth: number): number; +function skip(chars: string | RegExp): (text: string, index: number | false, opts?: SkipOptions) => number | false; +function skipWhitespace(text: string, index: number | false, opts?: SkipOptions): number | false; +function skipSpaces(text: string, index: number | false, opts?: SkipOptions): number | false; +function skipToLineEnd(text: string, index: number | false, opts?: SkipOptions): number | false; +function skipEverythingButNewLine(text: string, index: number | false, opts?: SkipOptions): number | false; +function skipInlineComment(text: string, index: number | false): number | false; +function skipTrailingComment(text: string, index: number | false): number | false; +function skipNewline(text: string, index: number | false, opts?: SkipOptions): number | false; +function hasNewline(text: string, index: number, opts?: SkipOptions): boolean; +function hasNewlineInRange(text: string, start: number, end: number): boolean; +function hasSpaces(text: string, index: number, opts?: SkipOptions): boolean; +function makeString(rawContent: string, enclosingQuote: Quote, unescapeUnnecessaryEscapes?: boolean): string; +function getNextNonSpaceNonCommentCharacterIndex(text: string, node: N, locEnd: (node: N) => number): number | false; +function isNextLineEmptyAfterIndex(text: string, index: number): boolean; +function isNextLineEmpty(text: string, node: N, locEnd: (node: N) => number): boolean; +function isPreviousLineEmpty(text: string, node: N, locStart: (node: N) => number): boolean; +function mapDoc(doc: object, callback: function): void; ``` ### Tutorials From 816bcf7626e4ce130eb2bffd8a9b21adc438251f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2019 16:17:10 +0200 Subject: [PATCH 19/43] Bump @angular/compiler from 8.2.7 to 8.2.13 (#6803) Bumps [@angular/compiler](https://github.com/angular/angular) from 8.2.7 to 8.2.13. - [Release notes](https://github.com/angular/angular/releases) - [Changelog](https://github.com/angular/angular/blob/master/CHANGELOG.md) - [Commits](https://github.com/angular/angular/compare/8.2.7...8.2.13) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 0fe307bd6..66351969c 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "node": ">=8" }, "dependencies": { - "@angular/compiler": "8.2.7", + "@angular/compiler": "8.2.13", "@babel/code-frame": "7.5.5", "@babel/parser": "7.6.4", "@glimmer/syntax": "0.41.0", diff --git a/yarn.lock b/yarn.lock index bf7ef034f..f141dfaf5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@angular/compiler@8.2.7": - version "8.2.7" - resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-8.2.7.tgz#d5b457359708088ab821b5834c204dcaa8b246dc" - integrity sha512-RLXJMe+YW5a6mOj1Cxx4AkjaZX0JuerPQs4KgKx2mQXRP0LtI4+6qg2+Kds6gIJxUd1Fx9oqAflRGDPchyJaxA== +"@angular/compiler@8.2.13": + version "8.2.13" + resolved "https://registry.yarnpkg.com/@angular/compiler/-/compiler-8.2.13.tgz#76d35761918df8cadeb1624418377712d259347f" + integrity sha512-u2NWCvEn4SjbMvn2PG6sYcf+rR5u3aYMv3/mNQ9k+2UmCIu3yJrcuCzebjo5SdlDVqKD2vzbyMZnr8VB9OcceQ== dependencies: tslib "^1.9.0" @@ -7174,15 +7174,11 @@ trough@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/trough/-/trough-1.0.1.tgz#a9fd8b0394b0ae8fff82e0633a0a36ccad5b5f86" -tslib@^1.10.0: +tslib@^1.10.0, tslib@^1.8.0, tslib@^1.9.0, tslib@^1.9.3: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== -tslib@^1.8.0, tslib@^1.9.0, tslib@^1.9.3: - version "1.9.3" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" - tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" From 069803d0c6b07222f6116063ce72f4f4e7bb41c4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2019 16:17:33 +0200 Subject: [PATCH 20/43] Bump webpack-cli from 3.3.9 to 3.3.10 in /website (#6802) Bumps [webpack-cli](https://github.com/webpack/webpack-cli) from 3.3.9 to 3.3.10. - [Release notes](https://github.com/webpack/webpack-cli/releases) - [Changelog](https://github.com/webpack/webpack-cli/blob/v3.3.10/CHANGELOG.md) - [Commits](https://github.com/webpack/webpack-cli/compare/v3.3.9...v3.3.10) Signed-off-by: dependabot-preview[bot] --- website/package.json | 2 +- website/yarn.lock | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/website/package.json b/website/package.json index 540c326c8..1fb908002 100644 --- a/website/package.json +++ b/website/package.json @@ -28,6 +28,6 @@ "js-yaml": "3.13.1", "svgo": "1.3.2", "webpack": "4.41.2", - "webpack-cli": "3.3.9" + "webpack-cli": "3.3.10" } } diff --git a/website/yarn.lock b/website/yarn.lock index dc72214e6..a0f66d14d 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -4075,15 +4075,11 @@ inquirer@6.5.0: strip-ansi "^5.1.0" through "^2.3.6" -interpret@1.2.0: +interpret@1.2.0, interpret@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296" integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw== -interpret@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" - into-stream@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/into-stream/-/into-stream-3.1.0.tgz#96fb0a936c12babd6ff1752a17d05616abd094c6" @@ -7718,10 +7714,10 @@ webidl-conversions@^4.0.2: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== -webpack-cli@3.3.9: - version "3.3.9" - resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-3.3.9.tgz#79c27e71f94b7fe324d594ab64a8e396b9daa91a" - integrity sha512-xwnSxWl8nZtBl/AFJCOn9pG7s5CYUYdZxmmukv+fAHLcBIHM36dImfpQg3WfShZXeArkWlf6QRw24Klcsv8a5A== +webpack-cli@3.3.10: + version "3.3.10" + resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-3.3.10.tgz#17b279267e9b4fb549023fae170da8e6e766da13" + integrity sha512-u1dgND9+MXaEt74sJR4PR7qkPxXUSQ0RXYq8x1L6Jg1MYVEmGPrH6Ah6C4arD4r0J1P5HKjRqpab36k0eIzPqg== dependencies: chalk "2.4.2" cross-spawn "6.0.5" From dccb13ee114a79a95edad092aa6d2f688032e9a1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2019 16:18:12 +0200 Subject: [PATCH 21/43] Bump eslint-plugin-react from 7.14.3 to 7.16.0 (#6807) Bumps [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) from 7.14.3 to 7.16.0. - [Release notes](https://github.com/yannickcr/eslint-plugin-react/releases) - [Changelog](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md) - [Commits](https://github.com/yannickcr/eslint-plugin-react/compare/v7.14.3...v7.16.0) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 46 ++++++++++++++-------------------------------- 2 files changed, 15 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 66351969c..26932baae 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "eslint-formatter-friendly": "7.0.0", "eslint-plugin-import": "2.18.2", "eslint-plugin-prettier": "3.1.1", - "eslint-plugin-react": "7.14.3", + "eslint-plugin-react": "7.16.0", "execa": "3.2.0", "jest": "23.3.0", "jest-junit": "9.0.0", diff --git a/yarn.lock b/yarn.lock index f141dfaf5..5b100f2b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2718,20 +2718,20 @@ eslint-plugin-prettier@^2.2.0: fast-diff "^1.1.1" jest-docblock "^21.0.0" -eslint-plugin-react@7.14.3: - version "7.14.3" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.14.3.tgz#911030dd7e98ba49e1b2208599571846a66bdf13" - integrity sha512-EzdyyBWC4Uz2hPYBiEJrKCUi2Fn+BJ9B/pJQcjw5X+x/H2Nm59S4MJIvL4O5NEE0+WbnQwEBxWY03oUk+Bc3FA== +eslint-plugin-react@7.16.0: + version "7.16.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.16.0.tgz#9928e4f3e2122ed3ba6a5b56d0303ba3e41d8c09" + integrity sha512-GacBAATewhhptbK3/vTP09CbFrgUJmBSaaRcWdbQLFvUZy9yVcQxigBNHGPU/KE2AyHpzj3AWXpxoMTsIDiHug== dependencies: array-includes "^3.0.3" doctrine "^2.1.0" has "^1.0.3" - jsx-ast-utils "^2.1.0" + jsx-ast-utils "^2.2.1" object.entries "^1.1.0" object.fromentries "^2.0.0" object.values "^1.1.0" prop-types "^15.7.2" - resolve "^1.10.1" + resolve "^1.12.0" eslint-scope@^4.0.3: version "4.0.3" @@ -3234,7 +3234,7 @@ fsevents@^1.1.1, fsevents@^1.1.2: nan "^2.9.2" node-pre-gyp "^0.10.0" -function-bind@^1.0.2, function-bind@^1.1.1: +function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -3470,13 +3470,7 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" -has@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" - dependencies: - function-bind "^1.0.2" - -has@^1.0.3: +has@^1.0.1, has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== @@ -4632,12 +4626,13 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.3.6" -jsx-ast-utils@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.1.0.tgz#0ee4e2c971fb9601c67b5641b71be80faecf0b36" - integrity sha512-yDGDG2DS4JcqhA6blsuYbtsT09xL8AoLuUR2Gb5exrw7UEM19sBcOTq+YBBhrNbl0PUC4R4LnFu+dHg2HKeVvA== +jsx-ast-utils@^2.2.1: + version "2.2.3" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.2.3.tgz#8a9364e402448a3ce7f14d357738310d9248054f" + integrity sha512-EdIHFMm+1BPynpKOpdPqiOsvnIrInRGJD7bzPZdPkjitQEqpdpUuFpq4T0npZFKTiB3RhWFdGN+oqOJIdhDhQA== dependencies: array-includes "^3.0.3" + object.assign "^4.1.0" kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" @@ -6257,26 +6252,13 @@ resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" -resolve@1.12.0, resolve@^1.11.1: +resolve@1.12.0, resolve@^1.1.6, resolve@^1.11.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.3.2, resolve@^1.5.0: version "1.12.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.12.0.tgz#3fc644a35c84a48554609ff26ec52b66fa577df6" integrity sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w== dependencies: path-parse "^1.0.6" -resolve@^1.1.6, resolve@^1.3.2: - version "1.7.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3" - dependencies: - path-parse "^1.0.5" - -resolve@^1.10.1, resolve@^1.11.0, resolve@^1.5.0: - version "1.11.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e" - integrity sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw== - dependencies: - path-parse "^1.0.6" - restore-cursor@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" From 82257bc091b7d2ec0d4bfb36e3ea3a9329680cba Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Tue, 5 Nov 2019 23:18:50 +0900 Subject: [PATCH 22/43] Fix to follow #6811 (#6812) --- website/versioned_docs/version-stable/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/versioned_docs/version-stable/index.md b/website/versioned_docs/version-stable/index.md index bbfe71453..0de7d5d10 100644 --- a/website/versioned_docs/version-stable/index.md +++ b/website/versioned_docs/version-stable/index.md @@ -12,12 +12,12 @@ Prettier is an opinionated code formatter with support for: - [Vue](https://vuejs.org/) - [Flow](https://flow.org/) - [TypeScript](https://www.typescriptlang.org/) -- CSS, [Less](http://lesscss.org/), and [SCSS](http://sass-lang.com) +- CSS, [Less](http://lesscss.org/), and [SCSS](https://sass-lang.com) - [HTML](https://en.wikipedia.org/wiki/HTML) - [JSON](http://json.org/) -- [GraphQL](http://graphql.org/) -- [Markdown](http://commonmark.org/), including [GFM](https://github.github.com/gfm/) and [MDX](https://mdxjs.com/) -- [YAML](http://yaml.org/) +- [GraphQL](https://graphql.org/) +- [Markdown](https://commonmark.org/), including [GFM](https://github.github.com/gfm/) and [MDX](https://mdxjs.com/) +- [YAML](https://yaml.org/) It removes all original styling[\*](#footnotes) and ensures that all outputted code conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Prettier-Formatter)) From 9d2f5e0e584cad4f8bab3b0bf6c278e3f359d094 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2019 19:08:14 +0100 Subject: [PATCH 23/43] Bump terser-webpack-plugin from 2.1.3 to 2.2.1 (#6819) Bumps [terser-webpack-plugin](https://github.com/webpack-contrib/terser-webpack-plugin) from 2.1.3 to 2.2.1. - [Release notes](https://github.com/webpack-contrib/terser-webpack-plugin/releases) - [Changelog](https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v2.1.3...v2.2.1) Signed-off-by: dependabot-preview[bot] Co-authored-by: null <27856297+dependabot-preview[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 26932baae..90d460e25 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "strip-ansi": "5.2.0", "synchronous-promise": "2.0.10", "tempy": "0.2.1", - "terser-webpack-plugin": "2.1.3", + "terser-webpack-plugin": "2.2.1", "webpack": "4.41.2" }, "scripts": { diff --git a/yarn.lock b/yarn.lock index 5b100f2b5..3ed7c757d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6458,10 +6458,10 @@ schema-utils@^1.0.0: ajv-errors "^1.0.0" ajv-keywords "^3.1.0" -schema-utils@^2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.4.1.tgz#e89ade5d056dc8bcaca377574bb4a9c4e1b8be56" - integrity sha512-RqYLpkPZX5Oc3fw/kHHHyP56fg5Y+XBpIpV8nCg0znIALfq3OH+Ea9Hfeac9BAMwG5IICltiZ0vxFvJQONfA5w== +schema-utils@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.5.0.tgz#8f254f618d402cc80257486213c8970edfd7c22f" + integrity sha512-32ISrwW2scPXHUSusP8qMg5dLUawKkyV+/qIEV9JdXKx+rsM6mi8vZY8khg2M69Qom16rtroWXD3Ybtiws38gQ== dependencies: ajv "^6.10.2" ajv-keywords "^3.4.1" @@ -6999,18 +6999,18 @@ tempy@0.2.1: temp-dir "^1.0.0" unique-string "^1.0.0" -terser-webpack-plugin@2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-2.1.3.tgz#85430da71ba88a60072bf659589eafaf6a00dc22" - integrity sha512-z5Utx0TxmirZvRNL1GC795tlDM+bO83ZfcbtkL1y1VLoWtZ7S2a9+HFCLnabSRE/Yjsu4zCEX6U6CIRo4dVmcQ== +terser-webpack-plugin@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-2.2.1.tgz#5569e6c7d8be79e5e43d6da23acc3b6ba77d22bd" + integrity sha512-jwdauV5Al7zopR6OAYvIIRcxXCSvLjZjr7uZE8l2tIWb/ryrGN48sJftqGf5k9z09tWhajx53ldp0XPI080YnA== dependencies: cacache "^13.0.1" find-cache-dir "^3.0.0" jest-worker "^24.9.0" - schema-utils "^2.4.1" + schema-utils "^2.5.0" serialize-javascript "^2.1.0" source-map "^0.6.1" - terser "^4.3.8" + terser "^4.3.9" webpack-sources "^1.4.3" terser-webpack-plugin@^1.4.1: @@ -7028,10 +7028,10 @@ terser-webpack-plugin@^1.4.1: webpack-sources "^1.4.0" worker-farm "^1.7.0" -terser@^4.1.0, terser@^4.1.2, terser@^4.3.8: - version "4.3.8" - resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.8.tgz#707f05f3f4c1c70c840e626addfdb1c158a17136" - integrity sha512-otmIRlRVmLChAWsnSFNO0Bfk6YySuBp6G9qrHiJwlLDd4mxe2ta4sjI7TzIR+W1nBMjilzrMcPOz9pSusgx3hQ== +terser@^4.1.0, terser@^4.1.2, terser@^4.3.9: + version "4.3.9" + resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.9.tgz#e4be37f80553d02645668727777687dad26bbca8" + integrity sha512-NFGMpHjlzmyOtPL+fDw3G7+6Ueh/sz4mkaUYa4lJCxOPTNzd0Uj0aZJOmsDYoSQyfuVoWDMSWTPU3huyOm2zdA== dependencies: commander "^2.20.0" source-map "~0.6.1" From 1df4c1721a748f61211273b5b6c38f387d2c1501 Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Tue, 5 Nov 2019 21:08:41 +0200 Subject: [PATCH 24/43] update Babel to 7.7.0 and enable error recovery (#6816) --- cspell.json | 7 +- package.json | 6 +- src/language-js/clean.js | 3 +- src/language-js/parser-babylon.js | 1 + src/language-js/printer-estree-json.js | 1 + .../__snapshots__/jsfmt.spec.js.snap | 16 + tests/js_invalid_code/duplicate_bindings.js | 1 + tests/js_invalid_code/jsfmt.spec.js | 1 + yarn.lock | 469 ++++++++++-------- 9 files changed, 291 insertions(+), 214 deletions(-) create mode 100644 tests/js_invalid_code/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/js_invalid_code/duplicate_bindings.js create mode 100644 tests/js_invalid_code/jsfmt.spec.js diff --git a/cspell.json b/cspell.json index b57e67bef..724cc709d 100644 --- a/cspell.json +++ b/cspell.json @@ -91,8 +91,8 @@ "editorconfig", "ekkhus", "elektronik", - "ENOENT", "Eneman", + "ENOENT", "ericsakmar", "Ericsburgh", "Esben", @@ -393,6 +393,7 @@ "\\n(`{3,})\\w*\\n[\\s\\S]+?\\1", "\\[@\\w+?\\]", "\\[`\\w+`\\]", - "ve+r+y+(long\\w+)?" + "ve{2,}r{2,}y", + "ve+r+y+long\\w*" ] -} +} \ No newline at end of file diff --git a/package.json b/package.json index 90d460e25..06b46c467 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "dependencies": { "@angular/compiler": "8.2.13", "@babel/code-frame": "7.5.5", - "@babel/parser": "7.6.4", + "@babel/parser": "7.7.0", "@glimmer/syntax": "0.41.0", "@iarna/toml": "2.2.3", "@typescript-eslint/typescript-estree": "2.6.0", @@ -74,8 +74,8 @@ "yaml-unist-parser": "1.1.1" }, "devDependencies": { - "@babel/core": "7.6.3", - "@babel/preset-env": "7.6.3", + "@babel/core": "7.7.0", + "@babel/preset-env": "7.7.1", "@rollup/plugin-alias": "2.2.0", "@rollup/plugin-replace": "2.2.0", "babel-loader": "8.0.6", diff --git a/src/language-js/clean.js b/src/language-js/clean.js index ee1209be5..2801323f8 100644 --- a/src/language-js/clean.js +++ b/src/language-js/clean.js @@ -10,7 +10,8 @@ function clean(ast, newObj, parent) { "extra", "start", "end", - "flags" + "flags", + "errors" ].forEach(name => { delete newObj[name]; }); diff --git a/src/language-js/parser-babylon.js b/src/language-js/parser-babylon.js index 6d81940fb..f4fc59024 100644 --- a/src/language-js/parser-babylon.js +++ b/src/language-js/parser-babylon.js @@ -17,6 +17,7 @@ function babelOptions(extraOptions, extraPlugins) { allowReturnOutsideFunction: true, allowSuperOutsideMethod: true, allowUndeclaredExports: true, + errorRecovery: true, plugins: [ "jsx", "doExpressions", diff --git a/src/language-js/printer-estree-json.js b/src/language-js/printer-estree-json.js index 5f82f15d3..2b5348272 100644 --- a/src/language-js/printer-estree-json.js +++ b/src/language-js/printer-estree-json.js @@ -64,6 +64,7 @@ function clean(node, newNode /*, parent*/) { delete newNode.extra; delete newNode.loc; delete newNode.comments; + delete newNode.errors; if (node.type === "Identifier") { return { type: "StringLiteral", value: node.name }; diff --git a/tests/js_invalid_code/__snapshots__/jsfmt.spec.js.snap b/tests/js_invalid_code/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..f0e61b66a --- /dev/null +++ b/tests/js_invalid_code/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`duplicate_bindings.js 1`] = ` +====================================options===================================== +parsers: ["babel"] +printWidth: 80 + | printWidth +=====================================input====================================== +class A{} class A{} + +=====================================output===================================== +class A {} +class A {} + +================================================================================ +`; diff --git a/tests/js_invalid_code/duplicate_bindings.js b/tests/js_invalid_code/duplicate_bindings.js new file mode 100644 index 000000000..2a8e8ef14 --- /dev/null +++ b/tests/js_invalid_code/duplicate_bindings.js @@ -0,0 +1 @@ +class A{} class A{} diff --git a/tests/js_invalid_code/jsfmt.spec.js b/tests/js_invalid_code/jsfmt.spec.js new file mode 100644 index 000000000..8382eddeb --- /dev/null +++ b/tests/js_invalid_code/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["babel"]); diff --git a/yarn.lock b/yarn.lock index 3ed7c757d..91819b38f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28,25 +28,25 @@ dependencies: "@babel/highlight" "7.0.0-beta.46" -"@babel/core@7.6.3": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.6.3.tgz#44de824e89eaa089bb12da7337bc9bdff2ab68f9" - integrity sha512-QfQ5jTBgXLzJuo7Mo8bZK/ePywmgNRgk/UQykiKwEtZPiFIn8ZqE6jB+AnD1hbB1S2xQyL4//it5vuAUOVAMTw== +"@babel/core@7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.7.0.tgz#461d2948b1a7113088baf999499bcbd39a7faa3b" + integrity sha512-Bb1NjZCaiwTQC/ARL+MwDpgocdnwWDCaugvkGt6cxfBzQa8Whv1JybBoUEiBDKl8Ni3H3c7Fykwk7QChUsHRlg== dependencies: "@babel/code-frame" "^7.5.5" - "@babel/generator" "^7.6.3" - "@babel/helpers" "^7.6.2" - "@babel/parser" "^7.6.3" - "@babel/template" "^7.6.0" - "@babel/traverse" "^7.6.3" - "@babel/types" "^7.6.3" + "@babel/generator" "^7.7.0" + "@babel/helpers" "^7.7.0" + "@babel/parser" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" convert-source-map "^1.1.0" debug "^4.1.0" json5 "^2.1.0" lodash "^4.17.13" resolve "^1.3.2" semver "^5.4.1" - source-map "^0.6.1" + source-map "^0.5.0" "@babel/generator@^7.1.5": version "7.1.5" @@ -80,32 +80,29 @@ source-map "^0.5.0" trim-right "^1.0.1" -"@babel/generator@^7.6.2": - version "7.6.2" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.6.2.tgz#dac8a3c2df118334c2a29ff3446da1636a8f8c03" - integrity sha512-j8iHaIW4gGPnViaIHI7e9t/Hl8qLjERI6DcV9kEpAIDJsAOrcnXqRS7t+QbhL76pwbtqP+QCQLL0z1CyVmtjjQ== +"@babel/generator@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.7.0.tgz#c6d4d1f7a0d6e139cbd01aca73170b0bff5425b4" + integrity sha512-1wdJ6UxHyL1XoJQ119JmvuRX27LRih7iYStMPZOWAjQqeAabFg3dYXKMpgihma+to+0ADsTVVt6oRyUxWZw6Mw== dependencies: - "@babel/types" "^7.6.0" + "@babel/types" "^7.7.0" jsesc "^2.5.1" lodash "^4.17.13" source-map "^0.5.0" -"@babel/generator@^7.6.3": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.6.3.tgz#71d5375264f93ec7bac7d9f35a67067733f5578e" - integrity sha512-hLhYbAb3pHwxjlijC4AQ7mqZdcoujiNaW7izCT04CIowHK8psN0IN8QjDv0iyFtycF5FowUOTwDloIheI25aMw== - dependencies: - "@babel/types" "^7.6.3" - jsesc "^2.5.1" - lodash "^4.17.13" - source-map "^0.6.1" - "@babel/helper-annotate-as-pure@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32" dependencies: "@babel/types" "^7.0.0" +"@babel/helper-annotate-as-pure@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.7.0.tgz#efc54032d43891fe267679e63f6860aa7dbf4a5e" + integrity sha512-k50CQxMlYTYo+GGyUGFwpxKVtxVJi9yh61sXZji3zYHccK9RYliZGSTOgci85T+r+0VFN2nWbGM04PIqwfrpMg== + dependencies: + "@babel/types" "^7.7.0" + "@babel/helper-builder-binary-assignment-operator-visitor@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.1.0.tgz#6b69628dfe4087798e0c4ed98e3d4a6b2fbd2f5f" @@ -122,13 +119,21 @@ "@babel/traverse" "^7.4.4" "@babel/types" "^7.4.4" -"@babel/helper-define-map@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.5.5.tgz#3dec32c2046f37e09b28c93eb0b103fd2a25d369" - integrity sha512-fTfxx7i0B5NJqvUOBBGREnrqbTxRh7zinBANpZXAVDlsZxYdclDp467G1sQ8VZYMnAURY3RpBUAgOYT9GfzHBg== +"@babel/helper-create-regexp-features-plugin@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.7.0.tgz#2e8badfe201cfafb5d930f46cf1e0b6f1cdcab23" + integrity sha512-ZhagAAVGD3L6MPM9/zZi7RRteonfBFLVUz3kjsnYsMAtr9hOJCKI9BAKIMpqn3NyWicPieoX779UL+7/3BEAOA== dependencies: - "@babel/helper-function-name" "^7.1.0" - "@babel/types" "^7.5.5" + "@babel/helper-regex" "^7.4.4" + regexpu-core "^4.6.0" + +"@babel/helper-define-map@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.7.0.tgz#60b0e9fd60def9de5054c38afde8c8ee409c7529" + integrity sha512-kPKWPb0dMpZi+ov1hJiwse9dWweZsz3V9rP4KdytnX1E7z3cTNmFGglwklzFPuqIcHLIY3bgKSs4vkwXXdflQA== + dependencies: + "@babel/helper-function-name" "^7.7.0" + "@babel/types" "^7.7.0" lodash "^4.17.13" "@babel/helper-explode-assignable-expression@^7.1.0": @@ -146,12 +151,28 @@ "@babel/template" "^7.1.0" "@babel/types" "^7.0.0" +"@babel/helper-function-name@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz#44a5ad151cfff8ed2599c91682dda2ec2c8430a3" + integrity sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q== + dependencies: + "@babel/helper-get-function-arity" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/types" "^7.7.0" + "@babel/helper-get-function-arity@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" dependencies: "@babel/types" "^7.0.0" +"@babel/helper-get-function-arity@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz#c604886bc97287a1d1398092bc666bc3d7d7aa2d" + integrity sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw== + dependencies: + "@babel/types" "^7.7.0" + "@babel/helper-hoist-variables@^7.4.4": version "7.4.4" resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.4.tgz#0298b5f25c8c09c53102d52ac4a98f773eb2850a" @@ -159,6 +180,13 @@ dependencies: "@babel/types" "^7.4.4" +"@babel/helper-hoist-variables@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.7.0.tgz#b4552e4cfe5577d7de7b183e193e84e4ec538c81" + integrity sha512-LUe/92NqsDAkJjjCEWkNe+/PcpnisvnqdlRe19FahVapa4jndeuJ+FBiTX1rcAKWKcJGE+C3Q3tuEuxkSmCEiQ== + dependencies: + "@babel/types" "^7.7.0" + "@babel/helper-member-expression-to-functions@^7.5.5": version "7.5.5" resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.5.5.tgz#1fb5b8ec4453a93c439ee9fe3aeea4a84b76b590" @@ -166,12 +194,26 @@ dependencies: "@babel/types" "^7.5.5" +"@babel/helper-member-expression-to-functions@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.7.0.tgz#472b93003a57071f95a541ea6c2b098398bcad8a" + integrity sha512-QaCZLO2RtBcmvO/ekOLp8p7R5X2JriKRizeDpm5ChATAFWrrYDcDxPuCIBXKyBjY+i1vYSdcUTMIb8psfxHDPA== + dependencies: + "@babel/types" "^7.7.0" + "@babel/helper-module-imports@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz#96081b7111e486da4d2cd971ad1a4fe216cc2e3d" dependencies: "@babel/types" "^7.0.0" +"@babel/helper-module-imports@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.7.0.tgz#99c095889466e5f7b6d66d98dffc58baaf42654d" + integrity sha512-Dv3hLKIC1jyfTkClvyEkYP2OlkzNvWs5+Q8WgPbxM5LMeorons7iPP91JM+DU7tRbhqA1ZeooPaMFvQrn23RHw== + dependencies: + "@babel/types" "^7.7.0" + "@babel/helper-module-transforms@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.1.0.tgz#470d4f9676d9fad50b324cdcce5fbabbc3da5787" @@ -183,17 +225,17 @@ "@babel/types" "^7.0.0" lodash "^4.17.10" -"@babel/helper-module-transforms@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.4.4.tgz#96115ea42a2f139e619e98ed46df6019b94414b8" - integrity sha512-3Z1yp8TVQf+B4ynN7WoHPKS8EkdTbgAEy0nU0rs/1Kw4pDgmvYH3rz3aI11KgxKCba2cn7N+tqzV1mY2HMN96w== +"@babel/helper-module-transforms@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.7.0.tgz#154a69f0c5b8fd4d39e49750ff7ac4faa3f36786" + integrity sha512-rXEefBuheUYQyX4WjV19tuknrJFwyKw0HgzRwbkyTbB+Dshlq7eqkWbyjzToLrMZk/5wKVKdWFluiAsVkHXvuQ== dependencies: - "@babel/helper-module-imports" "^7.0.0" - "@babel/helper-simple-access" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.4.4" - "@babel/template" "^7.4.4" - "@babel/types" "^7.4.4" - lodash "^4.17.11" + "@babel/helper-module-imports" "^7.7.0" + "@babel/helper-simple-access" "^7.7.0" + "@babel/helper-split-export-declaration" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/types" "^7.7.0" + lodash "^4.17.13" "@babel/helper-optimise-call-expression@^7.0.0": version "7.0.0" @@ -201,6 +243,13 @@ dependencies: "@babel/types" "^7.0.0" +"@babel/helper-optimise-call-expression@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.7.0.tgz#4f66a216116a66164135dc618c5d8b7a959f9365" + integrity sha512-48TeqmbazjNU/65niiiJIJRc5JozB8acui1OS7bSd6PgxfuovWsvjfWSzlgx+gPFdVveNzUdpdIg5l56Pl5jqg== + dependencies: + "@babel/types" "^7.7.0" + "@babel/helper-plugin-utils@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250" @@ -218,15 +267,16 @@ dependencies: lodash "^4.17.11" -"@babel/helper-remap-async-to-generator@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz#361d80821b6f38da75bd3f0785ece20a88c5fe7f" +"@babel/helper-remap-async-to-generator@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.7.0.tgz#4d69ec653e8bff5bce62f5d33fc1508f223c75a7" + integrity sha512-pHx7RN8X0UNHPB/fnuDnRXVZ316ZigkO8y8D835JlZ2SSdFKb6yH9MIYRU4fy/KPe5sPHDFOPvf8QLdbAGGiyw== dependencies: - "@babel/helper-annotate-as-pure" "^7.0.0" - "@babel/helper-wrap-function" "^7.1.0" - "@babel/template" "^7.1.0" - "@babel/traverse" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/helper-annotate-as-pure" "^7.7.0" + "@babel/helper-wrap-function" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" "@babel/helper-replace-supers@^7.5.5": version "7.5.5" @@ -238,6 +288,16 @@ "@babel/traverse" "^7.5.5" "@babel/types" "^7.5.5" +"@babel/helper-replace-supers@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.7.0.tgz#d5365c8667fe7cbd13b8ddddceb9bd7f2b387512" + integrity sha512-5ALYEul5V8xNdxEeWvRsBzLMxQksT7MaStpxjJf9KsnLxpAKBtfw5NeMKZJSYDa0lKdOcy0g+JT/f5mPSulUgg== + dependencies: + "@babel/helper-member-expression-to-functions" "^7.7.0" + "@babel/helper-optimise-call-expression" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" + "@babel/helper-simple-access@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz#65eeb954c8c245beaa4e859da6188f39d71e585c" @@ -245,6 +305,14 @@ "@babel/template" "^7.1.0" "@babel/types" "^7.0.0" +"@babel/helper-simple-access@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.7.0.tgz#97a8b6c52105d76031b86237dc1852b44837243d" + integrity sha512-AJ7IZD7Eem3zZRuj5JtzFAptBw7pMlS3y8Qv09vaBWoFsle0d1kAn5Wq6Q9MyBXITPOKnxwkZKoAm4bopmv26g== + dependencies: + "@babel/template" "^7.7.0" + "@babel/types" "^7.7.0" + "@babel/helper-split-export-declaration@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz#3aae285c0311c2ab095d997b8c9a94cad547d813" @@ -258,23 +326,31 @@ dependencies: "@babel/types" "^7.4.4" -"@babel/helper-wrap-function@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.1.0.tgz#8cf54e9190706067f016af8f75cb3df829cc8c66" +"@babel/helper-split-export-declaration@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.0.tgz#1365e74ea6c614deeb56ebffabd71006a0eb2300" + integrity sha512-HgYSI8rH08neWlAH3CcdkFg9qX9YsZysZI5GD8LjhQib/mM0jGOZOVkoUiiV2Hu978fRtjtsGsW6w0pKHUWtqA== dependencies: - "@babel/helper-function-name" "^7.1.0" - "@babel/template" "^7.1.0" - "@babel/traverse" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/types" "^7.7.0" -"@babel/helpers@^7.6.2": - version "7.6.2" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.6.2.tgz#681ffe489ea4dcc55f23ce469e58e59c1c045153" - integrity sha512-3/bAUL8zZxYs1cdX2ilEE0WobqbCmKWr/889lf2SS0PpDcpEIY8pb1CCyz0pEcX3pEb+MCbks1jIokz2xLtGTA== +"@babel/helper-wrap-function@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.7.0.tgz#15af3d3e98f8417a60554acbb6c14e75e0b33b74" + integrity sha512-sd4QjeMgQqzshSjecZjOp8uKfUtnpmCyQhKQrVJBBgeHAB/0FPi33h3AbVlVp07qQtMD4QgYSzaMI7VwncNK/w== dependencies: - "@babel/template" "^7.6.0" - "@babel/traverse" "^7.6.2" - "@babel/types" "^7.6.0" + "@babel/helper-function-name" "^7.7.0" + "@babel/template" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" + +"@babel/helpers@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.7.0.tgz#359bb5ac3b4726f7c1fde0ec75f64b3f4275d60b" + integrity sha512-VnNwL4YOhbejHb7x/b5F39Zdg5vIQpUUNzJwx0ww1EcVRt41bbGRZWhAURrfY32T5zTT3qwNOQFWpn+P0i0a2g== + dependencies: + "@babel/template" "^7.7.0" + "@babel/traverse" "^7.7.0" + "@babel/types" "^7.7.0" "@babel/highlight@7.0.0-beta.46": version "7.0.0-beta.46" @@ -292,23 +368,29 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@7.6.4", "@babel/parser@^7.1.2", "@babel/parser@^7.1.5", "@babel/parser@^7.4.4", "@babel/parser@^7.4.5", "@babel/parser@^7.5.5", "@babel/parser@^7.6.0", "@babel/parser@^7.6.2", "@babel/parser@^7.6.3": +"@babel/parser@7.7.0", "@babel/parser@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.0.tgz#232618f6e8947bc54b407fa1f1c91a22758e7159" + integrity sha512-GqL+Z0d7B7ADlQBMXlJgvXEbtt5qlqd1YQ5fr12hTSfh7O/vgrEIvJxU2e7aSVrEUn75zTZ6Nd0s8tthrlZnrQ== + +"@babel/parser@^7.1.2", "@babel/parser@^7.1.5", "@babel/parser@^7.4.5", "@babel/parser@^7.5.5": version "7.6.4" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.4.tgz#cb9b36a7482110282d5cb6dd424ec9262b473d81" integrity sha512-D8RHPW5qd0Vbyo3qb+YjO5nvUVRTXFLQ/FsDxJU2Nqz4uB5EnUN0ZQSEYpvTIbRuttig1XbHWU5oMeQwQSAA+A== -"@babel/plugin-proposal-async-generator-functions@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz#b289b306669dce4ad20b0252889a15768c9d417e" +"@babel/plugin-proposal-async-generator-functions@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.7.0.tgz#83ef2d6044496b4c15d8b4904e2219e6dccc6971" + integrity sha512-ot/EZVvf3mXtZq0Pd0+tSOfGWMizqmOohXmNZg6LNFjHOV+wOPv7BvVYh8oPR8LhpIP3ye8nNooKL50YRWxpYA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-remap-async-to-generator" "^7.1.0" + "@babel/helper-remap-async-to-generator" "^7.7.0" "@babel/plugin-syntax-async-generators" "^7.2.0" -"@babel/plugin-proposal-dynamic-import@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.5.0.tgz#e532202db4838723691b10a67b8ce509e397c506" - integrity sha512-x/iMjggsKTFHYC6g11PL7Qy58IK8H5zqfm9e6hu4z1iH2IRyAp9u9dL80zA6R76yFovETFLKz2VJIC2iIPBuFw== +"@babel/plugin-proposal-dynamic-import@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.7.0.tgz#dc02a8bad8d653fb59daf085516fa416edd2aa7f" + integrity sha512-7poL3Xi+QFPC7sGAzEIbXUyYzGJwbc2+gSD0AkiC5k52kH2cqHdqxm5hNFfLW3cRSTcx9bN0Fl7/6zWcLLnKAQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-dynamic-import" "^7.2.0" @@ -335,14 +417,13 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" -"@babel/plugin-proposal-unicode-property-regex@^7.6.2": - version "7.6.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.6.2.tgz#05413762894f41bfe42b9a5e80919bd575dcc802" - integrity sha512-NxHETdmpeSCtiatMRYWVJo7266rrvAC3DTeG5exQBIH/fMIUK7ejDNznBbn3HQl/o9peymRRg7Yqkx6PdUXmMw== +"@babel/plugin-proposal-unicode-property-regex@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.7.0.tgz#549fe1717a1bd0a2a7e63163841cb37e78179d5d" + integrity sha512-mk34H+hp7kRBWJOOAR0ZMGCydgKMD4iN9TpDRp3IIcbunltxEY89XSimc6WbtSLCDrwcdy/EEw7h5CFCzxTchw== dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-regex" "^7.4.4" - regexpu-core "^4.6.0" "@babel/plugin-syntax-async-generators@^7.2.0": version "7.2.0" @@ -375,20 +456,27 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-syntax-top-level-await@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.7.0.tgz#f5699549f50bbe8d12b1843a4e82f0a37bb65f4d" + integrity sha512-hi8FUNiFIY1fnUI2n1ViB1DR0R4QeK4iHcTlW6aJkrPoTdb8Rf1EMQ6GT3f67DDkYyWgew9DFoOZ6gOoEsdzTA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-transform-arrow-functions@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.2.0.tgz#9aeafbe4d6ffc6563bf8f8372091628f00779550" dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-async-to-generator@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.5.0.tgz#89a3848a0166623b5bc481164b5936ab947e887e" - integrity sha512-mqvkzwIGkq0bEF1zLRRiTdjfomZJDV33AH3oQzHVGkI2VzEmXLpKKOBvEVaFZBJdN0XTyH38s9j/Kiqr68dggg== +"@babel/plugin-transform-async-to-generator@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.7.0.tgz#e2b84f11952cf5913fe3438b7d2585042772f492" + integrity sha512-vLI2EFLVvRBL3d8roAMqtVY0Bm9C1QzLkdS57hiKrjUBSqsQYrBsMCeOg/0KK7B0eK9V71J5mWcha9yyoI2tZw== dependencies: - "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-module-imports" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-remap-async-to-generator" "^7.1.0" + "@babel/helper-remap-async-to-generator" "^7.7.0" "@babel/plugin-transform-block-scoped-functions@^7.2.0": version "7.2.0" @@ -404,18 +492,18 @@ "@babel/helper-plugin-utils" "^7.0.0" lodash "^4.17.13" -"@babel/plugin-transform-classes@^7.5.5": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.5.5.tgz#d094299d9bd680a14a2a0edae38305ad60fb4de9" - integrity sha512-U2htCNK/6e9K7jGyJ++1p5XRU+LJjrwtoiVn9SzRlDT2KubcZ11OOwy3s24TjHxPgxNwonCYP7U2K51uVYCMDg== +"@babel/plugin-transform-classes@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.7.0.tgz#b411ecc1b8822d24b81e5d184f24149136eddd4a" + integrity sha512-/b3cKIZwGeUesZheU9jNYcwrEA7f/Bo4IdPmvp7oHgvks2majB5BoT5byAql44fiNQYOPzhk2w8DbgfuafkMoA== dependencies: - "@babel/helper-annotate-as-pure" "^7.0.0" - "@babel/helper-define-map" "^7.5.5" - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-optimise-call-expression" "^7.0.0" + "@babel/helper-annotate-as-pure" "^7.7.0" + "@babel/helper-define-map" "^7.7.0" + "@babel/helper-function-name" "^7.7.0" + "@babel/helper-optimise-call-expression" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-replace-supers" "^7.5.5" - "@babel/helper-split-export-declaration" "^7.4.4" + "@babel/helper-replace-supers" "^7.7.0" + "@babel/helper-split-export-declaration" "^7.7.0" globals "^11.1.0" "@babel/plugin-transform-computed-properties@^7.2.0": @@ -431,14 +519,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-dotall-regex@^7.6.2": - version "7.6.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.6.2.tgz#44abb948b88f0199a627024e1508acaf8dc9b2f9" - integrity sha512-KGKT9aqKV+9YMZSkowzYoYEiHqgaDhGmPNZlZxX6UeHC4z30nC1J9IrZuGqbYFB1jaIGdv91ujpze0exiVK8bA== +"@babel/plugin-transform-dotall-regex@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.7.0.tgz#c5c9ecacab3a5e0c11db6981610f0c32fd698b3b" + integrity sha512-3QQlF7hSBnSuM1hQ0pS3pmAbWLax/uGNCbPBND9y+oJ4Y776jsyujG2k0Sn2Aj2a0QwVOiOFL5QVPA7spjvzSA== dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-regex" "^7.4.4" - regexpu-core "^4.6.0" "@babel/plugin-transform-duplicate-keys@^7.5.0": version "7.5.0" @@ -461,12 +548,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-function-name@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.4.4.tgz#e1436116abb0610c2259094848754ac5230922ad" - integrity sha512-iU9pv7U+2jC9ANQkKeNF6DrPy4GBa4NWQtl6dHB4Pb3izX2JOEvDTFarlNsBj/63ZEzNNIAMs3Qw4fNCcSOXJA== +"@babel/plugin-transform-function-name@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.7.0.tgz#0fa786f1eef52e3b7d4fc02e54b2129de8a04c2a" + integrity sha512-P5HKu0d9+CzZxP5jcrWdpe7ZlFDe24bmqP6a6X8BHEBl/eizAsY8K6LX8LASZL0Jxdjm5eEfzp+FIrxCm/p8bA== dependencies: - "@babel/helper-function-name" "^7.1.0" + "@babel/helper-function-name" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-literals@^7.2.0": @@ -491,38 +578,39 @@ "@babel/helper-plugin-utils" "^7.0.0" babel-plugin-dynamic-import-node "^2.3.0" -"@babel/plugin-transform-modules-commonjs@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.6.0.tgz#39dfe957de4420445f1fcf88b68a2e4aa4515486" - integrity sha512-Ma93Ix95PNSEngqomy5LSBMAQvYKVe3dy+JlVJSHEXZR5ASL9lQBedMiCyVtmTLraIDVRE3ZjTZvmXXD2Ozw3g== +"@babel/plugin-transform-modules-commonjs@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.7.0.tgz#3e5ffb4fd8c947feede69cbe24c9554ab4113fe3" + integrity sha512-KEMyWNNWnjOom8vR/1+d+Ocz/mILZG/eyHHO06OuBQ2aNhxT62fr4y6fGOplRx+CxCSp3IFwesL8WdINfY/3kg== dependencies: - "@babel/helper-module-transforms" "^7.4.4" + "@babel/helper-module-transforms" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-simple-access" "^7.1.0" + "@babel/helper-simple-access" "^7.7.0" babel-plugin-dynamic-import-node "^2.3.0" -"@babel/plugin-transform-modules-systemjs@^7.5.0": - version "7.5.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.5.0.tgz#e75266a13ef94202db2a0620977756f51d52d249" - integrity sha512-Q2m56tyoQWmuNGxEtUyeEkm6qJYFqs4c+XyXH5RAuYxObRNz9Zgj/1g2GMnjYp2EUyEy7YTrxliGCXzecl/vJg== +"@babel/plugin-transform-modules-systemjs@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.7.0.tgz#9baf471213af9761c1617bb12fd278e629041417" + integrity sha512-ZAuFgYjJzDNv77AjXRqzQGlQl4HdUM6j296ee4fwKVZfhDR9LAGxfvXjBkb06gNETPnN0sLqRm9Gxg4wZH6dXg== dependencies: - "@babel/helper-hoist-variables" "^7.4.4" + "@babel/helper-hoist-variables" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" babel-plugin-dynamic-import-node "^2.3.0" -"@babel/plugin-transform-modules-umd@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.2.0.tgz#7678ce75169f0877b8eb2235538c074268dd01ae" +"@babel/plugin-transform-modules-umd@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.7.0.tgz#d62c7da16670908e1d8c68ca0b5d4c0097b69966" + integrity sha512-u7eBA03zmUswQ9LQ7Qw0/ieC1pcAkbp5OQatbWUzY1PaBccvuJXUkYzoN1g7cqp7dbTu6Dp9bXyalBvD04AANA== dependencies: - "@babel/helper-module-transforms" "^7.1.0" + "@babel/helper-module-transforms" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-named-capturing-groups-regex@^7.6.3": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.6.3.tgz#aaa6e409dd4fb2e50b6e2a91f7e3a3149dbce0cf" - integrity sha512-jTkk7/uE6H2s5w6VlMHeWuH+Pcy2lmdwFoeWCVnvIrDUnB5gQqTVI8WfmEAhF2CDEarGrknZcmSFg1+bkfCoSw== +"@babel/plugin-transform-named-capturing-groups-regex@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.7.0.tgz#358e6fd869b9a4d8f5cbc79e4ed4fc340e60dcaf" + integrity sha512-+SicSJoKouPctL+j1pqktRVCgy+xAch1hWWTMy13j0IflnyNjaoskj+DwRQFimHbLqO3sq2oN2CXMvXq3Bgapg== dependencies: - regexpu-core "^4.6.0" + "@babel/helper-create-regexp-features-plugin" "^7.7.0" "@babel/plugin-transform-new-target@^7.4.4": version "7.4.4" @@ -555,10 +643,10 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-regenerator@^7.4.5": - version "7.4.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.4.5.tgz#629dc82512c55cee01341fb27bdfcb210354680f" - integrity sha512-gBKRh5qAaCWntnd09S8QC7r3auLCqq5DI6O0DlfoyDjslSBVqBibrMdsqO+Uhmx3+BlOmE/Kw1HFxmGbv0N9dA== +"@babel/plugin-transform-regenerator@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.7.0.tgz#f1b20b535e7716b622c99e989259d7dd942dd9cc" + integrity sha512-AXmvnC+0wuj/cFkkS/HFHIojxH3ffSXE+ttulrqWjZZRaUOonfJc60e1wSNT4rV8tIunvu/R3wCp71/tLAa9xg== dependencies: regenerator-transform "^0.14.0" @@ -603,65 +691,65 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-unicode-regex@^7.6.2": - version "7.6.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.6.2.tgz#b692aad888a7e8d8b1b214be6b9dc03d5031f698" - integrity sha512-orZI6cWlR3nk2YmYdb0gImrgCUwb5cBUwjf6Ks6dvNVvXERkwtJWOQaEOjPiu0Gu1Tq6Yq/hruCZZOOi9F34Dw== +"@babel/plugin-transform-unicode-regex@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.7.0.tgz#743d9bcc44080e3cc7d49259a066efa30f9187a3" + integrity sha512-RrThb0gdrNwFAqEAAx9OWgtx6ICK69x7i9tCnMdVrxQwSDp/Abu9DXFU5Hh16VP33Rmxh04+NGW28NsIkFvFKA== dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-regex" "^7.4.4" - regexpu-core "^4.6.0" -"@babel/preset-env@7.6.3": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.6.3.tgz#9e1bf05a2e2d687036d24c40e4639dc46cef2271" - integrity sha512-CWQkn7EVnwzlOdR5NOm2+pfgSNEZmvGjOhlCHBDq0J8/EStr+G+FvPEiz9B56dR6MoiUFjXhfE4hjLoAKKJtIQ== +"@babel/preset-env@7.7.1": + version "7.7.1" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.7.1.tgz#04a2ff53552c5885cf1083e291c8dd5490f744bb" + integrity sha512-/93SWhi3PxcVTDpSqC+Dp4YxUu3qZ4m7I76k0w73wYfn7bGVuRIO4QUz95aJksbS+AD1/mT1Ie7rbkT0wSplaA== dependencies: - "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-module-imports" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-async-generator-functions" "^7.2.0" - "@babel/plugin-proposal-dynamic-import" "^7.5.0" + "@babel/plugin-proposal-async-generator-functions" "^7.7.0" + "@babel/plugin-proposal-dynamic-import" "^7.7.0" "@babel/plugin-proposal-json-strings" "^7.2.0" "@babel/plugin-proposal-object-rest-spread" "^7.6.2" "@babel/plugin-proposal-optional-catch-binding" "^7.2.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.6.2" + "@babel/plugin-proposal-unicode-property-regex" "^7.7.0" "@babel/plugin-syntax-async-generators" "^7.2.0" "@babel/plugin-syntax-dynamic-import" "^7.2.0" "@babel/plugin-syntax-json-strings" "^7.2.0" "@babel/plugin-syntax-object-rest-spread" "^7.2.0" "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" + "@babel/plugin-syntax-top-level-await" "^7.7.0" "@babel/plugin-transform-arrow-functions" "^7.2.0" - "@babel/plugin-transform-async-to-generator" "^7.5.0" + "@babel/plugin-transform-async-to-generator" "^7.7.0" "@babel/plugin-transform-block-scoped-functions" "^7.2.0" "@babel/plugin-transform-block-scoping" "^7.6.3" - "@babel/plugin-transform-classes" "^7.5.5" + "@babel/plugin-transform-classes" "^7.7.0" "@babel/plugin-transform-computed-properties" "^7.2.0" "@babel/plugin-transform-destructuring" "^7.6.0" - "@babel/plugin-transform-dotall-regex" "^7.6.2" + "@babel/plugin-transform-dotall-regex" "^7.7.0" "@babel/plugin-transform-duplicate-keys" "^7.5.0" "@babel/plugin-transform-exponentiation-operator" "^7.2.0" "@babel/plugin-transform-for-of" "^7.4.4" - "@babel/plugin-transform-function-name" "^7.4.4" + "@babel/plugin-transform-function-name" "^7.7.0" "@babel/plugin-transform-literals" "^7.2.0" "@babel/plugin-transform-member-expression-literals" "^7.2.0" "@babel/plugin-transform-modules-amd" "^7.5.0" - "@babel/plugin-transform-modules-commonjs" "^7.6.0" - "@babel/plugin-transform-modules-systemjs" "^7.5.0" - "@babel/plugin-transform-modules-umd" "^7.2.0" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.6.3" + "@babel/plugin-transform-modules-commonjs" "^7.7.0" + "@babel/plugin-transform-modules-systemjs" "^7.7.0" + "@babel/plugin-transform-modules-umd" "^7.7.0" + "@babel/plugin-transform-named-capturing-groups-regex" "^7.7.0" "@babel/plugin-transform-new-target" "^7.4.4" "@babel/plugin-transform-object-super" "^7.5.5" "@babel/plugin-transform-parameters" "^7.4.4" "@babel/plugin-transform-property-literals" "^7.2.0" - "@babel/plugin-transform-regenerator" "^7.4.5" + "@babel/plugin-transform-regenerator" "^7.7.0" "@babel/plugin-transform-reserved-words" "^7.2.0" "@babel/plugin-transform-shorthand-properties" "^7.2.0" "@babel/plugin-transform-spread" "^7.6.2" "@babel/plugin-transform-sticky-regex" "^7.2.0" "@babel/plugin-transform-template-literals" "^7.4.4" "@babel/plugin-transform-typeof-symbol" "^7.2.0" - "@babel/plugin-transform-unicode-regex" "^7.6.2" - "@babel/types" "^7.6.3" + "@babel/plugin-transform-unicode-regex" "^7.7.0" + "@babel/types" "^7.7.1" browserslist "^4.6.0" core-js-compat "^3.1.1" invariant "^2.2.2" @@ -683,23 +771,14 @@ "@babel/parser" "^7.1.2" "@babel/types" "^7.1.2" -"@babel/template@^7.4.4": - version "7.4.4" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.4.tgz#f4b88d1225689a08f5bc3a17483545be9e4ed237" - integrity sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw== +"@babel/template@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.7.0.tgz#4fadc1b8e734d97f56de39c77de76f2562e597d0" + integrity sha512-OKcwSYOW1mhWbnTBgQY5lvg1Fxg+VyfQGjcBduZFljfc044J5iDlnDSfhQ867O17XHiSCxYHUxHg2b7ryitbUQ== dependencies: "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.4.4" - "@babel/types" "^7.4.4" - -"@babel/template@^7.6.0": - version "7.6.0" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.6.0.tgz#7f0159c7f5012230dad64cca42ec9bdb5c9536e6" - integrity sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ== - dependencies: - "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.6.0" - "@babel/types" "^7.6.0" + "@babel/parser" "^7.7.0" + "@babel/types" "^7.7.0" "@babel/traverse@^7.1.0": version "7.1.5" @@ -745,32 +824,17 @@ globals "^11.1.0" lodash "^4.17.13" -"@babel/traverse@^7.6.2": - version "7.6.2" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.6.2.tgz#b0e2bfd401d339ce0e6c05690206d1e11502ce2c" - integrity sha512-8fRE76xNwNttVEF2TwxJDGBLWthUkHWSldmfuBzVRmEDWOtu4XdINTgN7TDWzuLg4bbeIMLvfMFD9we5YcWkRQ== +"@babel/traverse@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.7.0.tgz#9f5744346b8d10097fd2ec2eeffcaf19813cbfaf" + integrity sha512-ea/3wRZc//e/uwCpuBX2itrhI0U9l7+FsrKWyKGNyvWbuMcCG7ATKY2VI4wlg2b2TA39HHwIxnvmXvtiKsyn7w== dependencies: "@babel/code-frame" "^7.5.5" - "@babel/generator" "^7.6.2" - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.4.4" - "@babel/parser" "^7.6.2" - "@babel/types" "^7.6.0" - debug "^4.1.0" - globals "^11.1.0" - lodash "^4.17.13" - -"@babel/traverse@^7.6.3": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.6.3.tgz#66d7dba146b086703c0fb10dd588b7364cec47f9" - integrity sha512-unn7P4LGsijIxaAJo/wpoU11zN+2IaClkQAxcJWBNCMS6cmVh802IyLHNkAjQ0iYnRS3nnxk5O3fuXW28IMxTw== - dependencies: - "@babel/code-frame" "^7.5.5" - "@babel/generator" "^7.6.3" - "@babel/helper-function-name" "^7.1.0" - "@babel/helper-split-export-declaration" "^7.4.4" - "@babel/parser" "^7.6.3" - "@babel/types" "^7.6.3" + "@babel/generator" "^7.7.0" + "@babel/helper-function-name" "^7.7.0" + "@babel/helper-split-export-declaration" "^7.7.0" + "@babel/parser" "^7.7.0" + "@babel/types" "^7.7.0" debug "^4.1.0" globals "^11.1.0" lodash "^4.17.13" @@ -801,19 +865,10 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" -"@babel/types@^7.6.0": - version "7.6.1" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.1.tgz#53abf3308add3ac2a2884d539151c57c4b3ac648" - integrity sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g== - dependencies: - esutils "^2.0.2" - lodash "^4.17.13" - to-fast-properties "^2.0.0" - -"@babel/types@^7.6.3": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.3.tgz#3f07d96f854f98e2fbd45c64b0cb942d11e8ba09" - integrity sha512-CqbcpTxMcpuQTMhjI37ZHVgjBkysg5icREQIEZ0eG1yCNwg3oy+5AaLiOKmjsCj6nqOsa6Hf0ObjRVwokb7srA== +"@babel/types@^7.7.0", "@babel/types@^7.7.1": + version "7.7.1" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.7.1.tgz#8b08ea368f2baff236613512cf67109e76285827" + integrity sha512-kN/XdANDab9x1z5gcjDc9ePpxexkt+1EQ2MQUiM4XnMvQfvp87/+6kY4Ko2maLXH+tei/DgJ/ybFITeqqRwDiA== dependencies: esutils "^2.0.2" lodash "^4.17.13" From c26f08758f5d24e552c3418784396dd51350a216 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2019 23:45:28 +0200 Subject: [PATCH 25/43] Bump rollup from 1.26.0 to 1.26.3 (#6821) Bumps [rollup](https://github.com/rollup/rollup) from 1.26.0 to 1.26.3. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v1.26.0...v1.26.3) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 06b46c467..97233ae49 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "prettier": "1.18.2", "prettylint": "1.0.0", "rimraf": "3.0.0", - "rollup": "1.26.0", + "rollup": "1.26.3", "rollup-plugin-babel": "4.3.3", "rollup-plugin-commonjs": "10.1.0", "rollup-plugin-json": "4.0.0", diff --git a/yarn.lock b/yarn.lock index 91819b38f..adf5a9e4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6433,10 +6433,10 @@ rollup-pluginutils@^2.6.0: dependencies: estree-walker "^0.6.1" -rollup@1.26.0: - version "1.26.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.26.0.tgz#cf40fd5e1edc4d7f3d4235a0a43f1c2be1cf294b" - integrity sha512-5HljNYn9icFvXX+Oe97qY5TWvnWhKqgGT0HGeWWqFPx7w7+Anzg7dfHMtUif7YYy6QxAgynDSwK6uxbgcrVUxw== +rollup@1.26.3: + version "1.26.3" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.26.3.tgz#3e71b8120a4ccc745a856e926cab0efbe0eead90" + integrity sha512-8MhY/M8gnv3Q/pQQSWYWzbeJ5J1C5anCNY5BK1kV8Yzw9RFS0FF4lbLt+uyPO3wLKWXSXrhAL5pWL85TZAh+Sw== dependencies: "@types/estree" "*" "@types/node" "*" From d3fbdd99c21b04d901579df8146af1c1437bb774 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2019 07:40:45 +0100 Subject: [PATCH 26/43] Bump typescript from 3.7.1-rc to 3.7.2 (#6832) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.7.1-rc to 3.7.2. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/commits) Signed-off-by: dependabot-preview[bot] Co-authored-by: null <27856297+dependabot-preview[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 97233ae49..37379766b 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "resolve": "1.12.0", "semver": "6.3.0", "string-width": "4.1.0", - "typescript": "3.7.1-rc", + "typescript": "3.7.2", "unicode-regex": "3.0.0", "unified": "8.4.1", "vnopts": "1.0.2", diff --git a/yarn.lock b/yarn.lock index adf5a9e4c..42b0e97c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7245,15 +7245,10 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript@3.7.1-rc: - version "3.7.1-rc" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.1-rc.tgz#2054b872d67f8dc732e36c1df397f9327f37ada0" - integrity sha512-2rMtWppLsaPvmpXsoIAXWDBQVnJMw1ITGGSnidMuayLj9iCmMRT69ncKZw/Mk5rXfJkilApKucWQZxproALoRw== - -typescript@^3.4.3: - version "3.6.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.4.tgz#b18752bb3792bc1a0281335f7f6ebf1bbfc5b91d" - integrity sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg== +typescript@3.7.2, typescript@^3.4.3: + version "3.7.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb" + integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ== uglify-js@^3.1.4: version "3.6.0" From 2b22c7a5e5b8d14ebda08297d7a051c9d6fa7378 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2019 07:46:14 +0100 Subject: [PATCH 27/43] Bump @babel/preset-react from 7.6.3 to 7.7.0 in /website (#6827) Bumps [@babel/preset-react](https://github.com/babel/babel) from 7.6.3 to 7.7.0. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md) - [Commits](https://github.com/babel/babel/compare/v7.6.3...v7.7.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: null <27856297+dependabot-preview[bot]@users.noreply.github.com> --- website/package.json | 2 +- website/yarn.lock | 39 ++++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/website/package.json b/website/package.json index 1fb908002..6e38555cb 100644 --- a/website/package.json +++ b/website/package.json @@ -20,7 +20,7 @@ }, "devDependencies": { "@babel/preset-env": "7.6.3", - "@babel/preset-react": "7.6.3", + "@babel/preset-react": "7.7.0", "@sandhose/prettier-animated-logo": "1.0.3", "babel-loader": "8.0.6", "concurrently": "5.0.0", diff --git a/website/yarn.lock b/website/yarn.lock index a0f66d14d..d4bb00d07 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -61,12 +61,12 @@ "@babel/helper-explode-assignable-expression" "^7.1.0" "@babel/types" "^7.0.0" -"@babel/helper-builder-react-jsx@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx/-/helper-builder-react-jsx-7.0.0.tgz#fa154cb53eb918cf2a9a7ce928e29eb649c5acdb" - integrity sha512-ebJ2JM6NAKW0fQEqN8hOLxK84RbRz9OkUhGS/Xd5u56ejMfVbayJ4+LykERZCOUM6faa6Fp3SZNX3fcT16MKHw== +"@babel/helper-builder-react-jsx@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-react-jsx/-/helper-builder-react-jsx-7.7.0.tgz#c6b8254d305bacd62beb648e4dea7d3ed79f352d" + integrity sha512-LSln3cexwInTMYYoFeVLKnYPPMfWNJ8PubTBs3hkh7wCu9iBaqq1OOyW+xGmEdLxT1nhsl+9SJ+h2oUDYz0l2A== dependencies: - "@babel/types" "^7.0.0" + "@babel/types" "^7.7.0" esutils "^2.0.0" "@babel/helper-call-delegate@^7.4.4": @@ -589,12 +589,12 @@ "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-jsx" "^7.2.0" -"@babel/plugin-transform-react-jsx@^7.0.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.2.0.tgz#ca36b6561c4d3b45524f8efb6f0fbc9a0d1d622f" - integrity sha512-h/fZRel5wAfCqcKgq3OhbmYaReo7KkoJBpt8XnvpS7wqaNMqtw5xhxutzcm35iMUWucfAdT/nvGTsWln0JTg2Q== +"@babel/plugin-transform-react-jsx@^7.7.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.7.0.tgz#834b0723ba78cd4d24d7d629300c2270f516d0b7" + integrity sha512-mXhBtyVB1Ujfy+0L6934jeJcSXj/VCg6whZzEcgiiZHNS0PGC7vUCsZDQCxxztkpIdF+dY1fUMcjAgEOC3ZOMQ== dependencies: - "@babel/helper-builder-react-jsx" "^7.0.0" + "@babel/helper-builder-react-jsx" "^7.7.0" "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-jsx" "^7.2.0" @@ -722,14 +722,14 @@ js-levenshtein "^1.1.3" semver "^5.5.0" -"@babel/preset-react@7.6.3", "@babel/preset-react@^7.0.0": - version "7.6.3" - resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.6.3.tgz#d5242c828322520205ae4eda5d4f4f618964e2f6" - integrity sha512-07yQhmkZmRAfwREYIQgW0HEwMY9GBJVuPY4Q12UC72AbfaawuupVWa8zQs2tlL+yun45Nv/1KreII/0PLfEsgA== +"@babel/preset-react@7.7.0", "@babel/preset-react@^7.0.0": + version "7.7.0" + resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.7.0.tgz#8ab0c4787d98cf1f5f22dabf115552bf9e4e406c" + integrity sha512-IXXgSUYBPHUGhUkH+89TR6faMcBtuMW0h5OHbMuVbL3/5wK2g6a2M2BBpkLa+Kw0sAHiZ9dNVgqJMDP/O4GRBA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-react-display-name" "^7.0.0" - "@babel/plugin-transform-react-jsx" "^7.0.0" + "@babel/plugin-transform-react-jsx" "^7.7.0" "@babel/plugin-transform-react-jsx-self" "^7.0.0" "@babel/plugin-transform-react-jsx-source" "^7.0.0" @@ -786,6 +786,15 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" +"@babel/types@^7.7.0": + version "7.7.1" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.7.1.tgz#8b08ea368f2baff236613512cf67109e76285827" + integrity sha512-kN/XdANDab9x1z5gcjDc9ePpxexkt+1EQ2MQUiM4XnMvQfvp87/+6kY4Ko2maLXH+tei/DgJ/ybFITeqqRwDiA== + dependencies: + esutils "^2.0.2" + lodash "^4.17.13" + to-fast-properties "^2.0.0" + "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" From e48a9df343527d3bfbe67a1c7a49a3cc712963db Mon Sep 17 00:00:00 2001 From: George Zahariev Date: Tue, 5 Nov 2019 22:50:32 -0800 Subject: [PATCH 28/43] Upgrade flow-parser from 0.89 to 0.111 (#6830) --- package.json | 2 +- tests/quotes/__snapshots__/jsfmt.spec.js.snap | 28 +++++++++++++++++++ .../strings/__snapshots__/jsfmt.spec.js.snap | 2 ++ yarn.lock | 8 +++--- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 37379766b..3c06e6ebd 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "esutils": "2.0.3", "find-parent-dir": "0.3.0", "find-project-root": "1.1.1", - "flow-parser": "0.89.0", + "flow-parser": "0.111.1", "get-stream": "5.1.0", "globby": "6.1.0", "graphql": "14.5.8", diff --git a/tests/quotes/__snapshots__/jsfmt.spec.js.snap b/tests/quotes/__snapshots__/jsfmt.spec.js.snap index e79b3f993..7733658ea 100644 --- a/tests/quotes/__snapshots__/jsfmt.spec.js.snap +++ b/tests/quotes/__snapshots__/jsfmt.spec.js.snap @@ -219,15 +219,19 @@ printWidth: 80 // Emoji. ("🐶"); + // Empty string. (""); (""); + // Single double quote. ('"'); ('"'); + // Single single quote. ("'"); ("'"); + // Unnecessary escapes. ("'"); ('"'); @@ -246,6 +250,7 @@ printWidth: 80 ("aa"); // consecutive unnecessarily escaped characters ("aa"); // consecutive unnecessarily escaped characters ("escaped \\u2030 ‰ (should not stay escaped)"); + // Meaningful escapes ("octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7"); ("octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7"); @@ -257,30 +262,39 @@ printWidth: 80 "); ("escaped \\u2028 \\
"); ("escaped \\u2029 \\
"); + // One of each. ("\\"'"); ("\\"'"); + // One of each with unnecessary escapes. ("\\"'"); ("\\"'"); + // More double quotes than single quotes. ('"\\'"'); ('"\\'"'); + // More single quotes than double quotes. ("\\"''"); ("\\"''"); + // Two of each. ("\\"\\"''"); ("\\"\\"''"); + // Single backslash. ("\\\\"); ("\\\\"); + // Backslases. ("\\"\\\\\\"\\\\\\\\\\" ''\\\\'\\\\'\\\\\\\\'"); ('\\'\\\\\\'\\\\\\\\\\' ""\\\\"\\\\"\\\\\\\\"'); + // Somewhat more real-word example. ("He's sayin': \\"How's it goin'?\\" Don't ask me why."); ("He's sayin': \\"How's it goin'?\\" Don't ask me why."); + // Somewhat more real-word example 2. ('var backslash = "\\\\", doubleQuote = \\'"\\';'); ('var backslash = "\\\\", doubleQuote = \\'"\\';'); @@ -418,15 +432,19 @@ singleQuote: true // Emoji. ('🐶'); + // Empty string. (''); (''); + // Single double quote. ('"'); ('"'); + // Single single quote. ("'"); ("'"); + // Unnecessary escapes. ("'"); ('"'); @@ -445,6 +463,7 @@ singleQuote: true ('aa'); // consecutive unnecessarily escaped characters ('aa'); // consecutive unnecessarily escaped characters ('escaped \\u2030 ‰ (should not stay escaped)'); + // Meaningful escapes ('octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7'); ('octal escapes \\0 \\1 \\2 \\3 \\4 \\5 \\6 \\7'); @@ -456,30 +475,39 @@ singleQuote: true '); ('escaped \\u2028 \\
'); ('escaped \\u2029 \\
'); + // One of each. ('"\\''); ('"\\''); + // One of each with unnecessary escapes. ('"\\''); ('"\\''); + // More double quotes than single quotes. ('"\\'"'); ('"\\'"'); + // More single quotes than double quotes. ("\\"''"); ("\\"''"); + // Two of each. ('""\\'\\''); ('""\\'\\''); + // Single backslash. ('\\\\'); ('\\\\'); + // Backslases. ("\\"\\\\\\"\\\\\\\\\\" ''\\\\'\\\\'\\\\\\\\'"); ('\\'\\\\\\'\\\\\\\\\\' ""\\\\"\\\\"\\\\\\\\"'); + // Somewhat more real-word example. ("He's sayin': \\"How's it goin'?\\" Don't ask me why."); ("He's sayin': \\"How's it goin'?\\" Don't ask me why."); + // Somewhat more real-word example 2. ('var backslash = "\\\\", doubleQuote = \\'"\\';'); ('var backslash = "\\\\", doubleQuote = \\'"\\';'); diff --git a/tests/strings/__snapshots__/jsfmt.spec.js.snap b/tests/strings/__snapshots__/jsfmt.spec.js.snap index 607d419c9..ff176f2b3 100644 --- a/tests/strings/__snapshots__/jsfmt.spec.js.snap +++ b/tests/strings/__snapshots__/jsfmt.spec.js.snap @@ -55,6 +55,7 @@ printWidth: 80 "\\0", "🐶", + "\\uD801\\uDC28" ]; @@ -117,6 +118,7 @@ trailingComma: "all" "\\0", "🐶", + "\\uD801\\uDC28", ]; diff --git a/yarn.lock b/yarn.lock index 42b0e97c3..b35717799 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3202,10 +3202,10 @@ flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" -flow-parser@0.89.0: - version "0.89.0" - resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.89.0.tgz#c87bf45831644733dd576983ab12e75a3546573b" - integrity sha512-vC8YuwhAPE+tbkz49DA/TjtFyfhcqM48occMdRQiZ/HL+Wg97IcuebMZUGVB4oBq7aHw0iJJtnvmlnmOQF7Ydg== +flow-parser@0.111.1: + version "0.111.1" + resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.111.1.tgz#f84108934264105916f466e7d1824efacb19b9a3" + integrity sha512-yo+C0a/fMsGwooxA2xd4kK/kuzSnFC8JZLsIB68mkTllLrF/nSQ8llwD82o8Vxwvisw9IPC/ZC8zqrWmkir9jQ== flush-write-stream@^1.0.0: version "1.1.1" From 4d9acf86b893b793690bad80cae418ceefb3209c Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Wed, 6 Nov 2019 18:29:02 +0800 Subject: [PATCH 29/43] Bump `eslint` from 6.5.1 to 6.6.0 (#6846) --- package.json | 2 +- yarn.lock | 117 ++++++++++++++++++++++++--------------------------- 2 files changed, 56 insertions(+), 63 deletions(-) diff --git a/package.json b/package.json index 3c06e6ebd..cfc48942d 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "builtin-modules": "3.1.0", "codecov": "codecov/codecov-node#e427d900309adb50746a39a50aa7d80071a5ddd0", "cross-env": "6.0.3", - "eslint": "6.5.1", + "eslint": "6.6.0", "eslint-config-prettier": "6.5.0", "eslint-formatter-friendly": "7.0.0", "eslint-plugin-import": "2.18.2", diff --git a/yarn.lock b/yarn.lock index b35717799..caea3fa98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1199,10 +1199,10 @@ acorn-globals@^4.1.0: dependencies: acorn "^5.0.0" -acorn-jsx@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.0.2.tgz#84b68ea44b373c4f8686023a551f61a21b7c4a4f" - integrity sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw== +acorn-jsx@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.1.0.tgz#294adb71b57398b0680015f0a38c563ee1db5384" + integrity sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw== acorn@^5.0.0, acorn@^5.3.0, acorn@^5.7.3: version "5.7.3" @@ -1214,7 +1214,7 @@ acorn@^6.2.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.2.1.tgz#3ed8422d6dec09e6121cc7a843ca86a330a86b51" integrity sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q== -acorn@^7.0.0, acorn@^7.1.0: +acorn@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c" integrity sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ== @@ -1284,11 +1284,6 @@ ansi-escapes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" -ansi-escapes@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" - integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== - ansi-escapes@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.2.1.tgz#4dccdb846c3eee10f6d64dea66273eab90c37228" @@ -2074,11 +2069,12 @@ clean-stack@^2.0.0: resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== -cli-cursor@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" +cli-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" + integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== dependencies: - restore-cursor "^2.0.0" + restore-cursor "^3.1.0" cli-width@^2.0.0: version "2.1.0" @@ -2804,22 +2800,22 @@ eslint-scope@^5.0.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-utils@^1.4.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.2.tgz#166a5180ef6ab7eb462f162fd0e6f2463d7309ab" - integrity sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q== +eslint-utils@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" + integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== dependencies: - eslint-visitor-keys "^1.0.0" + eslint-visitor-keys "^1.1.0" -eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: +eslint-visitor-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== -eslint@6.5.1: - version "6.5.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.5.1.tgz#828e4c469697d43bb586144be152198b91e96ed6" - integrity sha512-32h99BoLYStT1iq1v2P9uwpyznQ4M2jRiFB6acitKz52Gqn+vPaMDUTB1bYi1WN4Nquj2w+t+bimYUG83DC55A== +eslint@6.6.0: + version "6.6.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.6.0.tgz#4a01a2fb48d32aacef5530ee9c5a78f11a8afd04" + integrity sha512-PpEBq7b6qY/qrOmpYQ/jTMDYfuQMELR4g4WI1M/NaSDDD/bdcMb+dj4Hgks7p41kW2caXsPsEZAEAyAgjVVC0g== dependencies: "@babel/code-frame" "^7.0.0" ajv "^6.10.0" @@ -2828,9 +2824,9 @@ eslint@6.5.1: debug "^4.0.1" doctrine "^3.0.0" eslint-scope "^5.0.0" - eslint-utils "^1.4.2" + eslint-utils "^1.4.3" eslint-visitor-keys "^1.1.0" - espree "^6.1.1" + espree "^6.1.2" esquery "^1.0.1" esutils "^2.0.2" file-entry-cache "^5.0.1" @@ -2840,7 +2836,7 @@ eslint@6.5.1: ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^6.4.1" + inquirer "^7.0.0" is-glob "^4.0.0" js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" @@ -2859,13 +2855,13 @@ eslint@6.5.1: text-table "^0.2.0" v8-compile-cache "^2.0.3" -espree@^6.1.1: - version "6.1.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.1.tgz#7f80e5f7257fc47db450022d723e356daeb1e5de" - integrity sha512-EYbr8XZUhWbYCqQRW0duU5LxzL5bETN6AjKBGy1302qqzPaCH10QbRg3Wvco79Z8x9WbiE8HYB4e75xl6qUYvQ== +espree@^6.1.2: + version "6.1.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-6.1.2.tgz#6c272650932b4f91c3714e5e7b5f5e2ecf47262d" + integrity sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA== dependencies: - acorn "^7.0.0" - acorn-jsx "^5.0.2" + acorn "^7.1.0" + acorn-jsx "^5.1.0" eslint-visitor-keys "^1.1.0" esprima@^3.1.3: @@ -3087,9 +3083,10 @@ figgy-pudding@^3.5.1: resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790" integrity sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w== -figures@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" +figures@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-3.1.0.tgz#4b198dd07d8d71530642864af2d45dd9e459c4ec" + integrity sha512-ravh8VRXqHuMvZt/d8GblBeqDMkdJMBdv/2KntFH+ra5MXkO7nxNKpzQ3n6QD/2da1kH0aWmNISdvhM7gl2gVg== dependencies: escape-string-regexp "^1.0.5" @@ -3712,22 +3709,22 @@ ini@~1.3.0: version "1.3.4" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" -inquirer@^6.4.1: - version "6.5.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.0.tgz#2303317efc9a4ea7ec2e2df6f86569b734accf42" - integrity sha512-scfHejeG/lVZSpvCXpsB4j/wQNPM5JC8kiElOI0OUTwmc1RTpXr4H32/HOlQHcZiYl2z2VElwuCVDRG8vFmbnA== +inquirer@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.0.0.tgz#9e2b032dde77da1db5db804758b8fea3a970519a" + integrity sha512-rSdC7zelHdRQFkWnhsMu2+2SO41mpv2oF2zy4tMhmiLWkcKbOAs87fWAJhVXttKVwhdZvymvnuM95EyEXg2/tQ== dependencies: - ansi-escapes "^3.2.0" + ansi-escapes "^4.2.1" chalk "^2.4.2" - cli-cursor "^2.1.0" + cli-cursor "^3.1.0" cli-width "^2.0.0" external-editor "^3.0.3" - figures "^2.0.0" - lodash "^4.17.12" - mute-stream "0.0.7" + figures "^3.0.0" + lodash "^4.17.15" + mute-stream "0.0.8" run-async "^2.2.0" rxjs "^6.4.0" - string-width "^2.1.0" + string-width "^4.1.0" strip-ansi "^5.1.0" through "^2.3.6" @@ -4811,7 +4808,7 @@ lodash.uniqby@4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz#d99c07a669e9e6d24e1362dfe266c67616af1302" -lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.4: +lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== @@ -5162,9 +5159,10 @@ ms@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" -mute-stream@0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" +mute-stream@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" + integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== n-readlines@1.0.0: version "1.0.0" @@ -5444,12 +5442,6 @@ once@^1.3.0, once@^1.3.1, once@^1.4.0: dependencies: wrappy "1" -onetime@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" - dependencies: - mimic-fn "^1.0.0" - onetime@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.0.tgz#fff0f3c91617fe62bb50189636e99ac8a6df7be5" @@ -6314,11 +6306,12 @@ resolve@1.12.0, resolve@^1.1.6, resolve@^1.11.0, resolve@^1.11.1, resolve@^1.12. dependencies: path-parse "^1.0.6" -restore-cursor@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" +restore-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" + integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== dependencies: - onetime "^2.0.0" + onetime "^5.1.0" signal-exit "^3.0.2" ret@~0.1.10: @@ -6862,7 +6855,7 @@ string-length@^3.1.0: astral-regex "^1.0.0" strip-ansi "^5.2.0" -string-width@4.1.0: +string-width@4.1.0, string-width@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.1.0.tgz#ba846d1daa97c3c596155308063e075ed1c99aff" integrity sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ== @@ -6879,7 +6872,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: +string-width@^2.0.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== From 16f2c977960fdc1facc156518df8cd06419b3e8c Mon Sep 17 00:00:00 2001 From: Aymeric Bouzy <8168981+aymericbouzy@users.noreply.github.com> Date: Wed, 6 Nov 2019 15:57:49 +0100 Subject: [PATCH 30/43] Add mongo as a VS Code supported language (#6848) * Add mongo as a VS Code supported language * updated Changelog * fix spellcheck error * fix tests --- CHANGELOG.unreleased.md | 12 +++++++++++- src/language-js/index.js | 2 +- .../__tests__/__snapshots__/support-info.js.snap | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 438c4ed05..280485ba3 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -692,7 +692,7 @@ Previously, Prettier only supported the most common HTML entities, such as `&nbs [error] stdin: SyntaxError: Unknown entity "excl" - use the "&#;" or "&#x;" syntax (1:6) [error] > 1 |

Hi!

[error] | ^ -[error] 2 | +[error] 2 | --> @@ -1365,6 +1365,14 @@ const bigints = [200000n, 0x0000000an, 0b01111111n]; const bigints = [200_000n, 0x0000_000an, 0b0111_1111n]; ``` +#### VS Code: add support for .mongo files ([#6848] by [@aymericbouzy]) + +When using the Azure Cosmos DB extension for VS Code, you can create .mongo files to write MongoDB queries, which use Javascript syntax. This change allows VS Code to format your file using Prettier. + +```js +db.users.find({ someField: { $exists: true } }); +``` + [#5682]: https://github.com/prettier/prettier/pull/5682 [#6657]: https://github.com/prettier/prettier/pull/6657 [#5910]: https://github.com/prettier/prettier/pull/5910 @@ -1413,6 +1421,7 @@ const bigints = [200_000n, 0x0000_000an, 0b0111_1111n]; [#6708]: https://github.com/prettier/prettier/pull/6708 [#6687]: https://github.com/prettier/prettier/pull/6687 [#6796]: https://github.com/prettier/prettier/pull/6796 +[#6848]: https://github.com/prettier/prettier/pull/6848 [@brainkim]: https://github.com/brainkim [@duailibe]: https://github.com/duailibe [@gavinjoyce]: https://github.com/gavinjoyce @@ -1433,3 +1442,4 @@ const bigints = [200_000n, 0x0000_000an, 0b0111_1111n]; [@voithos]: https://github.com/voithos [@andersk]: https://github.com/andersk [@lydell]: https://github.com/lydell +[@aymericbouzy]: https://github.com/aymericbouzy diff --git a/src/language-js/index.js b/src/language-js/index.js index a02f4c812..7c80fd7a7 100644 --- a/src/language-js/index.js +++ b/src/language-js/index.js @@ -10,7 +10,7 @@ const languages = [ Object.assign(data, { since: "0.0.0", parsers: ["babel", "flow"], - vscodeLanguageIds: ["javascript"], + vscodeLanguageIds: ["javascript", "mongo"], interpreters: data.interpreters.concat(["nodejs"]) }) ), diff --git a/tests_integration/__tests__/__snapshots__/support-info.js.snap b/tests_integration/__tests__/__snapshots__/support-info.js.snap index e654050eb..8df224c93 100644 --- a/tests_integration/__tests__/__snapshots__/support-info.js.snap +++ b/tests_integration/__tests__/__snapshots__/support-info.js.snap @@ -698,7 +698,7 @@ exports[`CLI --support-info (stdout) 1`] = ` \\"since\\": \\"0.0.0\\", \\"tmScope\\": \\"source.js\\", \\"type\\": \\"programming\\", - \\"vscodeLanguageIds\\": [\\"javascript\\"] + \\"vscodeLanguageIds\\": [\\"javascript\\", \\"mongo\\"] }, { \\"aceMode\\": \\"javascript\\", From b23c6a2d5af464a54388f266f54754608f216ffd Mon Sep 17 00:00:00 2001 From: George Zahariev Date: Wed, 6 Nov 2019 11:36:16 -0800 Subject: [PATCH 31/43] Flow enums (#6833) --- src/language-js/needs-parens.js | 1 + src/language-js/parser-babylon.js | 2 +- src/language-js/parser-flow.js | 1 + src/language-js/printer-estree.js | 76 +++++ .../__snapshots__/jsfmt.spec.js.snap | 311 ++++++++++++++++++ tests/flow_enums/enum-boolean-explicit.js | 6 + tests/flow_enums/enum-boolean-implicit.js | 6 + tests/flow_enums/enum-empty.js | 3 + tests/flow_enums/enum-export.js | 5 + tests/flow_enums/enum-name.js | 4 + tests/flow_enums/enum-no-trailing-comma.js | 5 + tests/flow_enums/enum-number-explicit.js | 6 + tests/flow_enums/enum-number-implicit.js | 6 + .../enum-string-explicit-defaulted.js | 6 + .../enum-string-explicit-initialized.js | 6 + .../enum-string-implicit-defaulted.js | 6 + .../enum-string-implicit-initialized.js | 6 + tests/flow_enums/enum-symbol.js | 6 + tests/flow_enums/jsfmt.spec.js | 1 + 19 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 tests/flow_enums/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/flow_enums/enum-boolean-explicit.js create mode 100644 tests/flow_enums/enum-boolean-implicit.js create mode 100644 tests/flow_enums/enum-empty.js create mode 100644 tests/flow_enums/enum-export.js create mode 100644 tests/flow_enums/enum-name.js create mode 100644 tests/flow_enums/enum-no-trailing-comma.js create mode 100644 tests/flow_enums/enum-number-explicit.js create mode 100644 tests/flow_enums/enum-number-implicit.js create mode 100644 tests/flow_enums/enum-string-explicit-defaulted.js create mode 100644 tests/flow_enums/enum-string-explicit-initialized.js create mode 100644 tests/flow_enums/enum-string-implicit-defaulted.js create mode 100644 tests/flow_enums/enum-string-implicit-initialized.js create mode 100644 tests/flow_enums/enum-symbol.js create mode 100644 tests/flow_enums/jsfmt.spec.js diff --git a/src/language-js/needs-parens.js b/src/language-js/needs-parens.js index 5dafb312d..2f8f30266 100644 --- a/src/language-js/needs-parens.js +++ b/src/language-js/needs-parens.js @@ -790,6 +790,7 @@ function isStatement(node) { node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || + node.type === "EnumDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || diff --git a/src/language-js/parser-babylon.js b/src/language-js/parser-babylon.js index f4fc59024..333e6af4c 100644 --- a/src/language-js/parser-babylon.js +++ b/src/language-js/parser-babylon.js @@ -94,7 +94,7 @@ function createParse(parseMethod, extraPlugins) { } const parse = createParse("parse", ["flow"]); -const parseFlow = createParse("parse", [["flow", { all: true }]]); +const parseFlow = createParse("parse", [["flow", { all: true, enums: true }]]); const parseExpression = createParse("parseExpression"); function tryCombinations(fn, combinations) { diff --git a/src/language-js/parser-flow.js b/src/language-js/parser-flow.js index 132713c33..9b0b5fa6e 100644 --- a/src/language-js/parser-flow.js +++ b/src/language-js/parser-flow.js @@ -13,6 +13,7 @@ function parse(text, parsers, opts) { const flowParser = require("flow-parser"); const ast = flowParser.parse(text, { + enums: true, esproposal_class_instance_fields: true, esproposal_class_static_fields: true, esproposal_export_star_as: true, diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 1cd396b61..92ba97f13 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -2606,6 +2606,82 @@ function printPathNoParens(path, options, print, args) { return concat(parts); } + case "EnumDeclaration": + return concat([ + "enum ", + path.call(print, "id"), + " ", + path.call(print, "body") + ]); + case "EnumBooleanBody": + case "EnumNumberBody": + case "EnumStringBody": + case "EnumSymbolBody": { + if (n.type === "EnumSymbolBody" || n.explicitType) { + let type = null; + switch (n.type) { + case "EnumBooleanBody": + type = "boolean"; + break; + case "EnumNumberBody": + type = "number"; + break; + case "EnumStringBody": + type = "string"; + break; + case "EnumSymbolBody": + type = "symbol"; + break; + } + parts.push("of ", type, " "); + } + if (n.members.length === 0) { + parts.push( + group( + concat([ + "{", + comments.printDanglingComments(path, options), + softline, + "}" + ]) + ) + ); + } else { + parts.push( + group( + concat([ + "{", + indent( + concat([ + hardline, + printArrayItems(path, options, "members", print), + shouldPrintComma(options) ? "," : "" + ]) + ), + comments.printDanglingComments( + path, + options, + /* sameIndent */ true + ), + hardline, + "}" + ]) + ) + ); + } + return concat(parts); + } + case "EnumBooleanMember": + case "EnumNumberMember": + case "EnumStringMember": + return concat([ + path.call(print, "id"), + " = ", + typeof n.init === "object" ? path.call(print, "init") : String(n.init) + ]); + case "EnumDefaultedMember": + return path.call(print, "id"); + case "FunctionTypeAnnotation": case "TSFunctionType": { // FunctionTypeAnnotation is ambiguous: diff --git a/tests/flow_enums/__snapshots__/jsfmt.spec.js.snap b/tests/flow_enums/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..8fcc8f224 --- /dev/null +++ b/tests/flow_enums/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,311 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`enum-boolean-explicit.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E of boolean { + A = true, + B = false, +} + +=====================================output===================================== +// @flow + +enum E of boolean { + A = true, + B = false, +} + +================================================================================ +`; + +exports[`enum-boolean-implicit.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E { + A = true, + B = false, +} + +=====================================output===================================== +// @flow + +enum E { + A = true, + B = false, +} + +================================================================================ +`; + +exports[`enum-empty.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E { } + +=====================================output===================================== +// @flow + +enum E {} + +================================================================================ +`; + +exports[`enum-export.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +export enum A {} + +export default enum B {} + +=====================================output===================================== +// @flow + +export enum A {} + +export default enum B {}; + +================================================================================ +`; + +exports[`enum-name.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum type { +} + +=====================================output===================================== +// @flow + +enum type {} + +================================================================================ +`; + +exports[`enum-no-trailing-comma.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E { + A +} + +=====================================output===================================== +// @flow + +enum E { + A, +} + +================================================================================ +`; + +exports[`enum-number-explicit.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E of number { + A = 1, + B = 2, +} + +=====================================output===================================== +// @flow + +enum E of number { + A = 1, + B = 2, +} + +================================================================================ +`; + +exports[`enum-number-implicit.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E { + A = 0, + B = 1, +} + +=====================================output===================================== +// @flow + +enum E { + A = 0, + B = 1, +} + +================================================================================ +`; + +exports[`enum-string-explicit-defaulted.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E of string { + A, + B, +} + +=====================================output===================================== +// @flow + +enum E of string { + A, + B, +} + +================================================================================ +`; + +exports[`enum-string-explicit-initialized.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E of string { + A = "a", + B = "b", +} + +=====================================output===================================== +// @flow + +enum E of string { + A = "a", + B = "b", +} + +================================================================================ +`; + +exports[`enum-string-implicit-defaulted.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E { + A, + B, +} + +=====================================output===================================== +// @flow + +enum E { + A, + B, +} + +================================================================================ +`; + +exports[`enum-string-implicit-initialized.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E { + A = "a", + B = "b", +} + +=====================================output===================================== +// @flow + +enum E { + A = "a", + B = "b", +} + +================================================================================ +`; + +exports[`enum-symbol.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +// @flow + +enum E of symbol { + A, + B, +} + +=====================================output===================================== +// @flow + +enum E of symbol { + A, + B, +} + +================================================================================ +`; diff --git a/tests/flow_enums/enum-boolean-explicit.js b/tests/flow_enums/enum-boolean-explicit.js new file mode 100644 index 000000000..72237af59 --- /dev/null +++ b/tests/flow_enums/enum-boolean-explicit.js @@ -0,0 +1,6 @@ +// @flow + +enum E of boolean { + A = true, + B = false, +} diff --git a/tests/flow_enums/enum-boolean-implicit.js b/tests/flow_enums/enum-boolean-implicit.js new file mode 100644 index 000000000..8d87b5032 --- /dev/null +++ b/tests/flow_enums/enum-boolean-implicit.js @@ -0,0 +1,6 @@ +// @flow + +enum E { + A = true, + B = false, +} diff --git a/tests/flow_enums/enum-empty.js b/tests/flow_enums/enum-empty.js new file mode 100644 index 000000000..f38c31d7b --- /dev/null +++ b/tests/flow_enums/enum-empty.js @@ -0,0 +1,3 @@ +// @flow + +enum E { } diff --git a/tests/flow_enums/enum-export.js b/tests/flow_enums/enum-export.js new file mode 100644 index 000000000..0170e3a6d --- /dev/null +++ b/tests/flow_enums/enum-export.js @@ -0,0 +1,5 @@ +// @flow + +export enum A {} + +export default enum B {} diff --git a/tests/flow_enums/enum-name.js b/tests/flow_enums/enum-name.js new file mode 100644 index 000000000..84dac082f --- /dev/null +++ b/tests/flow_enums/enum-name.js @@ -0,0 +1,4 @@ +// @flow + +enum type { +} diff --git a/tests/flow_enums/enum-no-trailing-comma.js b/tests/flow_enums/enum-no-trailing-comma.js new file mode 100644 index 000000000..6e39676ff --- /dev/null +++ b/tests/flow_enums/enum-no-trailing-comma.js @@ -0,0 +1,5 @@ +// @flow + +enum E { + A +} diff --git a/tests/flow_enums/enum-number-explicit.js b/tests/flow_enums/enum-number-explicit.js new file mode 100644 index 000000000..63a5e0dfc --- /dev/null +++ b/tests/flow_enums/enum-number-explicit.js @@ -0,0 +1,6 @@ +// @flow + +enum E of number { + A = 1, + B = 2, +} diff --git a/tests/flow_enums/enum-number-implicit.js b/tests/flow_enums/enum-number-implicit.js new file mode 100644 index 000000000..ebc371606 --- /dev/null +++ b/tests/flow_enums/enum-number-implicit.js @@ -0,0 +1,6 @@ +// @flow + +enum E { + A = 0, + B = 1, +} diff --git a/tests/flow_enums/enum-string-explicit-defaulted.js b/tests/flow_enums/enum-string-explicit-defaulted.js new file mode 100644 index 000000000..18a4a16c1 --- /dev/null +++ b/tests/flow_enums/enum-string-explicit-defaulted.js @@ -0,0 +1,6 @@ +// @flow + +enum E of string { + A, + B, +} diff --git a/tests/flow_enums/enum-string-explicit-initialized.js b/tests/flow_enums/enum-string-explicit-initialized.js new file mode 100644 index 000000000..109970bfa --- /dev/null +++ b/tests/flow_enums/enum-string-explicit-initialized.js @@ -0,0 +1,6 @@ +// @flow + +enum E of string { + A = "a", + B = "b", +} diff --git a/tests/flow_enums/enum-string-implicit-defaulted.js b/tests/flow_enums/enum-string-implicit-defaulted.js new file mode 100644 index 000000000..c2d824a68 --- /dev/null +++ b/tests/flow_enums/enum-string-implicit-defaulted.js @@ -0,0 +1,6 @@ +// @flow + +enum E { + A, + B, +} diff --git a/tests/flow_enums/enum-string-implicit-initialized.js b/tests/flow_enums/enum-string-implicit-initialized.js new file mode 100644 index 000000000..37b8ccec0 --- /dev/null +++ b/tests/flow_enums/enum-string-implicit-initialized.js @@ -0,0 +1,6 @@ +// @flow + +enum E { + A = "a", + B = "b", +} diff --git a/tests/flow_enums/enum-symbol.js b/tests/flow_enums/enum-symbol.js new file mode 100644 index 000000000..5fdbf118f --- /dev/null +++ b/tests/flow_enums/enum-symbol.js @@ -0,0 +1,6 @@ +// @flow + +enum E of symbol { + A, + B, +} diff --git a/tests/flow_enums/jsfmt.spec.js b/tests/flow_enums/jsfmt.spec.js new file mode 100644 index 000000000..21e024add --- /dev/null +++ b/tests/flow_enums/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["flow", "babel-flow"], { trailingComma: "all" }); From 4ed377a506a8e03ec0244b71a2470f2198987cbd Mon Sep 17 00:00:00 2001 From: Chris Brody Date: Wed, 6 Nov 2019 14:38:38 -0500 Subject: [PATCH 32/43] audit(critical): handlebars@4.4.5 in package resolutions (#6853) * audit(critical): handlebars@4.4.5 in package resolutions and update yarn.lock resolves critical `yarn audit` issue due to: https://www.npmjs.com/advisories/755 fixed formatting of `resolutions` package field using the following command: node ./bin/prettier.js --write package.json * and remove resolutions, not needed now that the lock file has been updated --- yarn.lock | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index caea3fa98..20f63bd69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3434,20 +3434,10 @@ growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" -handlebars@^4.0.13: - version "4.1.1" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.1.tgz#6e4e41c18ebe7719ae4d38e5aca3d32fa3dd23d3" - integrity sha512-3Zhi6C0euYZL5sM0Zcy7lInLXKQ+YLcF/olbN010mzGQ4XVm50JeyBnMqofHh696GrciGruC7kCcApPDJvVgwA== - dependencies: - neo-async "^2.6.0" - optimist "^0.6.1" - source-map "^0.6.1" - optionalDependencies: - uglify-js "^3.1.4" - -handlebars@^4.0.3: - version "4.1.2" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67" +handlebars@4.4.5, handlebars@^4.0.13, handlebars@^4.0.3: + version "4.4.5" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.4.5.tgz#1b1f94f9bfe7379adda86a8b73fb570265a0dddd" + integrity sha512-0Ce31oWVB7YidkaTq33ZxEbN+UDxMMgThvCe8ptgQViymL5DPis9uLdTA13MiRPhgvqyxIegugrP97iK3JeBHg== dependencies: neo-async "^2.6.0" optimist "^0.6.1" From 59926545aac9535b2392618ad0e36fc012160a7c Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Wed, 6 Nov 2019 22:43:21 +0300 Subject: [PATCH 33/43] test: issue #6283 (#6855) --- .../comments/__snapshots__/jsfmt.spec.js.snap | 63 +++++++++++++++++++ tests/comments/jsdoc.js | 26 ++++++++ 2 files changed, 89 insertions(+) create mode 100644 tests/comments/jsdoc.js diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap index 34cf5455a..099b640e1 100644 --- a/tests/comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap @@ -1125,6 +1125,69 @@ foo( ================================================================================ `; +exports[`jsdoc.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel"] +printWidth: 80 + | printWidth +=====================================input====================================== +/** @type {any} */ +const x = ( +
+
+
+); + +/** + * @type {object} + */ +() => ( +
+ sajdfpoiasdjfpoiasdjfpoiasdjfpoiadsjfpaoisdjfapsdiofjapioisadfaskfaspiofjp +
+); + +/** + * @type {object} + */ +function HelloWorld() { + return ( +
+ Test +
+ ); +} +=====================================output===================================== +/** @type {any} */ +const x = ( +
+
+
+); + +/** + * @type {object} + */ +() => ( +
+ sajdfpoiasdjfpoiasdjfpoiasdjfpoiadsjfpaoisdjfapsdiofjapioisadfaskfaspiofjp +
+); + +/** + * @type {object} + */ +function HelloWorld() { + return ( +
+ Test +
+ ); +} + +================================================================================ +`; + exports[`jsx.js 1`] = ` ====================================options===================================== parsers: ["flow", "babel"] diff --git a/tests/comments/jsdoc.js b/tests/comments/jsdoc.js new file mode 100644 index 000000000..24800022a --- /dev/null +++ b/tests/comments/jsdoc.js @@ -0,0 +1,26 @@ +/** @type {any} */ +const x = ( +
+
+
+); + +/** + * @type {object} + */ +() => ( +
+ sajdfpoiasdjfpoiasdjfpoiasdjfpoiadsjfpaoisdjfapsdiofjapioisadfaskfaspiofjp +
+); + +/** + * @type {object} + */ +function HelloWorld() { + return ( +
+ Test +
+ ); +} \ No newline at end of file From 5458fb5f17c7fe2289b9a6fcb3fa45ac48259e7c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2019 20:45:09 +0100 Subject: [PATCH 34/43] Bump @typescript-eslint/typescript-estree from 2.6.0 to 2.6.1 (#6805) * Bump @typescript-eslint/typescript-estree from 2.6.0 to 2.6.1 Bumps [@typescript-eslint/typescript-estree](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-estree) from 2.6.0 to 2.6.1. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/typescript-estree/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v2.6.1/packages/typescript-estree) Signed-off-by: dependabot-preview[bot] * add shim for path.extname --- package.json | 2 +- scripts/build/shims/path.js | 5 ++++ yarn.lock | 54 ++++++++++++------------------------- 3 files changed, 23 insertions(+), 38 deletions(-) create mode 100644 scripts/build/shims/path.js diff --git a/package.json b/package.json index cfc48942d..659b1aee2 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@babel/parser": "7.7.0", "@glimmer/syntax": "0.41.0", "@iarna/toml": "2.2.3", - "@typescript-eslint/typescript-estree": "2.6.0", + "@typescript-eslint/typescript-estree": "2.6.1", "angular-estree-parser": "1.1.5", "angular-html-parser": "1.3.0", "camelcase": "5.3.1", diff --git a/scripts/build/shims/path.js b/scripts/build/shims/path.js new file mode 100644 index 000000000..9d295d1ae --- /dev/null +++ b/scripts/build/shims/path.js @@ -0,0 +1,5 @@ +export function extname(path) { + const dotIndex = path.lastIndexOf("."); + if (dotIndex === -1) return ""; + return path.slice(dotIndex); +} diff --git a/yarn.lock b/yarn.lock index 20f63bd69..797476e3d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1018,16 +1018,17 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/typescript-estree@2.6.0": - version "2.6.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.6.0.tgz#d3e9d8e001492e2b9124c4d4bd4e7f03c0fd7254" - integrity sha512-A3lSBVIdj2Gp0lFEL6in2eSPqJ33uAc3Ko+Y4brhjkxzjbzLnwBH22CwsW2sCo+iwogfIyvb56/AJri15H0u5Q== +"@typescript-eslint/typescript-estree@2.6.1": + version "2.6.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.6.1.tgz#fb363dd4ca23384745c5ea4b7f4c867432b00d31" + integrity sha512-+sTnssW6bcbDZKE8Ce7VV6LdzkQz2Bxk7jzk1J8H1rovoTxnm6iXvYIyncvNsaB/kBCOM63j/LNJfm27bNdUoA== dependencies: debug "^4.1.1" glob "^7.1.4" is-glob "^4.0.1" lodash.unescape "4.0.1" semver "^6.3.0" + tsutils "^3.17.1" "@webassemblyjs/ast@1.8.5": version "1.8.5" @@ -2379,19 +2380,13 @@ debug@^3.1.0: dependencies: ms "2.0.0" -debug@^4.0.1, debug@^4.1.1: +debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== dependencies: ms "^2.1.1" -debug@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.0.tgz#373687bffa678b38b1cd91f861b63850035ddc87" - dependencies: - ms "^2.1.1" - decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -3368,18 +3363,7 @@ glob-parent@^5.0.0: dependencies: is-glob "^4.0.1" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^7.1.3, glob@^7.1.4: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4: version "7.1.4" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A== @@ -3911,13 +3895,7 @@ is-glob@^3.1.0: dependencies: is-extglob "^2.1.0" -is-glob@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0" - dependencies: - is-extglob "^2.1.1" - -is-glob@^4.0.1: +is-glob@^4.0.0, is-glob@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== @@ -6508,16 +6486,11 @@ schema-utils@^2.5.0: version "5.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" -semver@6.3.0, semver@^6.0.0, semver@^6.1.2, semver@^6.3.0: +semver@6.3.0, semver@^6.0.0, semver@^6.1.0, semver@^6.1.2, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^6.1.0: - version "6.1.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.1.1.tgz#53f53da9b30b2103cd4f15eab3a18ecbcb210c9b" - integrity sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ== - serialize-javascript@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.7.0.tgz#d6e0dfb2a3832a8c94468e6eb1db97e55a192a65" @@ -7194,11 +7167,18 @@ trough@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/trough/-/trough-1.0.1.tgz#a9fd8b0394b0ae8fff82e0633a0a36ccad5b5f86" -tslib@^1.10.0, tslib@^1.8.0, tslib@^1.9.0, tslib@^1.9.3: +tslib@^1.10.0, tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== +tsutils@^3.17.1: + version "3.17.1" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" + integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== + dependencies: + tslib "^1.8.1" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" From 54cbdb89b134d2238dfd642fd6c27aabc82e7f3f Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Wed, 6 Nov 2019 21:53:16 +0200 Subject: [PATCH 35/43] better formatting for AwaitExpression in CallExpression/MemberExpression (#6856) * better formatting for AwaitExpression nested in CallExpression or MemberExpression * update changelog --- CHANGELOG.unreleased.md | 31 ++++++++++++++++++++ src/language-js/printer-estree.js | 19 ++++++++++-- tests/async/__snapshots__/jsfmt.spec.js.snap | 24 +++++++++++++++ tests/async/inline_await.js | 3 ++ 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 tests/async/inline_await.js diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 280485ba3..35e6934c1 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -1373,6 +1373,36 @@ When using the Azure Cosmos DB extension for VS Code, you can create .mongo file db.users.find({ someField: { $exists: true } }); ``` +#### JavaScript: Better formatting for inline `await` expression nested in calls ([#6856] by [@thorn0]) + + +```js +// Input +async function f() { + const admins = (await(db.select('*').from('admins').leftJoin('bla').where('id', 'in', [1,2,3,4]))).map(({id, name})=>({id, name})) +} + +// Output (Prettier stable) +async function f() { + const admins = (await db + .select("*") + .from("admins") + .leftJoin("bla") + .where("id", "in", [1, 2, 3, 4])).map(({ id, name }) => ({ id, name })); +} + +// Output (Prettier master) +async function f() { + const admins = ( + await db + .select("*") + .from("admins") + .leftJoin("bla") + .where("id", "in", [1, 2, 3, 4]) + ).map(({ id, name }) => ({ id, name })); +} +``` + [#5682]: https://github.com/prettier/prettier/pull/5682 [#6657]: https://github.com/prettier/prettier/pull/6657 [#5910]: https://github.com/prettier/prettier/pull/5910 @@ -1422,6 +1452,7 @@ db.users.find({ someField: { $exists: true } }); [#6687]: https://github.com/prettier/prettier/pull/6687 [#6796]: https://github.com/prettier/prettier/pull/6796 [#6848]: https://github.com/prettier/prettier/pull/6848 +[#6856]: https://github.com/prettier/prettier/pull/6856 [@brainkim]: https://github.com/brainkim [@duailibe]: https://github.com/duailibe [@gavinjoyce]: https://github.com/gavinjoyce diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 92ba97f13..d3dba1d68 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -908,8 +908,23 @@ function printPathNoParens(path, options, print, args) { } return concat(parts); - case "AwaitExpression": - return concat(["await ", path.call(print, "argument")]); + case "AwaitExpression": { + parts.push("await ", path.call(print, "argument")); + const parent = path.getParentNode(); + if ( + ((parent.type === "CallExpression" || + parent.type === "OptionalCallExpression") && + parent.callee === n) || + ((parent.type === "MemberExpression" || + parent.type === "OptionalMemberExpression") && + parent.object === n) + ) { + return group( + concat([indent(concat([softline, concat(parts)])), softline]) + ); + } + return concat(parts); + } case "ImportSpecifier": if (n.importKind) { parts.push(path.call(print, "importKind"), " "); diff --git a/tests/async/__snapshots__/jsfmt.spec.js.snap b/tests/async/__snapshots__/jsfmt.spec.js.snap index 624db1b45..8d17a0847 100644 --- a/tests/async/__snapshots__/jsfmt.spec.js.snap +++ b/tests/async/__snapshots__/jsfmt.spec.js.snap @@ -113,6 +113,30 @@ async function f2() { ================================================================================ `; +exports[`inline_await.js 1`] = ` +====================================options===================================== +parsers: ["flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +async function f() { + const admins = (await(db.select('*').from('admins').leftJoin('bla').where('id', 'in', [1,2,3,4]))).map(({id, name})=>({id, name})) +} + +=====================================output===================================== +async function f() { + const admins = ( + await db + .select("*") + .from("admins") + .leftJoin("bla") + .where("id", "in", [1, 2, 3, 4]) + ).map(({ id, name }) => ({ id, name })); +} + +================================================================================ +`; + exports[`parens.js 1`] = ` ====================================options===================================== parsers: ["flow", "typescript"] diff --git a/tests/async/inline_await.js b/tests/async/inline_await.js new file mode 100644 index 000000000..3ee8968be --- /dev/null +++ b/tests/async/inline_await.js @@ -0,0 +1,3 @@ +async function f() { + const admins = (await(db.select('*').from('admins').leftJoin('bla').where('id', 'in', [1,2,3,4]))).map(({id, name})=>({id, name})) +} From b9ab7e2a81749ec54a912d67fb0df90bf570a25d Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Thu, 7 Nov 2019 12:02:41 +0200 Subject: [PATCH 36/43] fix formatting of comments in flow enums (#6860) --- src/language-js/postprocess.js | 16 +++++ .../__snapshots__/jsfmt.spec.js.snap | 66 +++++++++++++++++++ tests/flow_enums/enum-comments.js | 25 +++++++ 3 files changed, 107 insertions(+) create mode 100644 tests/flow_enums/enum-comments.js diff --git a/src/language-js/postprocess.js b/src/language-js/postprocess.js index b7fcc9ed6..888140e25 100644 --- a/src/language-js/postprocess.js +++ b/src/language-js/postprocess.js @@ -27,6 +27,22 @@ function postprocess(ast, options) { }); } break; + case "EnumDeclaration": + // A workaround for what looks like a bug in Flow. + // Flow assigns the same range to enum nodes and enum body nodes. + if ( + options.parser === "flow" && + node.body.range[0] === node.range[0] && + node.body.range[1] === node.range[1] + ) { + node.body.range = [node.id.range[1], node.range[1] - 1]; + } + // Babel does strange things as well. E.g. node.body.start > node.body.end can be true. + if (options.parser === "babel-flow") { + node.body.start = node.id.end; + node.body.end = node.end - 1; + } + break; } }); diff --git a/tests/flow_enums/__snapshots__/jsfmt.spec.js.snap b/tests/flow_enums/__snapshots__/jsfmt.spec.js.snap index 8fcc8f224..b8a72a02a 100644 --- a/tests/flow_enums/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow_enums/__snapshots__/jsfmt.spec.js.snap @@ -50,6 +50,72 @@ enum E { ================================================================================ `; +exports[`enum-comments.js 1`] = ` +====================================options===================================== +parsers: ["flow", "babel-flow"] +printWidth: 80 +trailingComma: "all" + | printWidth +=====================================input====================================== +enum E1 { + A = 0, + // B = 1, + C = 2 +} + +enum E2 of number { + // AA = -1, + A = 0, + // B = 1, + C = 2 + // D = 100 +} + +enum E3 {/*Q*/} + +enum E4 of /*Q*/ string { + Foo = "foo" +} + +enum E5 of string { // Q + Bar = "bar" +} + +enum /*Q*/ E6 of string {} + +=====================================output===================================== +enum E1 { + A = 0, + // B = 1, + C = 2, +} + +enum E2 of number { + // AA = -1, + A = 0, + // B = 1, + C = 2, + // D = 100 +} + +enum E3 { + /*Q*/ +} + +enum E4 of string { + /*Q*/ Foo = "foo", +} + +enum E5 of string { + // Q + Bar = "bar", +} + +enum /*Q*/ E6 of string {} + +================================================================================ +`; + exports[`enum-empty.js 1`] = ` ====================================options===================================== parsers: ["flow", "babel-flow"] diff --git a/tests/flow_enums/enum-comments.js b/tests/flow_enums/enum-comments.js new file mode 100644 index 000000000..6a4cef32b --- /dev/null +++ b/tests/flow_enums/enum-comments.js @@ -0,0 +1,25 @@ +enum E1 { + A = 0, + // B = 1, + C = 2 +} + +enum E2 of number { + // AA = -1, + A = 0, + // B = 1, + C = 2 + // D = 100 +} + +enum E3 {/*Q*/} + +enum E4 of /*Q*/ string { + Foo = "foo" +} + +enum E5 of string { // Q + Bar = "bar" +} + +enum /*Q*/ E6 of string {} From 5caa60876a4074809f1b9f8df16580d21c124b6a Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Thu, 7 Nov 2019 18:04:32 +0800 Subject: [PATCH 37/43] Update browerslist in yarn.lock (#6868) --- yarn.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/yarn.lock b/yarn.lock index 797476e3d..4f661c18f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1796,13 +1796,13 @@ browserify-zlib@^0.2.0: pako "~1.0.5" browserslist@^4.6.0: - version "4.6.2" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.6.2.tgz#574c665950915c2ac73a4594b8537a9eba26203f" - integrity sha512-2neU/V0giQy9h3XMPwLhEY3+Ao0uHSwHvU8Q1Ea6AgLVL1sXbX3dzPrJ8NWe5Hi4PoTkCYXOtVR9rfRLI0J/8Q== + version "4.7.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.7.2.tgz#1bb984531a476b5d389cedecb195b2cd69fb1348" + integrity sha512-uZavT/gZXJd2UTi9Ov7/Z340WOSQ3+m1iBVRUknf+okKxonL9P83S3ctiBDtuRmRu8PiCHjqyueqQ9HYlJhxiw== dependencies: - caniuse-lite "^1.0.30000974" - electron-to-chromium "^1.3.150" - node-releases "^1.1.23" + caniuse-lite "^1.0.30001004" + electron-to-chromium "^1.3.295" + node-releases "^1.1.38" bser@^2.0.0: version "2.0.0" @@ -1943,10 +1943,10 @@ camelcase@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" -caniuse-lite@^1.0.30000974: - version "1.0.30000974" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000974.tgz#b7afe14ee004e97ce6dc73e3f878290a12928ad8" - integrity sha512-xc3rkNS/Zc3CmpMKuczWEdY2sZgx09BkAxfvkxlAEBTqcMHeL8QnPqhKse+5sRTi3nrw2pJwToD2WvKn1Uhvww== +caniuse-lite@^1.0.30001004: + version "1.0.30001008" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001008.tgz#b8841b1df78a9f5ed9702537ef592f1f8772c0d9" + integrity sha512-b8DJyb+VVXZGRgJUa30cbk8gKHZ3LOZTBLaUEEVr2P4xpmFigOCc62CO4uzquW641Ouq1Rm9N+rWLWdSYDaDIw== caseless@~0.12.0: version "0.12.0" @@ -2554,10 +2554,10 @@ editorconfig@0.15.3: semver "^5.6.0" sigmund "^1.0.1" -electron-to-chromium@^1.3.150: - version "1.3.151" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.151.tgz#d4099131871ba2448706141162095ab977db805c" - integrity sha512-Lk5HHXw8hSGB6vYJO/yosy4U2JgVFoXn+uDMmZ0sYxltaKon5mKl2AbjNPkY+zBX9asnGDqEJzuzRq1t2aPm1Q== +electron-to-chromium@^1.3.295: + version "1.3.305" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.305.tgz#64f38c2986277b15c7b2c81954171ed22bee249b" + integrity sha512-jBEhRZ3eeJWf3eAnGYB1vDy09uBQpZWshC5fxiiIRofA9L3vkpa3SxsXleVS2MvuYir15oTVxzWPsOwj7KBzUw== elliptic@^6.0.0: version "6.4.0" @@ -3418,7 +3418,7 @@ growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" -handlebars@4.4.5, handlebars@^4.0.13, handlebars@^4.0.3: +handlebars@^4.0.13, handlebars@^4.0.3: version "4.4.5" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.4.5.tgz#1b1f94f9bfe7379adda86a8b73fb570265a0dddd" integrity sha512-0Ce31oWVB7YidkaTq33ZxEbN+UDxMMgThvCe8ptgQViymL5DPis9uLdTA13MiRPhgvqyxIegugrP97iK3JeBHg== @@ -5238,12 +5238,12 @@ node-pre-gyp@^0.10.0: semver "^5.3.0" tar "^4" -node-releases@^1.1.23: - version "1.1.23" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.23.tgz#de7409f72de044a2fa59c097f436ba89c39997f0" - integrity sha512-uq1iL79YjfYC0WXoHbC/z28q/9pOl8kSHaXdWmAAc8No+bDwqkZbzIJz55g/MUsPgSGm9LZ7QSUbzTcH5tz47w== +node-releases@^1.1.38: + version "1.1.39" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.39.tgz#c1011f30343aff5b633153b10ff691d278d08e8d" + integrity sha512-8MRC/ErwNCHOlAFycy9OPca46fQYUjbJRDcZTHVWIGXIjYLM73k70vv3WkYutVnM4cCo4hE0MqBVVZjP6vjISA== dependencies: - semver "^5.3.0" + semver "^6.3.0" nopt@^4.0.1: version "4.0.1" From d4a7a47b048b8ced046e71d44dfc5de417b89221 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Thu, 7 Nov 2019 18:33:24 +0800 Subject: [PATCH 38/43] Remove handlebars@4.4.5 requirement in yarn.lock (#6867) From 8188876633adb613ed0bb4059fb068295a318902 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Thu, 7 Nov 2019 13:56:44 -0500 Subject: [PATCH 39/43] Fix nullish coalescing parenthesis with mixed logical operators (#6863) * Fix nullish coalescing with mixed logical operators parenthesis Mixing nullish coalescing (`??`) with the other logical operators (`&&` and `||`) requires parenthesis to disambiguate the inteded short circuiting. Without it, it's a `SyntaxError`. Earlier drafts of the spec allowed mixing, but it was disallowed when we reached Stage 3. See https://v8.dev/features/nullish-coalescing#mixing-and-matching-operators * Update changelog * Fixes and cleanup * Update changelog --- CHANGELOG.unreleased.md | 15 +++++++++----- src/language-js/needs-parens.js | 9 ++++++++- .../__snapshots__/jsfmt.spec.js.snap | 20 +++++++++++++++++++ .../nullish_coalesing_operator.js | 10 ++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 35e6934c1..f3f737aa3 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -483,20 +483,23 @@ Previously, Prettier would sometimes ignore whitespace when formatting comments.
``` -#### JavaScript: Update `??` precedence to match stage 3 proposal ([#6404] by [@vjeux]) +#### JavaScript: Update `??` precedence to match stage 3 proposal ([#6404] by [@vjeux], [#6863] by [@jridgewell]) -We've updated Prettier's support for the nullish coalescing operator to match a spec update that no longer allows it to immediately contain, or be contained within an `&&` or `||` operation. +We've updated Prettier's support for the nullish coalescing operator to match a spec update that no longer allows it to immediately contain, or be contained within, an `&&` or `||` operation. ```js // Input -(foo ?? baz) || baz; +(foo ?? bar) || baz; +(foo || bar) ?? baz; // Output (Prettier stable) -foo ?? baz || baz; +foo ?? bar || baz; +foo || bar ?? baz; // Output (Prettier master) -(foo ?? baz) || baz; +(foo ?? bar) || baz; +(foo || bar) ?? baz; ``` Please note, as we update our parsers with versions that support this spec update, code without the parenthesis will throw a parse error. @@ -1453,6 +1456,7 @@ async function f() { [#6796]: https://github.com/prettier/prettier/pull/6796 [#6848]: https://github.com/prettier/prettier/pull/6848 [#6856]: https://github.com/prettier/prettier/pull/6856 +[#6863]: https://github.com/prettier/prettier/pull/6863 [@brainkim]: https://github.com/brainkim [@duailibe]: https://github.com/duailibe [@gavinjoyce]: https://github.com/gavinjoyce @@ -1474,3 +1478,4 @@ async function f() { [@andersk]: https://github.com/andersk [@lydell]: https://github.com/lydell [@aymericbouzy]: https://github.com/aymericbouzy +[@jridgewell]: https://github.com/jridgewell diff --git a/src/language-js/needs-parens.js b/src/language-js/needs-parens.js index 2f8f30266..aa356c2e8 100644 --- a/src/language-js/needs-parens.js +++ b/src/language-js/needs-parens.js @@ -354,7 +354,14 @@ function needsParens(path, options) { return true; } - if ((po === "||" || po === "??") && no === "&&") { + if ( + (po === "??" && (no === "||" || no === "&&")) || + (no === "??" && (po === "||" || po === "&&")) + ) { + return true; + } + + if (po === "||" && no === "&&") { return true; } diff --git a/tests/nullish_coalescing/__snapshots__/jsfmt.spec.js.snap b/tests/nullish_coalescing/__snapshots__/jsfmt.spec.js.snap index 57a8c76aa..2da5a898b 100644 --- a/tests/nullish_coalescing/__snapshots__/jsfmt.spec.js.snap +++ b/tests/nullish_coalescing/__snapshots__/jsfmt.spec.js.snap @@ -13,8 +13,18 @@ const x = (foo, bar = foo ?? bar) => {}; foo ? bar ?? foo : baz; foo ?? (bar ?? baz); +(foo ?? bar) ?? baz; +// Mixing ?? and (&& or ||) requires parens +// It's a syntax error without it. (foo ?? baz) || baz; +foo ?? (baz || baz); + +(foo ?? baz) && baz; +foo ?? (baz && baz); + +(foo || baz) ?? baz; +foo || (baz ?? baz); (foo && baz) ?? baz; foo && (baz ?? baz); @@ -27,8 +37,18 @@ const x = (foo, bar = foo ?? bar) => {}; foo ? bar ?? foo : baz; foo ?? (bar ?? baz); +foo ?? bar ?? baz; +// Mixing ?? and (&& or ||) requires parens +// It's a syntax error without it. (foo ?? baz) || baz; +foo ?? (baz || baz); + +(foo ?? baz) && baz; +foo ?? (baz && baz); + +(foo || baz) ?? baz; +foo || (baz ?? baz); (foo && baz) ?? baz; foo && (baz ?? baz); diff --git a/tests/nullish_coalescing/nullish_coalesing_operator.js b/tests/nullish_coalescing/nullish_coalesing_operator.js index 197fca77b..327b348b5 100644 --- a/tests/nullish_coalescing/nullish_coalesing_operator.js +++ b/tests/nullish_coalescing/nullish_coalesing_operator.js @@ -5,8 +5,18 @@ const x = (foo, bar = foo ?? bar) => {}; foo ? bar ?? foo : baz; foo ?? (bar ?? baz); +(foo ?? bar) ?? baz; +// Mixing ?? and (&& or ||) requires parens +// It's a syntax error without it. (foo ?? baz) || baz; +foo ?? (baz || baz); + +(foo ?? baz) && baz; +foo ?? (baz && baz); + +(foo || baz) ?? baz; +foo || (baz ?? baz); (foo && baz) ?? baz; foo && (baz ?? baz); From b06b42ddbbd51bf7ccbafbac9b09214cc7a94fb6 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2019 14:18:59 +0300 Subject: [PATCH 40/43] Bump @babel/parser from 7.7.0 to 7.7.2 (#6862) Bumps [@babel/parser](https://github.com/babel/babel) from 7.7.0 to 7.7.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md) - [Commits](https://github.com/babel/babel/compare/v7.7.0...v7.7.2) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 659b1aee2..d088d86bb 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "dependencies": { "@angular/compiler": "8.2.13", "@babel/code-frame": "7.5.5", - "@babel/parser": "7.7.0", + "@babel/parser": "7.7.2", "@glimmer/syntax": "0.41.0", "@iarna/toml": "2.2.3", "@typescript-eslint/typescript-estree": "2.6.1", diff --git a/yarn.lock b/yarn.lock index 4f661c18f..405f090de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -368,15 +368,10 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@7.7.0", "@babel/parser@^7.7.0": - version "7.7.0" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.0.tgz#232618f6e8947bc54b407fa1f1c91a22758e7159" - integrity sha512-GqL+Z0d7B7ADlQBMXlJgvXEbtt5qlqd1YQ5fr12hTSfh7O/vgrEIvJxU2e7aSVrEUn75zTZ6Nd0s8tthrlZnrQ== - -"@babel/parser@^7.1.2", "@babel/parser@^7.1.5", "@babel/parser@^7.4.5", "@babel/parser@^7.5.5": - version "7.6.4" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.4.tgz#cb9b36a7482110282d5cb6dd424ec9262b473d81" - integrity sha512-D8RHPW5qd0Vbyo3qb+YjO5nvUVRTXFLQ/FsDxJU2Nqz4uB5EnUN0ZQSEYpvTIbRuttig1XbHWU5oMeQwQSAA+A== +"@babel/parser@7.7.2", "@babel/parser@^7.1.2", "@babel/parser@^7.1.5", "@babel/parser@^7.4.5", "@babel/parser@^7.5.5", "@babel/parser@^7.7.0": + version "7.7.2" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.7.2.tgz#ea8334dc77416bfd9473eb470fd00d8245b3943b" + integrity sha512-DDaR5e0g4ZTb9aP7cpSZLkACEBdoLGwJDWgHtBhrGX7Q1RjhdoMOfexICj5cqTAtpowjGQWfcvfnQG7G2kAB5w== "@babel/plugin-proposal-async-generator-functions@^7.7.0": version "7.7.0" From 304acbea01cf633428d404dd98bc87940cf949e4 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 8 Nov 2019 19:49:32 +0800 Subject: [PATCH 41/43] Change external links to https (#6874) --- docs/api.md | 2 +- docs/comparison.md | 4 ++-- docs/configuration.md | 2 +- docs/index.md | 2 +- docs/technical-details.md | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api.md b/docs/api.md index a2126dc27..c8b73835d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -49,7 +49,7 @@ prettier.resolveConfig(filePath).then(options => { }); ``` -If `options.editorconfig` is `true` and an [`.editorconfig` file](http://editorconfig.org/) is in your project, Prettier will parse it and convert its properties to the corresponding prettier configuration. This configuration will be overridden by `.prettierrc`, etc. Currently, the following EditorConfig properties are supported: +If `options.editorconfig` is `true` and an [`.editorconfig` file](https://editorconfig.org/) is in your project, Prettier will parse it and convert its properties to the corresponding prettier configuration. This configuration will be overridden by `.prettierrc`, etc. Currently, the following EditorConfig properties are supported: - `end_of_line` - `indent_style` diff --git a/docs/comparison.md b/docs/comparison.md index e8c4b9caa..0f6d90bf9 100644 --- a/docs/comparison.md +++ b/docs/comparison.md @@ -7,10 +7,10 @@ title: Prettier vs. Linters Linters have two categories of rules: -**Formatting rules**: eg: [max-len](http://eslint.org/docs/rules/max-len), [no-mixed-spaces-and-tabs](http://eslint.org/docs/rules/no-mixed-spaces-and-tabs), [keyword-spacing](http://eslint.org/docs/rules/keyword-spacing), [comma-style](http://eslint.org/docs/rules/comma-style)... +**Formatting rules**: eg: [max-len](https://eslint.org/docs/rules/max-len), [no-mixed-spaces-and-tabs](https://eslint.org/docs/rules/no-mixed-spaces-and-tabs), [keyword-spacing](https://eslint.org/docs/rules/keyword-spacing), [comma-style](https://eslint.org/docs/rules/comma-style)... Prettier alleviates the need for this whole category of rules! Prettier is going to reprint the entire program from scratch in a consistent way, so it's not possible for the programmer to make a mistake there anymore :) -**Code-quality rules**: eg [no-unused-vars](http://eslint.org/docs/rules/no-unused-vars), [no-extra-bind](http://eslint.org/docs/rules/no-extra-bind), [no-implicit-globals](http://eslint.org/docs/rules/no-implicit-globals), [prefer-promise-reject-errors](http://eslint.org/docs/rules/prefer-promise-reject-errors)... +**Code-quality rules**: eg [no-unused-vars](https://eslint.org/docs/rules/no-unused-vars), [no-extra-bind](https://eslint.org/docs/rules/no-extra-bind), [no-implicit-globals](https://eslint.org/docs/rules/no-implicit-globals), [prefer-promise-reject-errors](https://eslint.org/docs/rules/prefer-promise-reject-errors)... Prettier does nothing to help with those kind of rules. They are also the most important ones provided by linters as they are likely to catch real bugs with your code! diff --git a/docs/configuration.md b/docs/configuration.md index b28f61c90..772e4c432 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -63,7 +63,7 @@ singleQuote = true Overrides let you have different configuration for certain file extensions, folders and specific files. -Prettier borrows ESLint’s [override format](http://eslint.org/docs/user-guide/configuring#example-configuration). +Prettier borrows ESLint’s [override format](https://eslint.org/docs/user-guide/configuring#example-configuration). JSON: diff --git a/docs/index.md b/docs/index.md index d264093bf..27f3750ab 100644 --- a/docs/index.md +++ b/docs/index.md @@ -18,7 +18,7 @@ Prettier is an opinionated code formatter with support for: - [Markdown](https://commonmark.org/), including [GFM](https://github.github.com/gfm/) and [MDX](https://mdxjs.com/) - [YAML](https://yaml.org/) -It removes all original styling[\*](#footnotes) and ensures that all outputted code conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Prettier-Formatter)) +It removes all original styling[\*](#footnotes) and ensures that all outputted code conforms to a consistent style. (See this [blog post](https://jlongster.com/A-Prettier-Formatter)) Prettier takes your code and reprints it from scratch by taking the line length into account. diff --git a/docs/technical-details.md b/docs/technical-details.md index a287192c1..543734b40 100644 --- a/docs/technical-details.md +++ b/docs/technical-details.md @@ -3,7 +3,7 @@ id: technical-details title: Technical Details --- -This printer is a fork of [recast](https://github.com/benjamn/recast)'s printer with its algorithm replaced by the one described by Wadler in "[A prettier printer](http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf)". There still may be leftover code from recast that needs to be cleaned up. +This printer is a fork of [recast](https://github.com/benjamn/recast)'s printer with its algorithm replaced by the one described by Wadler in "[A prettier printer](https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf)". There still may be leftover code from recast that needs to be cleaned up. The basic idea is that the printer takes an AST and returns an intermediate representation of the output, and the printer uses that to generate a string. The advantage is that the printer can "measure" the IR and see if the output is going to fit on a line, and break if not. From 91c5235a3f083719cd60f3c1005f6be14b488c6c Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 8 Nov 2019 20:51:51 +0800 Subject: [PATCH 42/43] Show invalid config filename in error message (#6865) --- CHANGELOG.unreleased.md | 16 ++++++++++++++++ src/cli/util.js | 4 +++- .../__snapshots__/config-invalid.js.snap | 6 +++--- tests_integration/path-serializer.js | 11 ++++++++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index f3f737aa3..44ff2e728 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -1406,6 +1406,20 @@ async function f() { } ``` +#### CLI: Display invalid config filename in error message ([#6865] by [@fisker]) + + +```bash +# Input +$ prettier filename.js --config .invalid-config + +# Output (Prettier stable) +Invalid configuration file: ... + +# Output (Prettier master) +Invalid configuration file `.invalid-config`: ... +``` + [#5682]: https://github.com/prettier/prettier/pull/5682 [#6657]: https://github.com/prettier/prettier/pull/6657 [#5910]: https://github.com/prettier/prettier/pull/5910 @@ -1456,6 +1470,7 @@ async function f() { [#6796]: https://github.com/prettier/prettier/pull/6796 [#6848]: https://github.com/prettier/prettier/pull/6848 [#6856]: https://github.com/prettier/prettier/pull/6856 +[#6865]: https://github.com/prettier/prettier/pull/6865 [#6863]: https://github.com/prettier/prettier/pull/6863 [@brainkim]: https://github.com/brainkim [@duailibe]: https://github.com/duailibe @@ -1478,4 +1493,5 @@ async function f() { [@andersk]: https://github.com/andersk [@lydell]: https://github.com/lydell [@aymericbouzy]: https://github.com/aymericbouzy +[@fisker]: https://github.com/fisker [@jridgewell]: https://github.com/jridgewell diff --git a/src/cli/util.js b/src/cli/util.js index 1fa3c5656..e419a11ec 100644 --- a/src/cli/util.js +++ b/src/cli/util.js @@ -284,7 +284,9 @@ function getOptionsOrDie(context, filePath) { context.logger.debug("loaded options `" + JSON.stringify(options) + "`"); return options; } catch (error) { - context.logger.error("Invalid configuration file: " + error.message); + context.logger.error( + `Invalid configuration file \`${filePath}\`: ` + error.message + ); process.exit(2); } } diff --git a/tests_integration/__tests__/__snapshots__/config-invalid.js.snap b/tests_integration/__tests__/__snapshots__/config-invalid.js.snap index 334c91fa2..5d43be4f4 100644 --- a/tests_integration/__tests__/__snapshots__/config-invalid.js.snap +++ b/tests_integration/__tests__/__snapshots__/config-invalid.js.snap @@ -19,7 +19,7 @@ exports[`show warning with unknown option (stdout) 1`] = `""`; exports[`show warning with unknown option (write) 1`] = `Array []`; exports[`throw error for unsupported extension (stderr) 1`] = ` -"[error] Invalid configuration file: No sync loader specified for extension \\".unsupported\\" +"[error] Invalid configuration file \`/tests_integration/cli/config/invalid\`: No sync loader specified for extension \\".unsupported\\" " `; @@ -28,7 +28,7 @@ exports[`throw error for unsupported extension (stdout) 1`] = `""`; exports[`throw error for unsupported extension (write) 1`] = `Array []`; exports[`throw error with invalid config format (stderr) 1`] = ` -"[error] Invalid configuration file: Cannot find module '--invalid--' from '/tests_integration/cli/config/invalid/file' +"[error] Invalid configuration file \`/tests_integration/cli/config/invalid\`: Cannot find module '--invalid--' from '/tests_integration/cli/config/invalid/file' " `; @@ -64,7 +64,7 @@ exports[`throw error with invalid config precedence option (configPrecedence) (s exports[`throw error with invalid config precedence option (configPrecedence) (write) 1`] = `Array []`; exports[`throw error with invalid config target (directory) (stderr) 1`] = ` -"[error] Invalid configuration file: EISDIR: illegal operation on a directory, read +"[error] Invalid configuration file \`/tests_integration/cli/config/invalid\`: EISDIR: illegal operation on a directory, read " `; diff --git a/tests_integration/path-serializer.js b/tests_integration/path-serializer.js index 5158a8253..da80071ce 100644 --- a/tests_integration/path-serializer.js +++ b/tests_integration/path-serializer.js @@ -1,9 +1,18 @@ "use strict"; +const replaceCWD = text => { + const cwd = process.cwd(); + while (text.indexOf(cwd) !== -1) { + text = text.replace(cwd, ""); + } + + return text; +}; + module.exports = { test: value => typeof value === "string" && (value.indexOf("\\") > -1 || value.indexOf(process.cwd()) > -1), print: (value, serializer) => - serializer(value.replace(process.cwd(), "").replace(/\\/g, "/")) + serializer(replaceCWD(value).replace(/\\/g, "/")) }; From 85912a738d9ec7071a094c83fcf4d23eaeb5b8ff Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 8 Nov 2019 23:34:14 +0800 Subject: [PATCH 43/43] Update `postcss-less` to v2 (#6778) * Update `postcss-less` to v2 * fix less `custom-selectors` * fix less `custom-selectors` 2 * fix custom-selector `:` position * remove less hack * fix custom selector * cleanup * add changlog * add link * restore changlog * restore snap * restore snap * update postcss-custom-selectors detect * remove startsWith * trigger build * update `custom-selector` * add test and changelog * style * md * issue-4090-test * docs * Update CHANGELOG.unreleased.md Co-Authored-By: Georgii Dolzhykov * fix pr issue * fix * fix merge issue * insert new line * snap update * only support custom-selector in css * scss already parse it as custom-selector * remove `custom-selector` test in scss * link --- CHANGELOG.unreleased.md | 15 ++++++++++ package.json | 2 +- src/language-css/parser-postcss.js | 28 +++++++++++++------ .../css_less/__snapshots__/jsfmt.spec.js.snap | 12 ++++++++ tests/css_less/less.less | 6 ++++ yarn.lock | 7 +++-- 6 files changed, 57 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 44ff2e728..c6406f02f 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -1420,6 +1420,20 @@ Invalid configuration file: ... Invalid configuration file `.invalid-config`: ... ``` +#### Less: don't lowercase variable names, remove whitespace between variable and colon ([#6778] by [@fisker]) + + +```less +// Input +@FoO : bar; + +// Output (Prettier stable) +@foo : bar; + +// Output (Prettier master) +@FoO: bar; +``` + [#5682]: https://github.com/prettier/prettier/pull/5682 [#6657]: https://github.com/prettier/prettier/pull/6657 [#5910]: https://github.com/prettier/prettier/pull/5910 @@ -1468,6 +1482,7 @@ Invalid configuration file `.invalid-config`: ... [#6708]: https://github.com/prettier/prettier/pull/6708 [#6687]: https://github.com/prettier/prettier/pull/6687 [#6796]: https://github.com/prettier/prettier/pull/6796 +[#6778]: https://github.com/prettier/prettier/pull/6778 [#6848]: https://github.com/prettier/prettier/pull/6848 [#6856]: https://github.com/prettier/prettier/pull/6856 [#6865]: https://github.com/prettier/prettier/pull/6865 diff --git a/package.json b/package.json index d088d86bb..f3c4273c9 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "n-readlines": "1.0.0", "normalize-path": "3.0.0", "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee", - "postcss-less": "1.1.5", + "postcss-less": "2.0.0", "postcss-media-query-parser": "0.2.3", "postcss-scss": "2.0.0", "postcss-selector-parser": "2.2.3", diff --git a/src/language-css/parser-postcss.js b/src/language-css/parser-postcss.js index 26787e2c6..447a8593e 100644 --- a/src/language-css/parser-postcss.js +++ b/src/language-css/parser-postcss.js @@ -256,12 +256,12 @@ function parseMediaQuery(params) { const DEFAULT_SCSS_DIRECTIVE = /(\s*?)(!default).*$/; const GLOBAL_SCSS_DIRECTIVE = /(\s*?)(!global).*$/; -function parseNestedCSS(node) { +function parseNestedCSS(node, options) { if (node && typeof node === "object") { delete node.parent; for (const key in node) { - parseNestedCSS(node[key]); + parseNestedCSS(node[key], options); } if (!node.type) { @@ -288,6 +288,16 @@ function parseNestedCSS(node) { node.raws.selector = selector; } + // postcss-less@2.0.0 parse `custom-selector` as `css-decl` + if ( + options.parser === "css" && + node.type === "css-decl" && + node.prop === "@custom-selector" + ) { + selector = node.value; + node.raws.value = selector; + } + let value = ""; if (typeof node.value === "string") { @@ -478,7 +488,7 @@ function parseNestedCSS(node) { return node; } -function parseWithParser(parser, text) { +function parseWithParser(parser, text, options) { const parsed = parseFrontMatter(text); const { frontMatter } = parsed; text = parsed.content; @@ -494,7 +504,7 @@ function parseWithParser(parser, text) { throw createError("(postcss) " + e.name + " " + e.reason, { start: e }); } - result = parseNestedCSS(addTypePrefix(result, "css-")); + result = parseNestedCSS(addTypePrefix(result, "css-"), options); if (frontMatter) { result.nodes.unshift(frontMatter); @@ -521,20 +531,20 @@ function requireParser(isSCSSParser) { return require("postcss-less"); } -function parse(text, parsers, opts) { +function parse(text, parsers, options) { const hasExplicitParserChoice = - opts.parser === "less" || opts.parser === "scss"; - const isSCSSParser = isSCSS(opts.parser, text); + options.parser === "less" || options.parser === "scss"; + const isSCSSParser = isSCSS(options.parser, text); try { - return parseWithParser(requireParser(isSCSSParser), text); + return parseWithParser(requireParser(isSCSSParser), text, options); } catch (originalError) { if (hasExplicitParserChoice) { throw originalError; } try { - return parseWithParser(requireParser(!isSCSSParser), text); + return parseWithParser(requireParser(!isSCSSParser), text, options); } catch (_secondError) { throw originalError; } diff --git a/tests/css_less/__snapshots__/jsfmt.spec.js.snap b/tests/css_less/__snapshots__/jsfmt.spec.js.snap index 35e12e716..56f29e8e9 100644 --- a/tests/css_less/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css_less/__snapshots__/jsfmt.spec.js.snap @@ -1677,6 +1677,12 @@ label { .margin-bottom-1\\/3; } +// whitespace between variable and colon, #2925 #4090 +@FoO : bar; + +// should not parse as custom-selector +@custom-selector :--icon #id; + =====================================output===================================== @nice-blue: #5b83ad; @light-blue: @nice-blue + #111; @@ -3281,5 +3287,11 @@ label { .margin-bottom-1\\/3; } +// whitespace between variable and colon, #2925 #4090 +@FoO: bar; + +// should not parse as custom-selector +@custom-selector: --icon #id; + ================================================================================ `; diff --git a/tests/css_less/less.less b/tests/css_less/less.less index 98562337d..d7a13f052 100644 --- a/tests/css_less/less.less +++ b/tests/css_less/less.less @@ -1668,3 +1668,9 @@ li + li { label { .margin-bottom-1\/3; } + +// whitespace between variable and colon, #2925 #4090 +@FoO : bar; + +// should not parse as custom-selector +@custom-selector :--icon #id; diff --git a/yarn.lock b/yarn.lock index 405f090de..c4ee19eb3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5735,9 +5735,10 @@ posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" -postcss-less@1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/postcss-less/-/postcss-less-1.1.5.tgz#a6f0ce180cf3797eeee1d4adc0e9e6d6db665609" +postcss-less@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/postcss-less/-/postcss-less-2.0.0.tgz#5d190b8e057ca446d60fe2e2587ad791c9029fb8" + integrity sha512-pPNsVnpCB13nBMOcl5GVh8JGmB0JGFjqkLUDzKdVpptFFKEe9wFdEzvh2j4lD2AD+7qcrUfw9Ta+oi5+Fw7jjQ== dependencies: postcss "^5.2.16"