reneable eslint and fix assorted linting errors
This commit is contained in:
parent
3139482358
commit
ec74eb41cf
@ -10,11 +10,15 @@
|
|||||||
"no-return-assign": 0,
|
"no-return-assign": 0,
|
||||||
"consistent-return": 0,
|
"consistent-return": 0,
|
||||||
"no-shadow": 0,
|
"no-shadow": 0,
|
||||||
"no-comma-dangle": 0,
|
"comma-dangle": 0,
|
||||||
"no-use-before-define": 0,
|
"no-use-before-define": 0,
|
||||||
"no-empty": 0,
|
"no-empty": 0,
|
||||||
"new-parens": 0,
|
"new-parens": 0,
|
||||||
"no-cond-assign": 0
|
"no-cond-assign": 0,
|
||||||
|
"no-fallthrough": 0,
|
||||||
|
"new-cap": 0,
|
||||||
|
"no-loop-func": 0,
|
||||||
|
"no-unreachable": 0
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"node": true
|
"node": true
|
||||||
|
|||||||
7
Makefile
7
Makefile
@ -22,6 +22,9 @@ watch-core: clean-core
|
|||||||
clean-core:
|
clean-core:
|
||||||
rm -rf lib
|
rm -rf lib
|
||||||
|
|
||||||
|
lint:
|
||||||
|
eslint src/babel
|
||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
make build-core
|
make build-core
|
||||||
@ -61,7 +64,7 @@ test-cov:
|
|||||||
test-parser:
|
test-parser:
|
||||||
node test/acorn/run.js
|
node test/acorn/run.js
|
||||||
|
|
||||||
test-travis: bootstrap build test
|
test-travis: bootstrap lint build test
|
||||||
|
|
||||||
test-browser:
|
test-browser:
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
@ -73,7 +76,7 @@ test-browser:
|
|||||||
|
|
||||||
test -n "`which open`" && open test/browser.html
|
test -n "`which open`" && open test/browser.html
|
||||||
|
|
||||||
publish:
|
publish: lint
|
||||||
git pull --rebase
|
git pull --rebase
|
||||||
|
|
||||||
make test
|
make test
|
||||||
|
|||||||
@ -67,8 +67,8 @@
|
|||||||
"babel": "5.3.1",
|
"babel": "5.3.1",
|
||||||
"browserify": "^9.0.8",
|
"browserify": "^9.0.8",
|
||||||
"chai": "^2.2.0",
|
"chai": "^2.2.0",
|
||||||
"eslint": "^0.18.0",
|
"eslint": "^0.21.2",
|
||||||
"babel-eslint": "^2.0.0",
|
"babel-eslint": "^3.1.8",
|
||||||
"esvalid": "^1.1.0",
|
"esvalid": "^1.1.0",
|
||||||
"istanbul": "^0.3.5",
|
"istanbul": "^0.3.5",
|
||||||
"matcha": "^0.6.0",
|
"matcha": "^0.6.0",
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint no-new-func: 0 */
|
||||||
|
|
||||||
require("./node");
|
require("./node");
|
||||||
var transform = module.exports = require("../transformation");
|
var transform = module.exports = require("../transformation");
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// required to safely use babel/register within a browserify codebase
|
// required to safely use babel/register within a browserify codebase
|
||||||
|
|
||||||
export default function () {};
|
export default function () {}
|
||||||
|
|
||||||
import "../../polyfill";
|
import "../../polyfill";
|
||||||
|
|||||||
@ -164,4 +164,4 @@ export default function (opts = {}) {
|
|||||||
delete opts.only;
|
delete opts.only;
|
||||||
|
|
||||||
extend(transformOpts, opts);
|
extend(transformOpts, opts);
|
||||||
};
|
}
|
||||||
|
|||||||
@ -107,9 +107,9 @@ export function ImportDeclaration(node, print) {
|
|||||||
|
|
||||||
if (node.specifiers.length) {
|
if (node.specifiers.length) {
|
||||||
this.push("{");
|
this.push("{");
|
||||||
this.space()
|
this.space();
|
||||||
print.join(node.specifiers, { separator: ", " });
|
print.join(node.specifiers, { separator: ", " });
|
||||||
this.space()
|
this.space();
|
||||||
this.push("}");
|
this.push("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint quotes: 0 */
|
||||||
|
|
||||||
import each from "lodash/collection/each";
|
import each from "lodash/collection/each";
|
||||||
import * as t from "../../types";
|
import * as t from "../../types";
|
||||||
|
|
||||||
|
|||||||
@ -252,9 +252,7 @@ class CodeGenerator {
|
|||||||
|
|
||||||
if (opts.indent) this.indent();
|
if (opts.indent) this.indent();
|
||||||
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
var printOpts = {
|
||||||
var node = nodes[i];
|
|
||||||
print(node, {
|
|
||||||
statement: opts.statement,
|
statement: opts.statement,
|
||||||
addNewlines: opts.addNewlines,
|
addNewlines: opts.addNewlines,
|
||||||
after: () => {
|
after: () => {
|
||||||
@ -266,7 +264,11 @@ class CodeGenerator {
|
|||||||
this.push(opts.separator);
|
this.push(opts.separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
|
var node = nodes[i];
|
||||||
|
print(node, printOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.indent) this.dedent();
|
if (opts.indent) this.dedent();
|
||||||
@ -318,7 +320,7 @@ class CodeGenerator {
|
|||||||
nodes.push(node.argument);
|
nodes.push(node.argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var node of (nodes: Array)) {
|
for (let node of (nodes: Array)) {
|
||||||
comments = comments.concat(this._getComments(key, node));
|
comments = comments.concat(this._getComments(key, node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -85,4 +85,4 @@ export default function (lines: number, lineNumber: number, colNumber: number, o
|
|||||||
params.before = params.before.replace(/^./, ">");
|
params.before = params.before.replace(/^./, ">");
|
||||||
}
|
}
|
||||||
}).join("\n");
|
}).join("\n");
|
||||||
};
|
}
|
||||||
|
|||||||
@ -6,4 +6,4 @@ export default function (ast, comments, tokens) {
|
|||||||
} else {
|
} else {
|
||||||
throw new Error("Not a valid ast?");
|
throw new Error("Not a valid ast?");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
export default function () {
|
export default function () {
|
||||||
return Object.create(null);
|
return Object.create(null);
|
||||||
};
|
}
|
||||||
|
|||||||
@ -83,4 +83,4 @@ export default function (whitelist, outputType = "global") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return generator(tree).code;
|
return generator(tree).code;
|
||||||
};
|
}
|
||||||
|
|||||||
@ -56,4 +56,4 @@ export default function (loc, opts = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return opts;
|
return opts;
|
||||||
};
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import * as optionParsers from "./option-parsers";
|
|||||||
import moduleFormatters from "../modules";
|
import moduleFormatters from "../modules";
|
||||||
import PluginManager from "./plugin-manager";
|
import PluginManager from "./plugin-manager";
|
||||||
import shebangRegex from "shebang-regex";
|
import shebangRegex from "shebang-regex";
|
||||||
import TraversalPath from "../../traversal/path";
|
import NodePath from "../../traversal/path";
|
||||||
import Transformer from "../transformer";
|
import Transformer from "../transformer";
|
||||||
import isFunction from "lodash/lang/isFunction";
|
import isFunction from "lodash/lang/isFunction";
|
||||||
import isAbsolute from "path-is-absolute";
|
import isAbsolute from "path-is-absolute";
|
||||||
@ -195,7 +195,7 @@ export default class File {
|
|||||||
// build internal transformers
|
// build internal transformers
|
||||||
for (var key in this.pipeline.transformers) {
|
for (var key in this.pipeline.transformers) {
|
||||||
var transformer = this.pipeline.transformers[key];
|
var transformer = this.pipeline.transformers[key];
|
||||||
var pass = transformers[key] = transformer.buildPass(file);
|
let pass = transformers[key] = transformer.buildPass(file);
|
||||||
|
|
||||||
if (pass.canTransform()) {
|
if (pass.canTransform()) {
|
||||||
stack.push(pass);
|
stack.push(pass);
|
||||||
@ -228,7 +228,7 @@ export default class File {
|
|||||||
this.uncollapsedTransformerStack = stack = stack.concat(secondaryStack);
|
this.uncollapsedTransformerStack = stack = stack.concat(secondaryStack);
|
||||||
|
|
||||||
// build dependency graph
|
// build dependency graph
|
||||||
for (var pass of (stack: Array)) {
|
for (let pass of (stack: Array)) {
|
||||||
for (var dep of (pass.transformer.dependencies: Array)) {
|
for (var dep of (pass.transformer.dependencies: Array)) {
|
||||||
this.transformerDependencies[dep] = pass.key;
|
this.transformerDependencies[dep] = pass.key;
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ export default class File {
|
|||||||
outputMapGenerator.applySourceMap(inputMapConsumer);
|
outputMapGenerator.applySourceMap(inputMapConsumer);
|
||||||
|
|
||||||
var mergedMap = outputMapGenerator.toJSON();
|
var mergedMap = outputMapGenerator.toJSON();
|
||||||
mergedMap.sources = inputMap.sources
|
mergedMap.sources = inputMap.sources;
|
||||||
mergedMap.file = inputMap.file;
|
mergedMap.file = inputMap.file;
|
||||||
return mergedMap;
|
return mergedMap;
|
||||||
}
|
}
|
||||||
@ -467,7 +467,7 @@ export default class File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_addAst(ast) {
|
_addAst(ast) {
|
||||||
this.path = TraversalPath.get(null, ast, ast, "program", this).setContext(null, this);
|
this.path = NodePath.get(null, ast, ast, "program", this).setContext(null, this);
|
||||||
this.scope = this.path.scope;
|
this.scope = this.path.scope;
|
||||||
this.ast = ast;
|
this.ast = ast;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,4 +44,4 @@ export default function (opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
};
|
}
|
||||||
|
|||||||
@ -42,4 +42,4 @@ export default function (exports, opts) {
|
|||||||
|
|
||||||
return nodes;
|
return nodes;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@ -202,4 +202,4 @@ export default function (exports, opts) {
|
|||||||
addDisplayName(left.name, right);
|
addDisplayName(left.name, right);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@ -68,4 +68,4 @@ export default function (node, nodes, file, scope, allowedSingleIdent) {
|
|||||||
uid: uid,
|
uid: uid,
|
||||||
ref: ref
|
ref: ref
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@ -6,4 +6,4 @@ export default function (node) {
|
|||||||
if (!t.isAssignmentPattern(node.params[i])) lastNonDefault = i + 1;
|
if (!t.isAssignmentPattern(node.params[i])) lastNonDefault = i + 1;
|
||||||
}
|
}
|
||||||
return lastNonDefault;
|
return lastNonDefault;
|
||||||
};
|
}
|
||||||
|
|||||||
@ -55,4 +55,4 @@ export default function (node, callId, scope) {
|
|||||||
|
|
||||||
return call;
|
return call;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@ -130,7 +130,7 @@ export default class ReplaceSupers {
|
|||||||
* Description
|
* Description
|
||||||
*/
|
*/
|
||||||
|
|
||||||
traverseLevel(path: TraversalPath, topLevel: boolean) {
|
traverseLevel(path: NodePath, topLevel: boolean) {
|
||||||
var state = { self: this, topLevel: topLevel };
|
var state = { self: this, topLevel: topLevel };
|
||||||
path.traverse(visitor, state);
|
path.traverse(visitor, state);
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ export default class ReplaceSupers {
|
|||||||
* Description
|
* Description
|
||||||
*/
|
*/
|
||||||
|
|
||||||
looseHandle(path: TraversalPath, getThisReference: Function) {
|
looseHandle(path: NodePath, getThisReference: Function) {
|
||||||
var node = path.node;
|
var node = path.node;
|
||||||
if (path.isSuper()) {
|
if (path.isSuper()) {
|
||||||
return this.getLooseSuperProperty(node, path.parent);
|
return this.getLooseSuperProperty(node, path.parent);
|
||||||
@ -234,7 +234,7 @@ export default class ReplaceSupers {
|
|||||||
* Description
|
* Description
|
||||||
*/
|
*/
|
||||||
|
|
||||||
specHandle(path: TraversalPath, getThisReference: Function) {
|
specHandle(path: NodePath, getThisReference: Function) {
|
||||||
var methodNode = this.methodNode;
|
var methodNode = this.methodNode;
|
||||||
var property;
|
var property;
|
||||||
var computed;
|
var computed;
|
||||||
@ -274,7 +274,7 @@ export default class ReplaceSupers {
|
|||||||
property = node.property;
|
property = node.property;
|
||||||
computed = node.computed;
|
computed = node.computed;
|
||||||
} else if (t.isUpdateExpression(node) && isMemberExpressionSuper(node.argument)) {
|
} else if (t.isUpdateExpression(node) && isMemberExpressionSuper(node.argument)) {
|
||||||
var binary = t.binaryExpression(node.operator[0], node.argument, t.literal(1))
|
var binary = t.binaryExpression(node.operator[0], node.argument, t.literal(1));
|
||||||
if (node.prefix) {
|
if (node.prefix) {
|
||||||
// ++super.foo; -> super.foo += 1;
|
// ++super.foo; -> super.foo += 1;
|
||||||
return this.specHandleAssignmentExpression(null, path, binary, getThisReference);
|
return this.specHandleAssignmentExpression(null, path, binary, getThisReference);
|
||||||
|
|||||||
@ -86,7 +86,7 @@ var metadataVisitor = {
|
|||||||
|
|
||||||
var declar = this.get("declaration");
|
var declar = this.get("declaration");
|
||||||
if (declar.isStatement()) {
|
if (declar.isStatement()) {
|
||||||
var bindings = declar.getBindingIdentifiers()
|
var bindings = declar.getBindingIdentifiers();
|
||||||
for (var name in bindings) {
|
for (var name in bindings) {
|
||||||
var binding = bindings[name];
|
var binding = bindings[name];
|
||||||
formatter._addExport(name, binding);
|
formatter._addExport(name, binding);
|
||||||
|
|||||||
@ -10,4 +10,4 @@ export default function (Parent) {
|
|||||||
util.inherits(Constructor, Parent);
|
util.inherits(Constructor, Parent);
|
||||||
|
|
||||||
return Constructor;
|
return Constructor;
|
||||||
};
|
}
|
||||||
|
|||||||
@ -258,7 +258,7 @@ class BlockScoping {
|
|||||||
* Description
|
* Description
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constructor(loopPath?: TraversalPath, blockPath: TraversalPath, parent: Object, scope: Scope, file: File) {
|
constructor(loopPath?: NodePath, blockPath: NodePath, parent: Object, scope: Scope, file: File) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
|||||||
@ -104,7 +104,7 @@ class ClassTransformer {
|
|||||||
* Description
|
* Description
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constructor(path: TraversalPath, file: File) {
|
constructor(path: NodePath, file: File) {
|
||||||
this.parent = path.parent;
|
this.parent = path.parent;
|
||||||
this.scope = path.scope;
|
this.scope = path.scope;
|
||||||
this.node = path.node;
|
this.node = path.node;
|
||||||
@ -262,7 +262,7 @@ class ClassTransformer {
|
|||||||
var map = defineMap.push(mutatorMap, node, kind, this.file);
|
var map = defineMap.push(mutatorMap, node, kind, this.file);
|
||||||
|
|
||||||
if (enumerable) {
|
if (enumerable) {
|
||||||
map.enumerable = t.literal(true)
|
map.enumerable = t.literal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.decorators) {
|
if (map.decorators) {
|
||||||
@ -375,7 +375,7 @@ class ClassTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var lastNonNullIndex = 0;
|
var lastNonNullIndex = 0;
|
||||||
for (var i = 0; i < args.length; i++) {
|
for (let i = 0; i < args.length; i++) {
|
||||||
if (args[i] !== nullNode) lastNonNullIndex = i;
|
if (args[i] !== nullNode) lastNonNullIndex = i;
|
||||||
}
|
}
|
||||||
args = args.slice(0, lastNonNullIndex + 1);
|
args = args.slice(0, lastNonNullIndex + 1);
|
||||||
@ -450,7 +450,7 @@ class ClassTransformer {
|
|||||||
* Description
|
* Description
|
||||||
*/
|
*/
|
||||||
|
|
||||||
verifyConstructor(path: TraversalPath) {
|
verifyConstructor(path: NodePath) {
|
||||||
var state = {
|
var state = {
|
||||||
hasBareSuper: false,
|
hasBareSuper: false,
|
||||||
bareSuper: null,
|
bareSuper: null,
|
||||||
@ -471,7 +471,7 @@ class ClassTransformer {
|
|||||||
* Push a method to its respective mutatorMap.
|
* Push a method to its respective mutatorMap.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pushMethod(node: { type: "MethodDefinition" }, path?: TraversalPath, allowedIllegal?) {
|
pushMethod(node: { type: "MethodDefinition" }, path?: NodePath, allowedIllegal?) {
|
||||||
if (!allowedIllegal && t.isLiteral(t.toComputedKey(node), { value: PROPERTY_COLLISION_METHOD_NAME })) {
|
if (!allowedIllegal && t.isLiteral(t.toComputedKey(node), { value: PROPERTY_COLLISION_METHOD_NAME })) {
|
||||||
throw this.file.errorWithNode(node, messages.get("illegalMethodName", PROPERTY_COLLISION_METHOD_NAME));
|
throw this.file.errorWithNode(node, messages.get("illegalMethodName", PROPERTY_COLLISION_METHOD_NAME));
|
||||||
}
|
}
|
||||||
@ -519,7 +519,6 @@ class ClassTransformer {
|
|||||||
this.pushToMap(node, true, "initializer");
|
this.pushToMap(node, true, "initializer");
|
||||||
|
|
||||||
var initializers;
|
var initializers;
|
||||||
var body;
|
|
||||||
var target;
|
var target;
|
||||||
if (node.static) {
|
if (node.static) {
|
||||||
initializers = this.staticInitializersId = this.staticInitializersId || this.scope.generateUidIdentifier("staticInitializers");
|
initializers = this.staticInitializersId = this.staticInitializersId || this.scope.generateUidIdentifier("staticInitializers");
|
||||||
@ -558,7 +557,7 @@ class ClassTransformer {
|
|||||||
* Replace the constructor body of our class.
|
* Replace the constructor body of our class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pushConstructor(method: { type: "MethodDefinition" }, path: TraversalPath) {
|
pushConstructor(method: { type: "MethodDefinition" }, path: NodePath) {
|
||||||
// https://github.com/babel/babel/issues/1077
|
// https://github.com/babel/babel/issues/1077
|
||||||
var fnPath = path.get("value");
|
var fnPath = path.get("value");
|
||||||
if (fnPath.scope.hasOwnBinding(this.classRef.name)) {
|
if (fnPath.scope.hasOwnBinding(this.classRef.name)) {
|
||||||
|
|||||||
@ -204,7 +204,7 @@ class TailCallTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.needsArguments || this.setsArguments) {
|
if (this.needsArguments || this.setsArguments) {
|
||||||
for (var path of (this.argumentsPaths: Array)) {
|
for (let path of (this.argumentsPaths: Array)) {
|
||||||
path.replaceWith(this.argumentsId);
|
path.replaceWith(this.argumentsId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,14 +356,14 @@ class TailCallTransformer {
|
|||||||
var elems = args.elements;
|
var elems = args.elements;
|
||||||
for (let i = 0; i < elems.length && i < params.length; i++) {
|
for (let i = 0; i < elems.length && i < params.length; i++) {
|
||||||
let param = params[i];
|
let param = params[i];
|
||||||
var elem = elems[i] || (elems[i] = t.identifier("undefined"));
|
let elem = elems[i] || (elems[i] = t.identifier("undefined"));
|
||||||
if (!param._isDefaultPlaceholder) {
|
if (!param._isDefaultPlaceholder) {
|
||||||
elems[i] = t.assignmentExpression("=", param, elem);
|
elems[i] = t.assignmentExpression("=", param, elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.needsArguments) {
|
if (!this.needsArguments) {
|
||||||
for (var elem of (elems: Array)) {
|
for (let elem of (elems: Array)) {
|
||||||
body.push(t.expressionStatement(elem));
|
body.push(t.expressionStatement(elem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,8 +10,8 @@ export var metadata = {
|
|||||||
|
|
||||||
export function ObjectExpression(node, parent, scope, file) {
|
export function ObjectExpression(node, parent, scope, file) {
|
||||||
var hasDecorators = false;
|
var hasDecorators = false;
|
||||||
for (var i = 0; i < node.properties.length; i++) {
|
for (let i = 0; i < node.properties.length; i++) {
|
||||||
var prop = node.properties[i];
|
let prop = node.properties[i];
|
||||||
if (prop.decorators) {
|
if (prop.decorators) {
|
||||||
hasDecorators = true;
|
hasDecorators = true;
|
||||||
break;
|
break;
|
||||||
@ -21,8 +21,8 @@ export function ObjectExpression(node, parent, scope, file) {
|
|||||||
|
|
||||||
var mutatorMap = {};
|
var mutatorMap = {};
|
||||||
|
|
||||||
for (var i = 0; i < node.properties.length; i++) {
|
for (let i = 0; i < node.properties.length; i++) {
|
||||||
var prop = node.properties[i];
|
let prop = node.properties[i];
|
||||||
if (prop.decorators) memoiseDecorators(prop.decorators, scope);
|
if (prop.decorators) memoiseDecorators(prop.decorators, scope);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export function ExportDefaultDeclaration(node, parent, scope) {
|
|||||||
|
|
||||||
if (t.isClassDeclaration(declar)) {
|
if (t.isClassDeclaration(declar)) {
|
||||||
// export default class Foo {};
|
// export default class Foo {};
|
||||||
var nodes = [getDeclar(node), node];
|
let nodes = [getDeclar(node), node];
|
||||||
node.declaration = declar.id;
|
node.declaration = declar.id;
|
||||||
return nodes;
|
return nodes;
|
||||||
} else if (t.isClassExpression(declar)) {
|
} else if (t.isClassExpression(declar)) {
|
||||||
@ -34,14 +34,14 @@ export function ExportDefaultDeclaration(node, parent, scope) {
|
|||||||
t.variableDeclarator(temp, declar)
|
t.variableDeclarator(temp, declar)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var nodes = [getDeclar(node), node];
|
let nodes = [getDeclar(node), node];
|
||||||
node.declaration = temp;
|
node.declaration = temp;
|
||||||
return nodes;
|
return nodes;
|
||||||
} else if (t.isFunctionDeclaration(declar)) {
|
} else if (t.isFunctionDeclaration(declar)) {
|
||||||
// export default function Foo() {}
|
// export default function Foo() {}
|
||||||
node._blockHoist = 2;
|
node._blockHoist = 2;
|
||||||
|
|
||||||
var nodes = [getDeclar(node), node];
|
let nodes = [getDeclar(node), node];
|
||||||
node.declaration = declar.id;
|
node.declaration = declar.id;
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
@ -57,7 +57,8 @@ export function ExportNamedDeclaration(node, parent, scope) {
|
|||||||
if (t.isClassDeclaration(declar)) {
|
if (t.isClassDeclaration(declar)) {
|
||||||
// export class Foo {}
|
// export class Foo {}
|
||||||
node.specifiers = [buildExportSpecifier(declar.id)];
|
node.specifiers = [buildExportSpecifier(declar.id)];
|
||||||
var nodes = [getDeclar(node), node];
|
|
||||||
|
let nodes = [getDeclar(node), node];
|
||||||
node.declaration = null;
|
node.declaration = null;
|
||||||
return nodes;
|
return nodes;
|
||||||
} else if (t.isFunctionDeclaration(declar)) {
|
} else if (t.isFunctionDeclaration(declar)) {
|
||||||
@ -65,7 +66,7 @@ export function ExportNamedDeclaration(node, parent, scope) {
|
|||||||
node.specifiers = [buildExportSpecifier(declar.id)];
|
node.specifiers = [buildExportSpecifier(declar.id)];
|
||||||
node._blockHoist = 2;
|
node._blockHoist = 2;
|
||||||
|
|
||||||
var nodes = [getDeclar(node), node];
|
let nodes = [getDeclar(node), node];
|
||||||
node.declaration = null;
|
node.declaration = null;
|
||||||
return nodes;
|
return nodes;
|
||||||
} else if (t.isVariableDeclaration(declar)) {
|
} else if (t.isVariableDeclaration(declar)) {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export var Program = {
|
|||||||
}
|
}
|
||||||
directive._blockHoist = Infinity;
|
directive._blockHoist = Infinity;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
export function ThisExpression() {
|
export function ThisExpression() {
|
||||||
if (!this.findParent((node) => !node.shadow && THIS_BREAK_KEYS.indexOf(node.type) >= 0)) {
|
if (!this.findParent((node) => !node.shadow && THIS_BREAK_KEYS.indexOf(node.type) >= 0)) {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ function statementList(key, path, file) {
|
|||||||
var paths = path.get(key);
|
var paths = path.get(key);
|
||||||
|
|
||||||
for (var i = 0; i < paths.length; i++) {
|
for (var i = 0; i < paths.length; i++) {
|
||||||
var path = paths[i];
|
let path = paths[i];
|
||||||
|
|
||||||
var func = path.node;
|
var func = path.node;
|
||||||
if (!t.isFunctionDeclaration(func)) continue;
|
if (!t.isFunctionDeclaration(func)) continue;
|
||||||
|
|||||||
@ -52,11 +52,11 @@ const CLEAR_KEYS = [
|
|||||||
|
|
||||||
function clearNode(node) {
|
function clearNode(node) {
|
||||||
for (var i = 0; i < CLEAR_KEYS.length; i++) {
|
for (var i = 0; i < CLEAR_KEYS.length; i++) {
|
||||||
var key = CLEAR_KEYS[i];
|
let key = CLEAR_KEYS[i];
|
||||||
if (node[key] != null) node[key] = null;
|
if (node[key] != null) node[key] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var key in node) {
|
for (let key in node) {
|
||||||
var val = node[key];
|
var val = node[key];
|
||||||
if (Array.isArray(val)) {
|
if (Array.isArray(val)) {
|
||||||
delete val._paths;
|
delete val._paths;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import * as virtualTypes from "./path/virtual-types";
|
import * as virtualTypes from "./path/lib/virtual-types";
|
||||||
import * as messages from "../messages";
|
import * as messages from "../messages";
|
||||||
import * as t from "../types";
|
import * as t from "../types";
|
||||||
import clone from "lodash/lang/clone";
|
import clone from "lodash/lang/clone";
|
||||||
@ -29,7 +29,7 @@ export function explode(visitor) {
|
|||||||
if (!wrapper) continue;
|
if (!wrapper) continue;
|
||||||
|
|
||||||
// wrap all the functions
|
// wrap all the functions
|
||||||
var fns = visitor[nodeType];
|
let fns = visitor[nodeType];
|
||||||
for (let type in fns) {
|
for (let type in fns) {
|
||||||
fns[type] = wrapCheck(wrapper, fns[type]);
|
fns[type] = wrapCheck(wrapper, fns[type]);
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ export function explode(visitor) {
|
|||||||
for (let nodeType in visitor) {
|
for (let nodeType in visitor) {
|
||||||
if (shouldIgnoreKey(nodeType)) continue;
|
if (shouldIgnoreKey(nodeType)) continue;
|
||||||
|
|
||||||
var fns = visitor[nodeType];
|
let fns = visitor[nodeType];
|
||||||
|
|
||||||
var aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
|
var aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
|
||||||
if (!aliases) continue;
|
if (!aliases) continue;
|
||||||
|
|||||||
@ -72,6 +72,7 @@ export function isReferenced(node: Object, parent: Object): boolean {
|
|||||||
|
|
||||||
// no: import { NODE as foo } from "foo";
|
// no: import { NODE as foo } from "foo";
|
||||||
// no: import { foo as NODE } from "foo";
|
// no: import { foo as NODE } from "foo";
|
||||||
|
// no: import NODE from "bar";
|
||||||
case "ImportSpecifier":
|
case "ImportSpecifier":
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -106,14 +107,6 @@ export function isReferenced(node: Object, parent: Object): boolean {
|
|||||||
case "ObjectPattern":
|
case "ObjectPattern":
|
||||||
case "ArrayPattern":
|
case "ArrayPattern":
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// no: import NODE from "bar";
|
|
||||||
case "ImportSpecifier":
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// no: import * as NODE from "foo";
|
|
||||||
case "ImportNamespaceSpecifier":
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -112,12 +112,12 @@ export function shouldIgnore(filename, ignore, only) {
|
|||||||
filename = slash(filename);
|
filename = slash(filename);
|
||||||
|
|
||||||
if (only.length) {
|
if (only.length) {
|
||||||
for (var pattern of (only: Array)) {
|
for (let pattern of (only: Array)) {
|
||||||
if (pattern.test(filename)) return false;
|
if (pattern.test(filename)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (ignore.length) {
|
} else if (ignore.length) {
|
||||||
for (var pattern of (ignore: Array)) {
|
for (let pattern of (ignore: Array)) {
|
||||||
if (pattern.test(filename)) return true;
|
if (pattern.test(filename)) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user