diff --git a/package.json b/package.json index 9baa4a2e2..229910641 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "@angular/compiler": "12.0.4", "@babel/code-frame": "7.14.5", - "@babel/parser": "7.14.4", + "@babel/parser": "7.14.5", "@glimmer/syntax": "0.79.3", "@iarna/toml": "2.2.5", "@typescript-eslint/typescript-estree": "4.26.1", diff --git a/tests/format/js/import-assertions/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/import-assertions/__snapshots__/jsfmt.spec.js.snap index bd4aa50ec..0f2a1173a 100644 --- a/tests/format/js/import-assertions/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/import-assertions/__snapshots__/jsfmt.spec.js.snap @@ -101,6 +101,34 @@ import json from "./foo.json" assert { type: "json", type: "bar" }; ================================================================================ `; +exports[`non-type.js [espree] format 1`] = ` +"Unexpected token assert (1:28) +> 1 | import foo from \\"foo.json\\" assert { lazy: \\"true\\" }; + | ^ + 2 |" +`; + +exports[`non-type.js [meriyah] format 1`] = ` +"[1:33]: Unexpected token: 'identifier' (1:33) +> 1 | import foo from \\"foo.json\\" assert { lazy: \\"true\\" }; + | ^ + 2 |" +`; + +exports[`non-type.js format 1`] = ` +====================================options===================================== +parsers: ["babel"] +printWidth: 80 + | printWidth +=====================================input====================================== +import foo from "foo.json" assert { lazy: "true" }; + +=====================================output===================================== +import foo from "foo.json" assert { lazy: "true" }; + +================================================================================ +`; + exports[`not-import-assertions.js format 1`] = ` ====================================options===================================== parsers: ["babel"] diff --git a/tests/format/js/import-assertions/jsfmt.spec.js b/tests/format/js/import-assertions/jsfmt.spec.js index 69aab7bca..60cc36973 100644 --- a/tests/format/js/import-assertions/jsfmt.spec.js +++ b/tests/format/js/import-assertions/jsfmt.spec.js @@ -7,6 +7,7 @@ run_spec(__dirname, ["babel"], { "static-import.js", "re-export.js", "without-from.js", + "non-type.js", ], meriyah: [ "dynamic-import.js", @@ -15,6 +16,7 @@ run_spec(__dirname, ["babel"], { "static-import.js", "re-export.js", "without-from.js", + "non-type.js", ], }, }); diff --git a/tests/format/js/import-assertions/non-type.js b/tests/format/js/import-assertions/non-type.js new file mode 100644 index 000000000..bdcedd93b --- /dev/null +++ b/tests/format/js/import-assertions/non-type.js @@ -0,0 +1 @@ +import foo from "foo.json" assert { lazy: "true" }; diff --git a/tests/format/js/regex/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/regex/__snapshots__/jsfmt.spec.js.snap index 64d96cf7d..e1e9e91b3 100644 --- a/tests/format/js/regex/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/regex/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,40 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`d-flag.js [espree] format 1`] = ` +"Invalid regular expression flag (1:2) +> 1 | /./d; + | ^ + 2 |" +`; + +exports[`d-flag.js [flow] format 1`] = ` +"Invalid flags supplied to RegExp constructor 'd' (1:5) +> 1 | /./d; + | ^ + 2 |" +`; + +exports[`d-flag.js [meriyah] format 1`] = ` +"[1:3]: Unexpected regular expression flag (1:3) +> 1 | /./d; + | ^ + 2 |" +`; + +exports[`d-flag.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +/./d; + +=====================================output===================================== +/./d; + +================================================================================ +`; + exports[`test.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] diff --git a/tests/format/js/regex/d-flag.js b/tests/format/js/regex/d-flag.js new file mode 100644 index 000000000..566fb6f0e --- /dev/null +++ b/tests/format/js/regex/d-flag.js @@ -0,0 +1 @@ +/./d; diff --git a/tests/format/js/regex/jsfmt.spec.js b/tests/format/js/regex/jsfmt.spec.js index eb85eda6b..fe800ee65 100644 --- a/tests/format/js/regex/jsfmt.spec.js +++ b/tests/format/js/regex/jsfmt.spec.js @@ -1 +1,7 @@ -run_spec(__dirname, ["babel", "flow", "typescript"]); +run_spec(__dirname, ["babel", "flow", "typescript"], { + errors: { + flow: ["d-flag.js"], + espree: ["d-flag.js"], + meriyah: ["d-flag.js"], + }, +}); diff --git a/tests/format/misc/errors/js/async-await/__snapshots__/jsfmt.spec.js.snap b/tests/format/misc/errors/js/async-await/__snapshots__/jsfmt.spec.js.snap index ddcde031c..ae58604af 100644 --- a/tests/format/misc/errors/js/async-await/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/misc/errors/js/async-await/__snapshots__/jsfmt.spec.js.snap @@ -84,6 +84,12 @@ exports[`snippet: #1 [babel] format 2`] = ` | ^" `; +exports[`snippet: #1 [babel] format 3`] = ` +"Unexpected token (1:15) +> 1 | async({ foo33 = 1 }); + | ^" +`; + exports[`snippet: #1 [espree] format 1`] = ` "Cannot use keyword 'await' outside an async function (1:12) > 1 | async (x = await 2) => {}; @@ -91,6 +97,12 @@ exports[`snippet: #1 [espree] format 1`] = ` `; exports[`snippet: #1 [espree] format 2`] = ` +"Shorthand property assignments are valid only in destructuring patterns (1:15) +> 1 | async({ foo33 = 1 }); + | ^" +`; + +exports[`snippet: #1 [espree] format 3`] = ` "Cannot use keyword 'await' outside an async function (1:1) > 1 | await 0; | ^" @@ -109,6 +121,12 @@ exports[`snippet: #1 [meriyah] format 1`] = ` `; exports[`snippet: #1 [meriyah] format 2`] = ` +"[1:21]: Invalid shorthand property initializer (1:21) +> 1 | async({ foo33 = 1 }); + | ^" +`; + +exports[`snippet: #1 [meriyah] format 3`] = ` "[1:5]: 'Await' may not be used as an identifier in this context (1:5) > 1 | await 0; | ^" diff --git a/tests/format/misc/errors/js/async-await/jsfmt.spec.js b/tests/format/misc/errors/js/async-await/jsfmt.spec.js index 752a145ac..ed8d92816 100644 --- a/tests/format/misc/errors/js/async-await/jsfmt.spec.js +++ b/tests/format/misc/errors/js/async-await/jsfmt.spec.js @@ -42,7 +42,7 @@ run_spec( run_spec( { dirname: __dirname, - snippets: ["async (x = await (2)) => {};"], + snippets: ["async (x = await (2)) => {};", "async({ foo33 = 1 });"], }, ["babel", "espree", "meriyah"] ); diff --git a/yarn.lock b/yarn.lock index 9947d36ed..cc0d62e66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -288,12 +288,7 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@7.14.4": - version "7.14.4" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.4.tgz#a5c560d6db6cd8e6ed342368dea8039232cbab18" - integrity sha512-ArliyUsWDUqEGfWcmzpGUzNfLxTdTp6WU4IuP6QFSp9gGfWS6boxFCkJSJ/L4+RG8z/FnIU3WxCk6hPL9SSWeA== - -"@babel/parser@^7.1.0", "@babel/parser@^7.14.5", "@babel/parser@^7.7.2": +"@babel/parser@7.14.5", "@babel/parser@^7.1.0", "@babel/parser@^7.14.5", "@babel/parser@^7.7.2": version "7.14.5" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.5.tgz#4cd2f346261061b2518873ffecdf1612cb032829" integrity sha512-TM8C+xtH/9n1qzX+JNHi7AN2zHMTiPUtspO0ZdHflW8KaskkALhMmuMHb4bCmNdv9VAPzJX3/bXqkVLnAvsPfg==