Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Update to use Node 4 features (#425)
Browse files Browse the repository at this point in the history
* Change for loops to forEach

* Change more for loops

* Arrow functions

* Use object shorthand

* Put this on one line

* Change back to using for loops
  • Loading branch information
nhajidin authored and hzoo committed Jan 14, 2017
1 parent 265d219 commit 781dc77
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 246 deletions.
10 changes: 5 additions & 5 deletions babylon-to-espree/toAST.js
Expand Up @@ -31,7 +31,7 @@ function changeComments(nodeComments) {

var astTransformVisitor = {
noScope: true,
enter: function (path) {
enter (path) {
var node = path.node;

node.range = [node.start, node.end];
Expand All @@ -55,12 +55,12 @@ var astTransformVisitor = {
// make '_paths' non-enumerable (babel-eslint #200)
Object.defineProperty(node, "_paths", { value: node._paths, writable: true });
},
exit: function (path) {
exit (path) {
var node = path.node;

[
fixDirectives,
].forEach(function (fixer) {
].forEach((fixer) => {
fixer(path);
});

Expand Down Expand Up @@ -211,7 +211,7 @@ var astTransformVisitor = {

// template string range fixes
if (path.isTemplateLiteral()) {
node.quasis.forEach(function (q) {
node.quasis.forEach((q) => {
q.range[0] -= 1;
if (q.tail) {
q.range[1] += 1;
Expand Down Expand Up @@ -244,7 +244,7 @@ function fixDirectives (path) {

if (!directivesContainer.directives) return;

directivesContainer.directives.reverse().forEach(function (directive) {
directivesContainer.directives.reverse().forEach((directive) => {
directive.type = "ExpressionStatement";
directive.expression = directive.value;
delete directive.value;
Expand Down
2 changes: 1 addition & 1 deletion babylon-to-espree/toTokens.js
Expand Up @@ -4,7 +4,7 @@ var toToken = require("./toToken");
module.exports = function (tokens, tt, code) {
// transform tokens to type "Template"
convertTemplateType(tokens, tt);
var transformedTokens = tokens.filter(function (token) {
var transformedTokens = tokens.filter((token) => {
return token.type !== "CommentLine" && token.type !== "CommentBlock";
});

Expand Down
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -44,7 +44,7 @@ function monkeypatch() {
estraverses.push(estraverseOfEslint);
Object.assign(estraverseOfEslint.VisitorKeys, t.VISITOR_KEYS);

estraverses.forEach(function (estraverse) {
estraverses.forEach((estraverse) => {
estraverse.VisitorKeys.MethodDefinition.push("decorators");
estraverse.VisitorKeys.Property.push("decorators");
});
Expand Down Expand Up @@ -100,7 +100,7 @@ function monkeypatch() {
}

// iterate through part of t.VISITOR_KEYS
var visitorKeysMap = pick(t.VISITOR_KEYS, function(k) {
var visitorKeysMap = pick(t.VISITOR_KEYS, (k) => {
return t.FLIPPED_ALIAS_KEYS.Flow.concat([
"ArrayPattern",
"ClassDeclaration",
Expand Down Expand Up @@ -268,13 +268,13 @@ function monkeypatch() {
}
// set ArrayPattern/ObjectPattern visitor keys back to their original. otherwise
// escope will traverse into them and include the identifiers within as declarations
estraverses.forEach(function (estraverse) {
estraverses.forEach((estraverse) => {
estraverse.VisitorKeys.ObjectPattern = ["properties"];
estraverse.VisitorKeys.ArrayPattern = ["elements"];
});
visitFunction.call(this, node);
// set them back to normal...
estraverses.forEach(function (estraverse) {
estraverses.forEach((estraverse) => {
estraverse.VisitorKeys.ObjectPattern = t.VISITOR_KEYS.ObjectPattern;
estraverse.VisitorKeys.ArrayPattern = t.VISITOR_KEYS.ArrayPattern;
});
Expand Down

0 comments on commit 781dc77

Please sign in to comment.