Remove babel.analyse and surrounding helpers.

This commit is contained in:
Logan Smyth
2017-09-29 11:44:32 -07:00
parent 655d1cc91b
commit 8339e036bf
5 changed files with 1 additions and 56 deletions

View File

@@ -31,7 +31,6 @@ export function Plugin(alias) {
export {
transform,
analyse,
transformFromAst,
transformFile,
transformFileSync,

View File

@@ -67,7 +67,6 @@ export default class File {
}
this.metadata = {
marked: [],
modules: {
imports: [],
exports: {

View File

@@ -1,23 +1,10 @@
/* global BabelFileResult, BabelFileMetadata */
/* global BabelFileResult */
import fs from "fs";
import * as t from "babel-types";
import File from "./file";
import loadConfig from "../config";
export function analyse(
code: string,
opts: Object = {},
visitor?: Object,
): ?BabelFileMetadata {
opts.code = false;
if (visitor) {
opts.plugins = opts.plugins || [];
opts.plugins.push({ visitor });
}
return transform(code, opts).metadata;
}
export function transform(code: string, opts?: Object): BabelFileResult {
const config = loadConfig(opts);
if (config === null) return null;

View File

@@ -103,38 +103,6 @@ describe("parser and generator options", function() {
});
describe("api", function() {
it("analyze", function() {
assert.equal(babel.analyse("foobar;").marked.length, 0);
assert.equal(
babel.analyse("foobar;", {
plugins: [
new Plugin({
visitor: {
Program: function(path) {
path.mark("category", "foobar");
},
},
}),
],
}).marked[0].message,
"foobar",
);
assert.equal(
babel.analyse(
"foobar;",
{},
{
Program: function(path) {
path.mark("category", "foobar");
},
},
).marked[0].message,
"foobar",
);
});
it("exposes the resolvePlugin method", function() {
assert.throws(
() => babel.resolvePlugin("nonexistent-plugin"),

View File

@@ -126,14 +126,6 @@ export default class NodePath {
traverse(this.node, visitor, this.scope, state, this);
}
mark(type: string, message: string) {
this.hub.file.metadata.marked.push({
type,
message,
loc: this.node.loc,
});
}
set(key: string, node: Object) {
t.validate(this.node, key, node);
this.node[key] = node;