-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4307 from mysticatea/core/npm3
Fix: ensure using correct estraverse
- Loading branch information
Showing
5 changed files
with
58 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @fileoverview Patch for estraverse | ||
* @author Toru Nagashima | ||
* @copyright 2015 Toru Nagashima. All rights reserved. | ||
* See LICENSE file in root directory for full license. | ||
*/ | ||
"use strict"; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
|
||
var estraverse = require("estraverse"), | ||
jsxKeys = require("estraverse-fb/keys"); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Helers | ||
//------------------------------------------------------------------------------ | ||
|
||
var experimentalKeys = { | ||
ExperimentalRestProperty: ["argument"], | ||
ExperimentalSpreadProperty: ["argument"] | ||
}; | ||
|
||
/** | ||
* Adds a given keys to Syntax and VisitorKeys of estraverse. | ||
* | ||
* @param {object} keys - Key definitions to add. | ||
* This is an object as map. | ||
* Keys are the node type. | ||
* Values are an array of property names to visit. | ||
* @returns {void} | ||
*/ | ||
function installKeys(keys) { | ||
for (var key in keys) { | ||
if (keys.hasOwnProperty(key)) { | ||
estraverse.Syntax[key] = key; | ||
if (keys[key]) { | ||
estraverse.VisitorKeys[key] = keys[key]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Add JSX node types. | ||
installKeys(jsxKeys); | ||
// Add Experimental node types. | ||
installKeys(experimentalKeys); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Public Interface | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = estraverse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters