From b012f7531efb9d0988804b45a4ac60dec16b00a8 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Mon, 20 Mar 2017 09:42:07 -0700 Subject: [PATCH] Fix comments inside of ObjectPattern (#1045) ast-types was missing a type, I sent a PR on ast-type ( https://github.com/benjamn/ast-types/pull/211 ) which was merged and released (thanks @benjamn for being super quick!). So I'm upgrading ast-types and add the test in this PR. Fixes #1007 --- package.json | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 28 +++++++++++++++++++ .../flow_object_comment.js | 11 ++++++++ tests/flow_object_comment/jsfmt.spec.js | 1 + yarn.lock | 6 ++-- 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 tests/flow_object_comment/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/flow_object_comment/flow_object_comment.js create mode 100644 tests/flow_object_comment/jsfmt.spec.js diff --git a/package.json b/package.json index 6cfe2fd00..69560bee7 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "license": "MIT", "main": "./index.js", "dependencies": { - "ast-types": "0.9.4", + "ast-types": "0.9.8", "babel-code-frame": "6.22.0", "babylon": "6.15.0", "chalk": "1.1.3", diff --git a/tests/flow_object_comment/__snapshots__/jsfmt.spec.js.snap b/tests/flow_object_comment/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..1314cca0a --- /dev/null +++ b/tests/flow_object_comment/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,28 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`flow_object_comment.js 1`] = ` +"export default ( + { + foo, + bar + }: { + // comment + foo?: Object, + // comment 2 + bar?: Object, + }, +) => {} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +export default ( + { + foo, + bar + }: { + // comment + foo?: Object, + // comment 2 + bar?: Object + } +) => {}; +" +`; diff --git a/tests/flow_object_comment/flow_object_comment.js b/tests/flow_object_comment/flow_object_comment.js new file mode 100644 index 000000000..7b9e268ed --- /dev/null +++ b/tests/flow_object_comment/flow_object_comment.js @@ -0,0 +1,11 @@ +export default ( + { + foo, + bar + }: { + // comment + foo?: Object, + // comment 2 + bar?: Object, + }, +) => {} diff --git a/tests/flow_object_comment/jsfmt.spec.js b/tests/flow_object_comment/jsfmt.spec.js new file mode 100644 index 000000000..989047bcc --- /dev/null +++ b/tests/flow_object_comment/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname); diff --git a/yarn.lock b/yarn.lock index 0b4ff6272..52c8e3c8e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -109,9 +109,9 @@ ast-types@0.8.18: version "0.8.18" resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.8.18.tgz#c8b98574898e8914e9d8de74b947564a9fe929af" -ast-types@0.9.4: - version "0.9.4" - resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.4.tgz#410d1f81890aeb8e0a38621558ba5869ae53c91b" +ast-types@0.9.8: + version "0.9.8" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.9.8.tgz#6cb6a40beba31f49f20928e28439fc14a3dab078" async@^1.4.0, async@^1.4.2: version "1.5.2"