Compare commits

...

44 Commits

Author SHA1 Message Date
Sebastian McKenzie
a45d6960da v4.4.6 2015-02-24 22:17:12 +11:00
Sebastian McKenzie
b13aa41a75 fixing linting error 2015-02-24 22:15:27 +11:00
Sebastian McKenzie
20a4ed6140 add 4.4.6 changelog 2015-02-24 22:14:34 +11:00
Sebastian McKenzie
c256e060b3 Merge branch 'master' of github.com:6to5/6to5 2015-02-24 22:11:33 +11:00
Sebastian McKenzie
bef315efd6 fix up JSXElement alias keys 2015-02-24 22:11:25 +11:00
Sebastian McKenzie
2ec5390b63 bump core-js 2015-02-24 22:11:18 +11:00
Sebastian McKenzie
f4c9dd8768 Merge pull request #881 from sindresorhus/bump-chalk
bump `chalk`
2015-02-24 22:06:05 +11:00
Sindre Sorhus
510c7a3e60 bump chalk
https://github.com/sindresorhus/chalk/releases/tag/v1.0.0
2015-02-24 16:03:00 +07:00
Sebastian McKenzie
3ce9508a1c bump core-js @zloirock 2015-02-24 14:16:29 +11:00
Sebastian McKenzie
717ef280f7 clean up #870 2015-02-24 11:20:04 +11:00
Sebastian McKenzie
8c5e7cf272 Merge pull request #870 from neVERberleRfellerER/fix-extends-anon-class
fix extends with empty anonymous base class
2015-02-24 11:18:18 +11:00
Ondrej Kraus
811a843be9 add tests for extends of anonymous classes 2015-02-24 01:01:05 +01:00
Ondrej Kraus
b7c297bb89 remove anonymous class constructor name in specific case
Name of anonymous class constructor is not needed when it contains
exactly one method that is not construtor, because constructor
will be assigned to variable in closure.
2015-02-24 01:01:02 +01:00
Sebastian McKenzie
b7342ef4ea move es6.arrowFunctions transformer - fixes #874 2015-02-24 10:31:11 +11:00
Sebastian McKenzie
1a899f5e77 move attribute whitespace handling to JSXAttribute enter - fixes #872 2015-02-24 09:48:10 +11:00
Sebastian McKenzie
f2eb1643c0 throw deprecation error for @jsx React.DOM usage and crawl all comments for pragmas - fixes #876 2015-02-24 09:38:16 +11:00
neVERberleRfellerER
9621d1bbeb remove unnecessary derived class constructor name 2015-02-23 17:39:42 +01:00
Ondrej Kraus
3cf7b2b761 add name to constructor of extended anonymous class 2015-02-23 17:19:41 +01:00
Sebastian McKenzie
ae8b1e242b remove illegal left for of test 2015-02-23 21:36:42 +11:00
Sebastian McKenzie
eea48f866d allow MemberExpressions in for-of head 2015-02-23 21:31:57 +11:00
Sebastian McKenzie
84d2d7b7d4 add 4.4.5 changelog 2015-02-23 11:11:24 +11:00
Sebastian McKenzie
ea30a619dd bump regenerator-babel 2015-02-23 11:11:19 +11:00
Sebastian McKenzie
87a201db22 4.4.5 2015-02-22 23:27:02 +11:00
Sebastian McKenzie
bcc86c47bc v4.4.5 2015-02-22 23:26:01 +11:00
Sebastian McKenzie
b6df9b583b 4.4.4 2015-02-22 23:23:38 +11:00
Sebastian McKenzie
52ea7b5f59 always use closure wrap - fixes #864 2015-02-22 23:23:34 +11:00
Sebastian McKenzie
7bff8239a1 v4.4.4 2015-02-22 22:50:02 +11:00
Sebastian McKenzie
04d79c1740 fix array unpacking test 2015-02-22 22:46:27 +11:00
Sebastian McKenzie
e387da7c2b upgrade acorn-babel 2015-02-22 22:42:17 +11:00
Sebastian McKenzie
53cf453480 add 4.4.4 changelog 2015-02-22 22:40:18 +11:00
Sebastian McKenzie
341528ee4a fix linting errors 2015-02-22 22:37:51 +11:00
Sebastian McKenzie
5f6808ba92 don't transform flow module nodes 2015-02-22 22:35:47 +11:00
Sebastian McKenzie
0b2f1fedcb don't unpack array when the pattern contains more elements than the corresponding array expression 2015-02-22 22:35:38 +11:00
Sebastian McKenzie
c3c94f0a4a fix options argument to vm.runInThisContext 2015-02-22 22:35:04 +11:00
Sebastian McKenzie
f2d60aab9e optimise named functions depending on whether they contain an assignment/reference - #861 2015-02-22 21:35:08 +11:00
Sebastian McKenzie
ab6bb35a4f make line-numbers and js-tokens versions fixed 2015-02-22 20:55:09 +11:00
Sebastian McKenzie
e11b943514 revert to old named function wrapper - fixes #861 2015-02-22 20:54:47 +11:00
Sebastian McKenzie
b44a6eb297 remove is-keyword-js in favor of esutils #856 2015-02-22 10:51:27 +11:00
Sebastian McKenzie
f3288ddb1f Merge branch 'lydell-error-syntax-highlighting' 2015-02-22 10:49:30 +11:00
Simon Lydell
476aa44a90 improve syntax highlighting in error messages
- Support hexadecimal, octal and binary number literals, template strings, and
  tokenize everything more robustly in general.
- Tokens spanning over several lines (such as multiline strings and comments) no
  longer leak their color into the line number gutter.
- The color scheme is preserved.
- The line numbers are now right-aligned instead of left-aligned, since that's
  how practically every editor does it.
- Superfluos space in the line number gutter has been removed.
2015-02-21 21:20:52 +01:00
Sebastian McKenzie
c5589e9336 Merge pull request #853 from meandmycode/master
build: ensure bootstrap works on windows
2015-02-21 21:43:49 +11:00
Stephen Taylor
404eb2f972 build: ensure bootstrap works on windows 2015-02-21 10:17:28 +00:00
Sebastian McKenzie
366257915e advise users to visit the gitter room before creating an issue in the readme 2015-02-21 19:17:48 +11:00
Sebastian McKenzie
e0cd9bdbe3 4.4.3 2015-02-21 19:14:26 +11:00
43 changed files with 577 additions and 354 deletions

View File

@@ -13,6 +13,33 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 4.4.6
* **Bug Fix**
* Fix extending a class expression with no methods/only constructor. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
* Allow `MemberExpression` as a valid `left` of `ForOfStatement`.
* **Polish**
* Throw an error when people try and transpile code with the `@jsx React.DOM` pragma as it conflicts with the custom jsx constructo method detection.
* Crawl all comments for `@jsx` pragma.
* **Internal**
* Upgrade `chalk`.
* Upgrade `core-js`.
## 4.4.5
* **Internal**
* Remove function self reference optimisation.
## 4.4.4
* **Bug Fix**
* Handle inferred function ids to be reassigned and deopt to a slower but working equivalent.
* Don't unpack array patterns that have more elements than their right hand array expression.
* **Polish**
* Improve syntax highlighting in the code frame. Thanks [@lydell](https://github.com/lydell)!
* **Internal**
* Upgrade `acorn-babel`.
## 4.4.3
* **Bug Fix**

View File

@@ -119,5 +119,5 @@ publish-core:
bootstrap:
npm install
git submodule update --init
cd vendor/regenerator; npm install
cd vendor/compat-table; npm install object-assign
cd vendor/regenerator && npm install
cd vendor/compat-table && npm install object-assign

View File

@@ -9,8 +9,9 @@
</p>
<p align="center">
For more information view the <a href="https://babeljs.io/">documentation</a>. For
support visit the <a href="https://gitter.im/babel/babel">gitter room</a>.
For more information view the <a href="https://babeljs.io/">documentation</a>. For questions
and support please visit the <a href="https://gitter.im/babel/babel">gitter room</a> before
creating an issue.
</p>
<p align="center">

View File

@@ -50,7 +50,10 @@ var _eval = function (code, filename) {
experimental: program.experimental,
playground: program.playground
}).code;
return vm.runInThisContext(code, filename);
return vm.runInThisContext(code, {
filename: filename
});
};
if (program.eval || program.print) {

View File

@@ -1,42 +1,59 @@
// syntax highlighting based on https://github.com/dominictarr/ansi-highlight by the fantastic Dominic Tarr
var repeating = require("repeating");
var tokenize = require("js-tokenizer");
var chalk = require("chalk");
var lineNumbers = require("line-numbers");
var repeating = require("repeating");
var jsTokens = require("js-tokens");
var esutils = require("esutils");
var chalk = require("chalk");
var ary = require("lodash/function/ary");
var defs = {
string1: "red",
string2: "red",
punct: ["white", "bold"],
curly: "green",
parens: ["blue", "bold"],
square: ["yellow"],
name: "white",
keyword: ["cyan"],
number: "magenta",
regexp: "magenta",
comment1: "grey",
comment2: "grey"
string: chalk.red,
punctuation: chalk.white.bold,
operator: chalk.white.bold,
curly: chalk.green,
parens: chalk.blue.bold,
square: chalk.yellow,
name: chalk.white,
keyword: chalk.cyan,
number: chalk.magenta,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.inverse
};
var highlight = function (text) {
var colorize = function (str, col) {
if (!col) return str;
var newline = /\r\n|[\n\r\u2028\u2029]/;
if (Array.isArray(col)) {
col.forEach(function (col) {
str = chalk[col](str);
});
} else {
str = chalk[col](str);
var highlight = function (text) {
var tokenType = function (match) {
var token = jsTokens.matchToToken(match);
if (token.type === "name" && esutils.keyword.isKeywordES6(token.value)) {
return "keyword";
}
return str;
if (token.type === "punctuation") {
switch (token.value) {
case "{":
case "}":
return "curly";
case "(":
case ")":
return "parens";
case "[":
case "]":
return "square";
}
}
return token.type;
};
return tokenize(text, true).map(function (str) {
var type = tokenize.type(str);
return colorize(str, defs[type]);
}).join("");
return text.replace(jsTokens, function (match) {
var type = tokenType(arguments);
if (type in defs) {
var colorize = ary(defs[type], 1);
return match.split(newline).map(colorize).join("\n");
}
return match;
});
};
module.exports = function (lines, lineNumber, colNumber) {
@@ -46,33 +63,29 @@ module.exports = function (lines, lineNumber, colNumber) {
lines = highlight(lines);
}
lines = lines.split(/\r\n|[\n\r\u2028\u2029]/);
lines = lines.split(newline);
var start = Math.max(lineNumber - 3, 0);
var end = Math.min(lines.length, lineNumber + 3);
var width = (end + "").length;
if (!lineNumber && !colNumber) {
start = 0;
end = lines.length;
}
return "\n" + lines.slice(start, end).map(function (line, i) {
var curr = i + start + 1;
var gutter = curr === lineNumber ? "> " : " ";
var sep = curr + repeating(" ", width + 1);
gutter += sep + "| ";
var str = gutter + line;
if (colNumber && curr === lineNumber) {
str += "\n";
str += repeating(" ", gutter.length - 2);
str += "|" + repeating(" ", colNumber) + "^";
return "\n" + lineNumbers(lines.slice(start, end), {
start: start + 1,
before: " ",
after: " | ",
transform: function (params) {
if (params.number !== lineNumber) {
return;
}
if (colNumber) {
params.line += "\n" + params.before + repeating(" ", params.width) +
params.after + repeating(" ", colNumber - 1) + "^";
}
params.before = params.before.replace(/^./, ">");
}
return str;
}).join("\n");
};

View File

@@ -44,16 +44,19 @@ module.exports = function (exports, opts) {
};
exports.JSXAttribute = {
exit: function (node) {
var value = node.value || t.literal(true);
enter: function (node) {
var value = node.value;
if (t.isLiteral(value) && isString(value.value)) {
value.value = value.value.replace(/\n\s+/g, " ");
}
},
exit: function (node) {
var value = node.value || t.literal(true);
return t.inherits(t.property("init", node.name, value), node);
}
};
exports.JSXOpeningElement = {
exit: function (node, parent, scope, file) {
var tagExpr = node.name;

View File

@@ -5,15 +5,13 @@ var t = require("../../types");
var visitor = {
enter: function (node, parent, scope, state) {
// check if this node is an identifier that matches the same as our function id
if (!t.isIdentifier(node, { name: state.id })) return;
// check if this node is the one referenced
if (!t.isReferenced(node, parent)) return;
// check if this node is a referenced identifier that matches the same as our
// function id
if (!t.isReferencedIdentifier(node, parent, { name: state.name })) return;
// check that we don't have a local variable declared as that removes the need
// for the wrapper
var localDeclar = scope.getBindingIdentifier(state.id);
var localDeclar = scope.getBindingIdentifier(state.name);
if (localDeclar !== state.outerDeclar) return;
state.selfReference = true;
@@ -21,33 +19,100 @@ var visitor = {
}
};
var wrap = function (state, method, id, scope) {
if (state.selfReference) {
var templateName = "property-method-assignment-wrapper";
if (method.generator) templateName += "-generator";
return util.template(templateName, {
FUNCTION: method,
FUNCTION_ID: id,
FUNCTION_KEY: scope.generateUidIdentifier(id.name),
WRAPPER_KEY: scope.generateUidIdentifier(id.name + "Wrapper")
});
} else {
method.id = id;
return method;
}
};
var visit = function (node, name, scope) {
var state = {
selfAssignment: false,
selfReference: false,
outerDeclar: scope.getBindingIdentifier(name),
references: [],
name: name,
};
// check to see if we have a local binding of the id we're setting inside of
// the function, this is important as there are caveats associated
var bindingInfo = scope.getOwnBindingInfo(name);
if (bindingInfo) {
if (bindingInfo.kind === "param") {
// safari will blow up in strict mode with code like:
//
// var t = function t(t) {};
//
// with the error:
//
// Cannot declare a parameter named 't' as it shadows the name of a
// strict mode function.
//
// this isn't to the spec and they've invented this behaviour which is
// **extremely** annoying so we avoid setting the name if it has a param
// with the same id
state.selfReference = true;
} else {
// otherwise it's defined somewhere in scope like:
//
// var t = function () {
// var t = 2;
// };
//
// so we can safely just set the id and move along as it shadows the
// bound function id
}
} else {
scope.traverse(node, visitor, state);
}
return state;
};
exports.property = function (node, file, scope) {
var key = t.toComputedKey(node, node.key);
if (!t.isLiteral(key)) return node; // we can't set a function id with this
var id = t.toIdentifier(key.value);
key = t.identifier(id);
var state = {
id: id,
selfReference: false,
outerDeclar: scope.getBindingIdentifier(id),
};
scope.traverse(node, visitor, state);
var name = t.toIdentifier(key.value);
var id = t.identifier(name);
var method = node.value;
if (state.selfReference) {
var templateName = "property-method-assignment-wrapper";
if (method.generator) templateName += "-generator";
node.value = util.template(templateName, {
FUNCTION: method,
FUNCTION_ID: key,
FUNCTION_KEY: scope.generateUidIdentifier(id),
WRAPPER_KEY: scope.generateUidIdentifier(id + "Wrapper")
});
} else {
method.id = key;
}
var state = visit(method, name, scope);
node.value = wrap(state, method, id, scope);
};
exports.bare = function (node, parent, scope) {
// has an `id` so we don't need to infer one
if (node.id) return;
var id;
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
// { foo: function () {} };
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
// var foo = function () {};
id = parent.id;
} else {
return;
}
if (!t.isIdentifier(id)) return;
var name = t.toIdentifier(id.name);
id = t.identifier(name);
var state = visit(node, name, scope);
return wrap(state, node, id, scope);
};

View File

@@ -1,7 +0,0 @@
(function () {
function GET_OUTER_ID() {
return ID;
}
return FUNCTION;
})()

View File

@@ -0,0 +1,7 @@
(function () {
function GET_OUTER_ID() {
return FUNCTION_ID;
}
return FUNCTION;
})()

View File

@@ -30,7 +30,7 @@ var isLet = function (node, parent) {
};
var isLetInitable = function (node, parent) {
return !t.isFor(parent) || t.isFor(parent) && parent.left !== node;
return !t.isFor(parent) || !t.isFor(parent, { left: node });
};
var isVar = function (node, parent) {

View File

@@ -65,6 +65,7 @@ function ClassTransformer(node, file, scope, isStatement) {
ClassTransformer.prototype.run = function () {
var superName = this.superName;
var className = this.className;
var classBody = this.node.body.body;
var file = this.file;
//
@@ -77,13 +78,21 @@ ClassTransformer.prototype.run = function () {
className
]))
]);
var constructor;
var constructor;
if (this.node.id) {
constructor = t.functionDeclaration(className, [], constructorBody);
body.push(constructor);
} else {
constructor = t.functionExpression(null, [], constructorBody);
var constructorName = null;
// when a class has no parent and there is only a constructor or no body
// then the constructor is not wrapped in a closure and needs to be named
var containsOnlyConstructor = classBody.length === 1 && classBody[0].key.name === "constructor";
if (!this.hasSuper && (classBody.length === 0 || containsOnlyConstructor)) {
constructorName = className;
}
constructor = t.functionExpression(constructorName, [], constructorBody);
body.push(t.variableDeclaration("var", [
t.variableDeclarator(className, constructor)
]));

View File

@@ -168,6 +168,7 @@ DestructuringTransformer.prototype.canUnpackArrayPattern = function (pattern, ar
// pattern has less elements than the array and doesn't have a rest so some
// elements wont be evaluated
if (pattern.elements.length > arr.elements.length) return;
if (pattern.elements.length < arr.elements.length && !hasRest(pattern)) return false;
// deopt on holes
@@ -418,7 +419,7 @@ exports.AssignmentExpression = function (node, parent, scope, file) {
return t.toSequenceExpression(nodes, scope);
};
var variableDeclarationhasPattern = function (node) {
var variableDeclarationHasPattern = function (node) {
for (var i = 0; i < node.declarations.length; i++) {
if (t.isPattern(node.declarations[i].id)) {
return true;
@@ -429,7 +430,7 @@ var variableDeclarationhasPattern = function (node) {
exports.VariableDeclaration = function (node, parent, scope, file) {
if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;
if (!variableDeclarationhasPattern(node)) return;
if (!variableDeclarationHasPattern(node)) return;
var nodes = [];
var declar;

View File

@@ -65,7 +65,7 @@ var loose = function (node, parent, scope, file) {
var left = node.left;
var declar, id;
if (t.isIdentifier(left) || t.isPattern(left)) {
if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
// for (i of test), for ({ i } of test)
id = left;
} else if (t.isVariableDeclaration(left)) {
@@ -126,7 +126,7 @@ var spec = function (node, parent, scope, file) {
var stepKey = scope.generateUidIdentifier("step");
var stepValue = t.memberExpression(stepKey, t.identifier("value"));
if (t.isIdentifier(left) || t.isPattern(left)) {
if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
// for (i of test), for ({ i } of test)
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
} else if (t.isVariableDeclaration(left)) {

View File

@@ -5,6 +5,9 @@ var t = require("../../../types");
exports.check = require("../internal/modules").check;
exports.ImportDeclaration = function (node, parent, scope, file) {
// flow type
if (node.isType) return;
var nodes = [];
if (node.specifiers.length) {
@@ -24,6 +27,9 @@ exports.ImportDeclaration = function (node, parent, scope, file) {
};
exports.ExportDeclaration = function (node, parent, scope, file) {
// flow type
if (t.isTypeAlias(node.declaration)) return;
var nodes = [];
var i;

View File

@@ -10,6 +10,9 @@ module.exports = {
"validation.react": require("./validation/react"),
"spec.blockScopedFunctions": require("./spec/block-scoped-functions"),
// needs to be before `_aliasFunction`
"es6.arrowFunctions": require("./es6/arrow-functions"),
"playground.malletOperator": require("./playground/mallet-operator"),
"playground.methodBinding": require("./playground/method-binding"),
"playground.memoizationOperator": require("./playground/memoization-operator"),
@@ -25,9 +28,6 @@ module.exports = {
// needs to be before `_aliasFunction`
"es7.comprehensions": require("./es7/comprehensions"),
// needs to be before `_aliasFunction`
"es6.arrowFunctions": require("./es6/arrow-functions"),
"es6.classes": require("./es6/classes"),
asyncToGenerator: require("./other/async-to-generator"),

View File

@@ -24,6 +24,9 @@ exports.ImportDeclaration = resolveModuleSource;
exports.ExportDeclaration = function (node, parent, scope) {
resolveModuleSource.apply(null, arguments);
// flow type
if (node.isType) return;
var declar = node.declaration;
if (node.default) {

View File

@@ -8,10 +8,17 @@ var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
exports.Program = function (node, parent, scope, file) {
var id = "React.createElement";
var comment = file.ast.comments[0];
if (comment) {
for (var i = 0; i < file.ast.comments.length; i++) {
var comment = file.ast.comments[i];
var matches = JSX_ANNOTATION_REGEX.exec(comment.value);
if (matches) id = matches[1];
if (matches) {
id = matches[1];
if (id === "React.DOM") {
throw file.errorWithNode(comment, "The @jsx React.DOM pragma has been deprecated as of React 0.12");
} else {
break;
}
}
}
file.set("jsxIdentifier", id.split(".").map(t.identifier).reduce(function (object, property) {

View File

@@ -1,95 +1,5 @@
"use strict";
var t = require("../../../types");
var util = require("../../../util");
var nameMethod = require("../../helpers/name-method");
var propertyFunctionVisitor = {
enter: function (node, parent, scope, state) {
if (t.isReferencedIdentifier(node, parent, { name: state.name }) && scope.getBindingIdentifier(node.name) === state.binding) {
return state.getOuter();
}
}
};
//exports.ArrowFunctionExpression =
exports.FunctionExpression = function (node, parent, scope) {
// has an `id` so we don't need to infer one
if (node.id) return;
var id;
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
// { foo: function () {} };
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
// var foo = function () {};
id = parent.id;
} else {
return;
}
if (!t.isIdentifier(id)) return;
var name = t.toIdentifier(id.name);
id = t.identifier(name);
// check to see if we have a local binding of the id we're setting inside of
// the function, this is important as there are caveats associated
var bindingInfo = scope.getOwnBindingInfo(name);
if (bindingInfo) {
if (bindingInfo.type === "param") {
// safari will blow up in strict mode with code like:
//
// var t = function t(t) {};
//
// with the error:
//
// Cannot declare a parameter named 't' as it shadows the name of a
// strict mode function.
//
// this isn't to the spec and they've invented this behaviour which is
// **extremely** annoying so we avoid setting the name if it has a param
// with the same id
} else {
// otherwise it's defined somewhere in scope like:
//
// var t = function () {
// var t = 2;
// };
//
// so we can safely just set the id and move along as it shadows the
// bound function id
node.id = id;
}
return;
}
//
var binding = scope.getBindingIdentifier(name);
var outerId;
scope.traverse(node, propertyFunctionVisitor, {
name: name,
binding: binding,
getOuter: function () {
return t.callExpression(
outerId || (outerId = scope.generateUidIdentifier("getOuter")),
[]
);
}
});
node.id = id;
if (outerId) {
return util.template("named-func", {
GET_OUTER_ID: outerId,
FUNCTION: node,
ID: id
});
}
};
exports.FunctionExpression = nameMethod.bare;

View File

@@ -48,7 +48,6 @@
"AssignmentPattern": ["Pattern"],
"Property": ["UserWhitespacable"],
"JSXElement": ["UserWhitespacable", "Expression"],
"ArrayExpression": ["Expression"],
"AssignmentExpression": ["Expression"],
@@ -74,7 +73,7 @@
"JSXAttribute": ["JSX"],
"JSXClosingElement": ["JSX"],
"JSXElement": ["JSX"],
"JSXElement": ["JSX", "Expression"],
"JSXEmptyExpression": ["JSX"],
"JSXExpressionContainer": ["JSX"],
"JSXIdentifier": ["JSX"],

View File

@@ -1,7 +1,7 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.4.3",
"version": "4.4.6",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",
@@ -36,12 +36,12 @@
"test": "make test"
},
"dependencies": {
"acorn-babel": "0.11.1-33",
"acorn-babel": "0.11.1-34",
"ast-types": "~0.6.1",
"chalk": "^0.5.1",
"chalk": "^1.0.0",
"chokidar": "^0.12.6",
"commander": "^2.6.0",
"core-js": "^0.5.4",
"core-js": "^0.6.1",
"debug": "^2.1.1",
"detect-indent": "^3.0.0",
"estraverse": "^1.9.1",
@@ -49,13 +49,14 @@
"fs-readdir-recursive": "^0.1.0",
"globals": "^6.2.0",
"is-integer": "^1.0.4",
"js-tokenizer": "^1.3.3",
"js-tokens": "0.4.1",
"leven": "^1.0.1",
"line-numbers": "0.2.0",
"lodash": "^3.2.0",
"output-file-sync": "^1.1.0",
"path-is-absolute": "^1.0.0",
"private": "^0.1.6",
"regenerator-babel": "0.8.10-2",
"regenerator-babel": "0.8.13-1",
"regexpu": "^1.1.1",
"repeating": "^1.1.2",
"shebang-regex": "^1.0.0",

View File

@@ -1,7 +1,7 @@
{
"name": "babel-runtime",
"description": "babel selfContained runtime",
"version": "4.4.2",
"version": "4.4.5",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>"
}

View File

@@ -0,0 +1,20 @@
class TestEmpty extends (class {}) {
}
class TestConstructorOnly extends (class { constructor() {} }) {
}
class TestMethodOnly extends (class { method() {} }) {
}
class TestConstructorAndMethod extends (class {
constructor() {}
method() {}
}) {
}
class TestMultipleMethods extends (class {
m1() {}
m2() {}
}) {
}

View File

@@ -0,0 +1,129 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var TestEmpty = (function (_ref) {
function TestEmpty() {
_classCallCheck(this, TestEmpty);
if (_ref != null) {
_ref.apply(this, arguments);
}
}
_inherits(TestEmpty, _ref);
return TestEmpty;
})(function _class() {
_classCallCheck(this, _class);
});
var TestConstructorOnly = (function (_ref2) {
function TestConstructorOnly() {
_classCallCheck(this, TestConstructorOnly);
if (_ref2 != null) {
_ref2.apply(this, arguments);
}
}
_inherits(TestConstructorOnly, _ref2);
return TestConstructorOnly;
})(function _class2() {
_classCallCheck(this, _class2);
});
var TestMethodOnly = (function (_ref3) {
function TestMethodOnly() {
_classCallCheck(this, TestMethodOnly);
if (_ref3 != null) {
_ref3.apply(this, arguments);
}
}
_inherits(TestMethodOnly, _ref3);
return TestMethodOnly;
})((function () {
var _class3 = function () {
_classCallCheck(this, _class3);
};
_prototypeProperties(_class3, null, {
method: {
value: function method() {},
writable: true,
configurable: true
}
});
return _class3;
})());
var TestConstructorAndMethod = (function (_ref4) {
function TestConstructorAndMethod() {
_classCallCheck(this, TestConstructorAndMethod);
if (_ref4 != null) {
_ref4.apply(this, arguments);
}
}
_inherits(TestConstructorAndMethod, _ref4);
return TestConstructorAndMethod;
})((function () {
var _class4 = function () {
_classCallCheck(this, _class4);
};
_prototypeProperties(_class4, null, {
method: {
value: function method() {},
writable: true,
configurable: true
}
});
return _class4;
})());
var TestMultipleMethods = (function (_ref5) {
function TestMultipleMethods() {
_classCallCheck(this, TestMultipleMethods);
if (_ref5 != null) {
_ref5.apply(this, arguments);
}
}
_inherits(TestMultipleMethods, _ref5);
return TestMultipleMethods;
})((function () {
var _class5 = function () {
_classCallCheck(this, _class5);
};
_prototypeProperties(_class5, null, {
m1: {
value: function m1() {},
writable: true,
configurable: true
},
m2: {
value: function m2() {},
writable: true,
configurable: true
}
});
return _class5;
})());

View File

@@ -1 +1 @@
var [a, [b], [c], d] = ["hello", [", ", "junk"], ["world"]];
var [a, [b], [c]] = ["hello", [", ", "junk"], ["world"]];

View File

@@ -4,4 +4,3 @@ var a = "hello";
var _ref = [", ", "junk"];
var b = _ref[0];
var c = "world";
var d;

View File

@@ -0,0 +1,3 @@
for (obj.prop of arr) {
}

View File

@@ -0,0 +1,12 @@
"use strict";
for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
if (_isArray) {
if (_i >= _iterator.length) break;
obj.prop = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
obj.prop = _i.value;
}
}

View File

@@ -1,3 +0,0 @@
for (foo.bar of test) {
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Unknown node type \"MemberExpression\" in ForStatement"
}

View File

@@ -0,0 +1,3 @@
for (obj.prop of arr) {
}

View File

@@ -0,0 +1,5 @@
"use strict";
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
obj.prop = _step.value;
}

View File

@@ -1,7 +1,7 @@
var t = function (t = "foo", f = 5) {
return t + " bar " + f;
var t = function (e = "foo", f = 5) {
return e + " bar " + f;
};
var a = function (t, f = 5) {
return t + " bar " + f;
var a = function (e, f = 5) {
return e + " bar " + f;
};

View File

@@ -1,14 +1,14 @@
"use strict";
var t = function t() {
var t = arguments[0] === undefined ? "foo" : arguments[0];
var e = arguments[0] === undefined ? "foo" : arguments[0];
var f = arguments[1] === undefined ? 5 : arguments[1];
return t + " bar " + f;
return e + " bar " + f;
};
var a = function a(t) {
var a = function a(e) {
var f = arguments[1] === undefined ? 5 : arguments[1];
return t + " bar " + f;
return e + " bar " + f;
};

View File

@@ -1,3 +1,3 @@
var t = function (t = "foo") {
return t + " bar";
var t = function (f = "foo") {
return f + " bar";
};

View File

@@ -1,7 +1,7 @@
"use strict";
var t = function t() {
var t = arguments[0] === undefined ? "foo" : arguments[0];
var f = arguments[0] === undefined ? "foo" : arguments[0];
return t + " bar";
return f + " bar";
};

View File

@@ -1,19 +0,0 @@
var bar = {
foo() {
console.log(foo);
}
};
var bar = {
foo() {
var foo = 41;
console.log(foo);
}
};
var foobar = 123;
var foobar2 = {
foobar() {
console.log(foobar);
}
};

View File

@@ -1,33 +0,0 @@
"use strict";
var bar = {
foo: (function () {
function _getOuter() {
return foo;
}
return function foo() {
console.log(_getOuter());
};
})()
};
var bar = {
foo: function foo() {
var foo = 41;
console.log(foo);
}
};
var foobar = 123;
var foobar2 = {
foobar: (function () {
function _getOuter() {
return foobar;
}
return function foobar() {
console.log(_getOuter());
};
})()
};

View File

@@ -1,3 +0,0 @@
{
"blacklist": ["es6.tailCall"]
}

View File

@@ -1,27 +0,0 @@
var obj = {
f: function () {
(function f() {
console.log(f);
})();
},
g: function () {
console.log(g);
},
h: function () {
console.log(h);
},
m: function () {
doSmth();
}
};
var f = function () {
console.log(f, g);
};
var g = function () {
doSmth();
};

View File

@@ -0,0 +1,48 @@
var obj = {
// localy declared variable
f: function () {
(function f() {
console.log(f);
})();
},
// self reference
h: function () {
console.log(h);
},
// no reference
m: function () {
doSmth();
}
};
// locally declared variable
var f = function () {
var f = 2;
};
// self reference
var f = function () {
console.log(f, g);
};
// no reference
var g = function () {
doSmth();
};
// param with the same name as id
var h = function (h) {
};
// assignment to self
var i = function () {
i = 5;
};
// assignment to self
var j = function () {
({ j }) = 5;
};

View File

@@ -0,0 +1,89 @@
"use strict";
var obj = {
// localy declared variable
f: function f() {
(function f() {
console.log(f);
})();
},
// self reference
h: (function (_h) {
var _hWrapper = function h() {
return _h.apply(this, arguments);
};
_hWrapper.toString = function () {
return _h.toString();
};
return _hWrapper;
})(function () {
console.log(h);
}),
// no reference
m: function m() {
doSmth();
}
};
// locally declared variable
var f = function f() {
var f = 2;
};
// self reference
var f = (function (_f) {
var _fWrapper = function f() {
return _f.apply(this, arguments);
};
_fWrapper.toString = function () {
return _f.toString();
};
return _fWrapper;
})(function () {
console.log(f, g);
});
// no reference
var g = function g() {
doSmth();
};
// param with the same name as id
var h = (function (_h) {
var _hWrapper = function h() {
return _h.apply(this, arguments);
};
_hWrapper.toString = function () {
return _h.toString();
};
return _hWrapper;
})(function (h) {});
// assignment to self
var i = (function (_i) {
var _iWrapper = function i() {
return _i.apply(this, arguments);
};
_iWrapper.toString = function () {
return _i.toString();
};
return _iWrapper;
})(function () {
i = 5;
});
// assignment to self
var j = function j() {
var _ref = 5;
j = _ref.j;
};

View File

@@ -1,42 +0,0 @@
"use strict";
var _selfGlobal = typeof global === "undefined" ? self : global;
var obj = {
f: function f() {
(function f() {
console.log(f);
})();
},
g: (function () {
function _getOuter() {
return g;
}
return function g() {
console.log(_getOuter());
};
})(),
h: function h() {
console.log(_selfGlobal.h);
},
m: function m() {
doSmth();
}
};
var f = (function () {
function _getOuter() {
return f;
}
return function f() {
console.log(_getOuter(), g);
};
})();
var g = function g() {
doSmth();
};

View File

@@ -1,3 +0,0 @@
{
"whitelist": ["spec.functionName"]
}