[Pkg-javascript-commits] [node-estree-walker] 01/03: New upstream version 0.5.0

Julien Puydt julien.puydt at laposte.net
Sun Jul 23 16:01:46 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-estree-walker.

commit 30a66583f720654cfe0da73da485d89592ab41e6
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Sun Jul 23 11:04:44 2017 +0200

    New upstream version 0.5.0
---
 CHANGELOG.md         |  4 ++++
 package.json         |  2 +-
 src/estree-walker.js |  2 +-
 test/test.js         | 32 +++++++++++++++++++++++++++++++-
 4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1593e20..100e34a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # changelog
 
+## 0.5.0
+
+* Export `childKeys`, for manually fixing in case of malformed ASTs
+
 ## 0.4.0
 
 * Add TypeScript typings ([#3](https://github.com/Rich-Harris/estree-walker/pull/3))
diff --git a/package.json b/package.json
index 1c6710f..5fcae2c 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "estree-walker",
   "description": "Traverse an ESTree-compliant AST",
-  "version": "0.4.0",
+  "version": "0.5.0",
   "author": "Rich Harris",
   "license": "MIT",
   "typings": "index.d.ts",
diff --git a/src/estree-walker.js b/src/estree-walker.js
index 2070ab9..6072c6f 100644
--- a/src/estree-walker.js
+++ b/src/estree-walker.js
@@ -7,7 +7,7 @@ const context = {
 	shouldSkip: false
 };
 
-let childKeys = {};
+export const childKeys = {};
 
 const toString = Object.prototype.toString;
 
diff --git a/test/test.js b/test/test.js
index 99257b9..0ce4432 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,8 +1,38 @@
 const { describe, it } = require( 'mocha' );
 const assert = require( 'assert' );
-const { walk } = require( '..' );
+const { walk, childKeys } = require( '..' );
 
 describe( 'estree-walker', () => {
+	it( 'walks a malformed node, if childKeys is populated', () => {
+		// this test must come first, otherwise it doesn't have
+		// an opportunity to present
+		childKeys.Foo = [ 'answer' ];
+
+		const block = [
+			{
+				type: 'Foo',
+				answer: undefined
+			},
+			{
+				type: 'Foo',
+				answer: {
+					type: 'Answer',
+					value: 42
+				}
+			}
+		];
+
+		let answer;
+
+		walk({ type: 'Test', block }, {
+			enter ( node ) {
+				if ( node.type === 'Answer' ) answer = node;
+			}
+		});
+
+		assert.equal(answer, block[1].answer);
+	});
+
 	it( 'walks an AST', () => {
 		const ast = {
 			type: 'Program',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-estree-walker.git



More information about the Pkg-javascript-commits mailing list