more es6
This commit is contained in:
parent
5d32432e67
commit
44e4dc970f
@ -55,7 +55,7 @@ var highlight = function (text) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = function (lines, lineNumber, colNumber) {
|
||||
export default function (lines, lineNumber, colNumber) {
|
||||
colNumber = Math.max(colNumber, 0);
|
||||
|
||||
if (chalk.supportsColor) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import t from "../types";
|
||||
|
||||
module.exports = function (ast, comments, tokens) {
|
||||
export default function (ast, comments, tokens) {
|
||||
if (ast && ast.type === "Program") {
|
||||
return t.file(ast, comments || [], tokens || []);
|
||||
} else {
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
module.exports = function () {
|
||||
export default function () {
|
||||
return Object.create(null);
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@ import estraverse from "estraverse";
|
||||
import codeFrame from "./code-frame";
|
||||
import acorn from "acorn-babel";
|
||||
|
||||
module.exports = function (opts, code, callback) {
|
||||
export default function (opts, code, callback) {
|
||||
try {
|
||||
var comments = [];
|
||||
var tokens = [];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import explode from "./explode-assignable-expression";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
export default function (exports, opts) {
|
||||
var isAssignment = function (node) {
|
||||
return node.operator === opts.operator + "=";
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function build(node, buildBody) {
|
||||
export default function build(node, buildBody) {
|
||||
var self = node.blocks.shift();
|
||||
if (!self) return;
|
||||
|
||||
@ -20,4 +20,4 @@ module.exports = function build(node, buildBody) {
|
||||
self.right,
|
||||
t.blockStatement([child])
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import explode from "./explode-assignable-expression";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
export default function (exports, opts) {
|
||||
var buildAssignment = function (left, right) {
|
||||
return t.assignmentExpression("=", left, right);
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ import esutils from "esutils";
|
||||
import * as react from "./react";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
export default function (exports, opts) {
|
||||
exports.check = function (node) {
|
||||
if (t.isJSX(node)) return true;
|
||||
if (react.isCreateClass(node)) return true;
|
||||
|
||||
@ -45,7 +45,7 @@ var getPropRef = function (node, nodes, file, scope) {
|
||||
return temp;
|
||||
};
|
||||
|
||||
module.exports = function (node, nodes, file, scope, allowedSingleIdent) {
|
||||
export default function (node, nodes, file, scope, allowedSingleIdent) {
|
||||
var obj;
|
||||
if (t.isIdentifier(node) && allowedSingleIdent) {
|
||||
obj = node;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (node) {
|
||||
export default function (node) {
|
||||
var lastNonDefault = 0;
|
||||
for (var i = 0; i < node.params.length; i++) {
|
||||
if (!t.isAssignmentPattern(node.params[i])) lastNonDefault = i + 1;
|
||||
|
||||
@ -16,7 +16,7 @@ var visitor = {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function (node, callId, scope) {
|
||||
export default function (node, callId, scope) {
|
||||
node.async = false;
|
||||
node.generator = true;
|
||||
|
||||
|
||||
@ -42,8 +42,8 @@ var remapVisitor = {
|
||||
};
|
||||
|
||||
var importsVisitor = {
|
||||
enter(node, parent, scope, formatter) {
|
||||
if (t.isImportDeclaration(node)) {
|
||||
ImportDeclaration: {
|
||||
enter(node, parent, scope, formatter) {
|
||||
formatter.hasLocalImports = true;
|
||||
extend(formatter.localImports, t.getBindingIdentifiers(node));
|
||||
formatter.bumpImportOccurences(node);
|
||||
@ -52,9 +52,9 @@ var importsVisitor = {
|
||||
};
|
||||
|
||||
var exportsVisitor = {
|
||||
enter(node, parent, scope, formatter) {
|
||||
var declar = node && node.declaration;
|
||||
if (t.isExportDeclaration(node)) {
|
||||
ExportDeclaration: {
|
||||
enter(node, parent, scope, formatter) {
|
||||
var declar = node.declaration;
|
||||
formatter.hasLocalImports = true;
|
||||
|
||||
if (declar && t.isStatement(declar)) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
commonStrict: require("./common-strict"),
|
||||
amdStrict: require("./amd-strict"),
|
||||
umdStrict: require("./umd-strict"),
|
||||
|
||||
@ -2,7 +2,7 @@ import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
|
||||
// check if the input Literal `source` is an alternate casing of "react"
|
||||
var check = function (source, file) {
|
||||
function check(source, file) {
|
||||
if (t.isLiteral(source)) {
|
||||
var name = source.value;
|
||||
var lower = name.toLowerCase();
|
||||
@ -11,7 +11,7 @@ var check = function (source, file) {
|
||||
throw file.errorWithNode(source, messages.get("didYouMean", "react"));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function CallExpression(node, parent, scope, file) {
|
||||
if (t.isIdentifier(node.callee, { name: "require" }) && node.arguments.length === 1) {
|
||||
|
||||
@ -6,10 +6,9 @@ export default class TraversalContext {
|
||||
constructor(scope, opts, state, parentPath) {
|
||||
this.shouldFlatten = false;
|
||||
this.parentPath = parentPath;
|
||||
|
||||
this.scope = scope;
|
||||
this.state = state;
|
||||
this.opts = opts;
|
||||
this.scope = scope;
|
||||
this.state = state;
|
||||
this.opts = opts;
|
||||
}
|
||||
|
||||
flatten() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user