move eslint out of the core into a separate plugin
This commit is contained in:
@@ -2,13 +2,13 @@ import isFunction from "lodash/lang/isFunction";
|
||||
import transform from "../transformation";
|
||||
import fs from "fs";
|
||||
|
||||
export { default as acorn } from "acorn-babel";
|
||||
export { default as _util, canCompile } from "../util";
|
||||
export { default as transform } from "../transformation";
|
||||
|
||||
export { version } from "../../../package";
|
||||
|
||||
export { default as traverse } from "../traversal";
|
||||
export { default as buildExternalHelpers } from "../build-external-helpers";
|
||||
export { default as types } from "../types";
|
||||
export { version } from "../../../package";
|
||||
|
||||
export function register(opts) {
|
||||
var callback = require("./register/node");
|
||||
|
||||
@@ -11,7 +11,9 @@ import n from "./node";
|
||||
import t from "../types";
|
||||
|
||||
class CodeGenerator {
|
||||
constructor(ast, opts = {}, code) {
|
||||
constructor(ast, opts, code) {
|
||||
opts ||= {};
|
||||
|
||||
this.comments = ast.comments || [];
|
||||
this.tokens = ast.tokens || [];
|
||||
this.format = CodeGenerator.normalizeOptions(code, opts);
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import traverse from "../traversal";
|
||||
import { tokTypes } from "acorn-babel";
|
||||
import t from "../types";
|
||||
|
||||
export function toEsprimaToken(token) {
|
||||
var type = token.type;
|
||||
|
||||
if (type === tokTypes.name) {
|
||||
token.type = "Identifier";
|
||||
} else if (type === tokTypes.semi || type === tokTypes.comma || type === tokTypes.parenL || type === tokTypes.parenR || type === tokTypes.braceL || type === tokTypes.braceR) {
|
||||
token.type = "Punctuator";
|
||||
token.value = type.type;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
export function toEsprimaAST(ast) {
|
||||
traverse(ast, astTransformVisitor);
|
||||
}
|
||||
|
||||
var astTransformVisitor = {
|
||||
noScope: true,
|
||||
enter(node) {
|
||||
if (t.isImportBatchSpecifier(node)) {
|
||||
node.type = "ImportNamespaceSpecifier";
|
||||
node.id = node.name;
|
||||
delete node.name;
|
||||
} else if (t.isFunction(node)) {
|
||||
node.defaults = [];
|
||||
|
||||
node.params = node.params.map(function (param) {
|
||||
if (t.isAssignmentPattern(param)) {
|
||||
node.defaults.push(param.right);
|
||||
return param.left;
|
||||
} else {
|
||||
node.defaults.push(null);
|
||||
return param;
|
||||
}
|
||||
});
|
||||
|
||||
if (t.isRestElement(node.params[node.params.length - 1])) {
|
||||
node.rest = node.params.pop();
|
||||
}
|
||||
} else if (t.isClassProperty(node)) {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user