-
Notifications
You must be signed in to change notification settings - Fork 2
upgrade from babel-core^6.18 to @babel/core^7.2.3 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CHNB128
wants to merge
2
commits into
miraks:master
Choose a base branch
from
CHNB128:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"presets": ["es2015"], | ||
"presets": ["@babel/preset-env"], | ||
"plugins": ["strict-equality"] | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
node_modules | ||
lib | ||
This file contains hidden or 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 hidden or 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,118 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
|
||
var _default = function _default(_ref) { | ||
var t = _ref.types; | ||
var unreturnableStatements = new Set(["DebuggerStatement", "WithStatement", "ReturnStatement", "LabeledStatement", "BreakStatement", "ContinueStatement", "ThrowStatement"]); | ||
var returnableStatements = new Set(["IfStatement", "SwitchStatement", "TryStatement", "WhileStatement", "DoWhileStatement", "ForStatement", "ForInStatement", "ForOfStatement"]); | ||
|
||
var last = function last(array) { | ||
return array[array.length - 1]; | ||
}; | ||
|
||
var lastNotEmptyIndex = function lastNotEmptyIndex(nodes) { | ||
for (var index = nodes.length - 1; index >= 0; index -= 1) { | ||
if (!t.isEmptyStatement(nodes[index])) return index; | ||
} | ||
}; // like babel-types#toExpression, but preserves function expressions | ||
|
||
|
||
var toExpression = function toExpression(node) { | ||
if (t.isExpressionStatement(node)) node = node.expression; | ||
|
||
if (t.isClass(node)) { | ||
node.type = "ClassExpression"; | ||
} else if (t.isFunctionDeclaration(node)) { | ||
node.type = "FunctionExpression"; | ||
} | ||
|
||
if (t.isExpression(node)) return node; | ||
throw new Error("cannot turn ".concat(node.type, " to an expression")); | ||
}; | ||
|
||
return { | ||
visitor: { | ||
Function: function Function(path) { | ||
var node = path.node; // arrow function expression | ||
|
||
if (node.expression) return; | ||
var _node$body = node.body, | ||
body = _node$body.body, | ||
directives = _node$body.directives; | ||
|
||
try { | ||
if (body.length === 0) { | ||
// empty function | ||
if (directives.length === 0) return; // function with directives only | ||
|
||
var directive = directives.pop(); | ||
body.push(t.returnStatement(t.stringLiteral(directive.value.value))); | ||
return; | ||
} | ||
} catch (error) { | ||
return; | ||
} | ||
|
||
var lastIndex = lastNotEmptyIndex(body); | ||
var lastPath = path.get("body.body.".concat(lastIndex)); | ||
var lastNode = body[lastIndex]; // skip unreturnable statements | ||
|
||
try { | ||
if (unreturnableStatements.has(lastNode.type)) return; | ||
} catch (error) { | ||
return; | ||
} // convert returnable statements | ||
|
||
|
||
if (returnableStatements.has(lastNode.type)) { | ||
var completionRecords = lastPath.getCompletionRecords(); | ||
var returnUid = null; | ||
completionRecords.forEach(function (subPath) { | ||
if (!subPath.isExpressionStatement()) return; | ||
var isLoop = subPath.findParent(function (subPath) { | ||
return subPath.isLoop(); | ||
}); | ||
|
||
if (isLoop) { | ||
if (!returnUid) returnUid = path.scope.generateDeclaredUidIdentifier("ret"); | ||
subPath.get("expression").replaceWith(t.assignmentExpression("=", returnUid, subPath.node.expression)); | ||
} else { | ||
subPath.replaceWith(t.returnStatement(subPath.node.expression)); | ||
} | ||
}); | ||
|
||
if (returnUid) { | ||
path.get("body").pushContainer("body", t.returnStatement(returnUid)); | ||
} | ||
|
||
return; | ||
} // variables declaration | ||
|
||
|
||
if (t.isVariableDeclaration(lastNode)) { | ||
var _last = last(lastNode.declarations), | ||
id = _last.id; | ||
|
||
if (t.isArrayPattern(id)) { | ||
id = last(id.elements).argument; | ||
} | ||
|
||
if (t.isObjectPattern(id)) { | ||
id = last(id.properties).argument; | ||
} | ||
|
||
body.push(t.returnStatement(id)); | ||
return; | ||
} | ||
|
||
body[lastIndex] = t.returnStatement(toExpression(lastNode)); | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
exports.default = _default; |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -36,14 +36,18 @@ export default ({ types: t }) => { | |
|
||
const { body, directives } = node.body | ||
|
||
if (body.length == 0) { | ||
// empty function | ||
if (directives.length == 0) return | ||
try { | ||
if (body.length == 0) { | ||
// empty function | ||
if (directives.length == 0) return | ||
|
||
// function with directives only | ||
const directive = directives.pop() | ||
body.push(t.returnStatement(t.stringLiteral(directive.value.value))) | ||
// function with directives only | ||
const directive = directives.pop() | ||
body.push(t.returnStatement(t.stringLiteral(directive.value.value))) | ||
|
||
return | ||
} | ||
} catch (error) { | ||
return | ||
} | ||
|
||
|
@@ -52,7 +56,11 @@ export default ({ types: t }) => { | |
const lastNode = body[lastIndex] | ||
|
||
// skip unreturnable statements | ||
if (unreturnableStatements.has(lastNode.type)) return | ||
try { | ||
if (unreturnableStatements.has(lastNode.type)) return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The obvious perceivable error here would be something along the lines of Cannot read property 'type' of null or undefined, so is a try/catch and using errors for control flow needed here? |
||
} catch (error) { | ||
return | ||
} | ||
|
||
// convert returnable statements | ||
if (returnableStatements.has(lastNode.type)) { | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -10,4 +10,5 @@ class Thing { | |
static fn() { | ||
return 1; | ||
} | ||
|
||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -6,9 +6,11 @@ const obj = { | |
return 2; | ||
}, | ||
c: () => 3, | ||
|
||
d() { | ||
return 4; | ||
}, | ||
|
||
["a" + "b"]: () => { | ||
return 5; | ||
} | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -3,8 +3,10 @@ function fn() { | |
constructor() { | ||
return super(); | ||
} | ||
|
||
fn() { | ||
return 1; | ||
} | ||
|
||
}; | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -2,8 +2,10 @@ function fn() { | |
var _ret; | ||
|
||
let n = 0; | ||
|
||
do { | ||
_ret = n += 1; | ||
} while (n < 5); | ||
|
||
return _ret; | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -2,8 +2,10 @@ function fn() { | |
var _ret; | ||
|
||
const arr = [1, 2, 3]; | ||
|
||
for (let n in arr) { | ||
_ret = n + 1; | ||
} | ||
|
||
return _ret; | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,9 +1,14 @@ | ||
function fn() { | ||
var _ret; | ||
|
||
const obj = { a: 1, b: 2 }; | ||
const obj = { | ||
a: 1, | ||
b: 2 | ||
}; | ||
|
||
for (let entry of obj) { | ||
_ret = entry[0] + entry[1]; | ||
} | ||
|
||
return _ret; | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -4,5 +4,6 @@ function fn() { | |
for (let n = 0; n < 5; n += 1) { | ||
_ret = n - 1; | ||
} | ||
|
||
return _ret; | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
function fn() { | ||
const fn = () => 1; | ||
|
||
return fn(); | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
function fn() { | ||
const a = 1, | ||
b = "str", | ||
c = { key: "value", other: 1 }; | ||
c = { | ||
key: "value", | ||
other: 1 | ||
}; | ||
return c; | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -6,5 +6,6 @@ function fn() { | |
_ret = n + k; | ||
} | ||
} | ||
|
||
return _ret; | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -20,5 +20,6 @@ function foo() { | |
_ret = res *= b; | ||
} | ||
} | ||
|
||
return _ret; | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
function fn() { | ||
return { key: "value", other: 1 }; | ||
return { | ||
key: "value", | ||
other: 1 | ||
}; | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
function fn() { | ||
const obj = { a: 1, b: 2 }; | ||
const { a, ...c } = obj; | ||
const obj = { | ||
a: 1, | ||
b: 2 | ||
}; | ||
const { | ||
a, | ||
...c | ||
} = obj; | ||
return c; | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,12 +1,4 @@ | ||
function fn() { | ||
const content = "content"; | ||
return React.createElement( | ||
"div", | ||
null, | ||
React.createElement( | ||
"span", | ||
null, | ||
content | ||
) | ||
); | ||
return React.createElement("div", null, React.createElement("span", null, content)); | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -2,11 +2,14 @@ function fn(a) { | |
switch (a) { | ||
case "a": | ||
1; | ||
|
||
case "b": | ||
2; | ||
break; | ||
|
||
case "c": | ||
3; | ||
|
||
default: | ||
4; | ||
} | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ function fn() { | |
try { | ||
return 1; | ||
} catch (e) { | ||
2; | ||
return 2; | ||
} finally { | ||
return 3; | ||
} | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -2,6 +2,6 @@ function fn() { | |
try { | ||
return 1; | ||
} catch (e) { | ||
2; | ||
return 2; | ||
} | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
function fn() { | ||
const obj = { key: "value", other: 1 }; | ||
const obj = { | ||
key: "value", | ||
other: 1 | ||
}; | ||
return obj; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason why lib is commented out in the gitignore instead of perhaps npmignore? On the flipside, unprocessed sources can be npm ignored