enable no-unused-vars in eslint

This commit is contained in:
Sebastian McKenzie
2015-05-25 01:32:06 +01:00
parent 0bf95d6aea
commit 49953e3464
43 changed files with 27 additions and 124 deletions

View File

@@ -1,5 +1,4 @@
import path from "path";
import os from "os";
import fs from "fs";
import homeOrTmp from "home-or-tmp";

View File

@@ -6,7 +6,6 @@ import * as babel from "../node";
import each from "lodash/collection/each";
import * as util from "../../util";
import fs from "fs";
import slash from "slash";
sourceMapSupport.install({
handleUncaughtExceptions: false,

View File

@@ -1,4 +1,3 @@
import each from "lodash/collection/each";
import * as t from "../../types";
export function JSXAttribute(node, print) {

View File

@@ -1,4 +1,3 @@
import each from "lodash/collection/each";
import * as t from "../../types";
export function ImportSpecifier(node, print) {

View File

@@ -1,5 +1,3 @@
import each from "lodash/collection/each";
export function TaggedTemplateExpression(node, print) {
print(node.tag);
print(node.quasi);

View File

@@ -1,6 +1,5 @@
/* eslint quotes: 0 */
import each from "lodash/collection/each";
import * as t from "../../types";
export function Identifier(node) {

View File

@@ -9,7 +9,6 @@ import isFunction from "lodash/lang/isFunction";
import isAbsolute from "path-is-absolute";
import resolveRc from "../../tools/resolve-rc";
import sourceMap from "source-map";
import transform from "./../index";
import generate from "../../generation";
import codeFrame from "../../helpers/code-frame";
import defaults from "lodash/object/defaults";
@@ -18,12 +17,10 @@ import traverse from "../../traversal";
import assign from "lodash/object/assign";
import Logger from "./logger";
import parse from "../../helpers/parse";
import Scope from "../../traversal/scope";
import merge from "../../helpers/merge";
import slash from "slash";
import clone from "lodash/lang/clone";
import * as util from "../../util";
import * as api from "../../api/node";
import path from "path";
import * as t from "../../types";
@@ -348,8 +345,6 @@ export default class File {
throw new ReferenceError(`Unknown helper ${name}`);
}
var program = this.ast.program;
var declar = this.declarations[name];
if (declar) return declar;
@@ -491,7 +486,7 @@ export default class File {
this.metadata.modules = modules;
}
transform(dependencyGraph) {
transform() {
this.call("pre");
for (var pass of (this.transformerStack: Array)) {
pass.transform();
@@ -534,7 +529,7 @@ export default class File {
}
}
addCode(code: string, parseCode?) {
addCode(code: string) {
code = (code || "") + "";
code = this.parseInputSourceMap(code);
this.code = code;

View File

@@ -10,7 +10,7 @@ import * as react from "./react";
import * as t from "../../types";
export default function (exports, opts) {
exports.JSXIdentifier = function (node, parent) {
exports.JSXIdentifier = function (node) {
if (node.name === "this" && this.isReferenced()) {
return t.thisExpression();
} else if (esutils.keyword.isIdentifierNameES6(node.name)) {
@@ -20,7 +20,7 @@ export default function (exports, opts) {
}
};
exports.JSXNamespacedName = function (node, parent, scope, file) {
exports.JSXNamespacedName = function () {
throw this.errorWithNode(messages.get("JSXNamespacedTags"));
};

View File

@@ -1,4 +1,3 @@
import traverse from "../../traversal";
import * as t from "../../types";
var visitor = {

View File

@@ -1,5 +1,3 @@
import cloneDeep from "lodash/lang/cloneDeep";
import traverse from "../../traversal";
import each from "lodash/collection/each";
import has from "lodash/object/has";
import * as t from "../../types";

View File

@@ -1,4 +1,3 @@
import isString from "lodash/lang/isString";
import * as t from "../../types";
var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
@@ -26,10 +25,6 @@ export function isCompatTag(tagName) {
return tagName && /^[a-z]|\-/.test(tagName);
}
function isStringLiteral(node) {
return t.isLiteral(node) && isString(node.value);
}
function cleanJSXElementLiteralChild(child, args) {
var lines = child.value.split(/\r\n|\n|\r/);

View File

@@ -1,7 +1,7 @@
import * as t from "../../types";
var awaitVisitor = {
enter(node, parent, scope, state) {
enter(node) {
if (t.isFunction(node)) this.skip();
if (t.isAwaitExpression(node)) {

View File

@@ -1,12 +1,11 @@
import * as messages from "../../messages";
import traverse from "../../traversal";
import extend from "lodash/object/extend";
import object from "../../helpers/object";
import * as util from "../../util";
import * as t from "../../types";
var remapVisitor = {
enter(node, parent, scope, formatter) {
enter(node) {
if (node._skipModulesRemap) {
return this.skip();
}

View File

@@ -1,5 +1,4 @@
import DefaultFormatter from "./_default";
import includes from "lodash/collection/includes";
import * as util from "../../util";
import * as t from "../../types";
@@ -84,7 +83,7 @@ export default class CommonJSFormatter extends DefaultFormatter {
}, true));
}
exportSpecifier(specifier, node, nodes) {
exportSpecifier(specifier) {
if (this.doDefaultExportInterop(specifier)) {
this.hasDefaultOnlyExport = true;
}
@@ -92,7 +91,7 @@ export default class CommonJSFormatter extends DefaultFormatter {
DefaultFormatter.prototype.exportSpecifier.apply(this, arguments);
}
exportDeclaration(node, nodes) {
exportDeclaration(node) {
if (this.doDefaultExportInterop(node)) {
this.hasDefaultOnlyExport = true;
}
@@ -101,8 +100,6 @@ export default class CommonJSFormatter extends DefaultFormatter {
}
_getExternalReference(node, nodes) {
var source = node.source.value;
var call = t.callExpression(t.identifier("require"), [node.source]);
var uid;

View File

@@ -3,7 +3,6 @@ import AMDFormatter from "./amd";
import object from "../../helpers/object";
import * as util from "../../util";
import last from "lodash/array/last";
import each from "lodash/collection/each";
import map from "lodash/collection/map";
import * as t from "../../types";

View File

@@ -1,4 +1,3 @@
import includes from "lodash/collection/includes";
import traverse from "../traversal";
/**

View File

@@ -4,7 +4,6 @@ import isFunction from "lodash/lang/isFunction";
import traverse from "../traversal";
import isObject from "lodash/lang/isObject";
import assign from "lodash/object/assign";
import * as acorn from "../../acorn";
import File from "./file";
import each from "lodash/collection/each";

View File

@@ -597,7 +597,6 @@ class BlockScoping {
t.variableDeclarator(ret, call)
]));
var loop = this.loop;
var retCheck;
var has = this.has;
var cases = [];

View File

@@ -4,9 +4,6 @@ import * as nameMethod from "../../helpers/name-method";
import * as defineMap from "../../helpers/define-map";
import * as messages from "../../../messages";
import * as util from "../../../util";
import traverse from "../../../traversal";
import each from "lodash/collection/each";
import has from "lodash/object/has";
import * as t from "../../../types";
const PROPERTY_COLLISION_METHOD_NAME = "__initializeProperties";
@@ -35,22 +32,6 @@ var collectPropertyReferencesVisitor = {
}
};
var constructorVisitor = {
ThisExpression: {
enter(node, parent, scope, ref) {
return ref;
}
},
Function: {
enter(node) {
if (!node.shadow) {
this.skip();
}
}
}
};
var verifyConstructorVisitor = {
MethodDefinition: {
enter() {
@@ -141,8 +122,6 @@ class ClassTransformer {
run() {
var superName = this.superName;
var className = this.className;
var classBody = this.node.body.body;
var classRef = this.classRef;
var file = this.file;
@@ -276,9 +255,6 @@ class ClassTransformer {
buildBody() {
var constructorBody = this.constructorBody;
var constructor = this.constructor;
var className = this.className;
var superName = this.superName;
var classBody = this.node.body.body;
var body = this.body;
@@ -501,8 +477,6 @@ class ClassTransformer {
*/
pushProperty(node: { type: "ClassProperty" }) {
var key;
this.scope.traverse(node, collectPropertyReferencesVisitor, {
references: this.instancePropRefs,
scope: this.scope

View File

@@ -1,5 +1,4 @@
import * as messages from "../../../messages";
import * as t from "../../../types";
export function AssignmentExpression(node, parent, scope, file) {
var ids = this.getBindingIdentifiers();

View File

@@ -498,7 +498,6 @@ class DestructuringTransformer {
// trying to destructure a value that we can't evaluate more than once so we
// need to save it to a variable
var shouldMemoise = true;
if (!t.isArrayExpression(ref) && !t.isMemberExpression(ref)) {
var memo = this.scope.maybeGenerateMemoised(ref, true);
if (memo) {

View File

@@ -1,6 +1,5 @@
import callDelegate from "../../helpers/call-delegate";
import * as util from "../../../util";
import traverse from "../../../traversal";
import * as t from "../../../types";
var hasDefaults = function (node) {

View File

@@ -1,4 +1,3 @@
import traverse from "../../../traversal";
import * as t from "../../../types";
var visitor = {

View File

@@ -1,4 +1,3 @@
import includes from "lodash/collection/includes";
import * as t from "../../../types";
function getSpreadLiteral(spread, scope) {

View File

@@ -1,7 +1,6 @@
import reduceRight from "lodash/collection/reduceRight";
import * as messages from "../../../messages";
import flatten from "lodash/array/flatten";
import traverse from "../../../traversal";
import * as util from "../../../util";
import map from "lodash/collection/map";
import * as t from "../../../types";
@@ -21,7 +20,7 @@ function returnBlock(expr) {
}
var visitor = {
enter(node, parent, scope, state) {
enter(node, parent) {
if (t.isTryStatement(parent)) {
if (node === parent.block) {
this.skip();
@@ -35,7 +34,7 @@ var visitor = {
return state.subTransform(node.argument);
},
Function(node, parent, scope, state) {
Function() {
this.skip();
},
@@ -128,7 +127,6 @@ class TailCallTransformer {
}
run() {
var scope = this.scope;
var node = this.node;
// only tail recursion can be optimized as for now, so we can skip anonymous

View File

@@ -10,7 +10,7 @@ export var metadata = {
export function ComprehensionExpression(node, parent, scope, file) {
var callback = array;
if (node.generator) callback = generator;
return callback(node, parent, scope, file);
return callback(node, parent, scope);
}
function generator(node) {
@@ -25,7 +25,7 @@ function generator(node) {
return t.callExpression(container, []);
}
function array(node, parent, scope, file) {
function array(node, parent, scope) {
var uid = scope.generateUidIdentifierBasedOnNode(parent);
var container = util.template("array-comprehension-container", {

View File

@@ -33,7 +33,7 @@ export function ReferencedIdentifier(node, parent, scope) {
}
if (!replacement) return;
if (this.findParent((node) => replacement)) {
if (this.findParent((node) => node === replacement)) {
return;
}
@@ -67,7 +67,7 @@ export function ConditionalExpression(node, parent, scope) {
}
export var IfStatement = {
exit(node, parent, scope) {
exit(node) {
var consequent = node.consequent;
var alternate = node.alternate;
var test = node.test;

View File

@@ -6,7 +6,7 @@ export var metadata = {
};
export var Expression = {
exit(node, parent, scope) {
exit() {
var res = this.evaluate();
if (res.confident) return t.valueToNode(res.value);
}

View File

@@ -1,5 +1,3 @@
import * as t from "../../../types";
export var metadata = {
optional: true,
group: "builtin-setup"

View File

@@ -1,5 +1,4 @@
import { _ForOfStatementArray } from "../es6/for-of";
import * as t from "../../../types";
export var metadata = {
optional: true

View File

@@ -1,5 +1,3 @@
import * as react from "../../helpers/react";
export var metadata = {
optional: true
};

View File

@@ -1,5 +1,3 @@
import * as t from "../../../types";
export function Flow(node) {
this.remove();
}

View File

@@ -1,12 +1,7 @@
import includes from "lodash/collection/includes";
import traverse from "../../../../traversal";
import * as util from "../../../../util";
import has from "lodash/object/has";
import * as t from "../../../../types";
import definitions from "./definitions";
var isSymbolIterator = t.buildMatchMemberExpression("Symbol.iterator");
const RUNTIME_MODULE_NAME = "babel-runtime";
export var metadata = {

View File

@@ -1,4 +1,3 @@
import * as messages from "../../../messages";
import * as t from "../../../types";
export var metadata = {
@@ -8,7 +7,7 @@ export var metadata = {
const THIS_BREAK_KEYS = ["FunctionExpression", "FunctionDeclaration", "ClassExpression", "ClassDeclaration"];
export var Program = {
enter(program, parent, scope, file) {
enter(program) {
var first = program.body[0];
var directive;

View File

@@ -1,6 +1,6 @@
import * as t from "../../../types";
function statementList(key, path, file) {
function statementList(key, path) {
var paths = path.get(key);
for (var i = 0; i < paths.length; i++) {
@@ -23,14 +23,14 @@ function statementList(key, path, file) {
}
}
export function BlockStatement(node, parent, scope, file) {
export function BlockStatement(node, parent) {
if ((t.isFunction(parent) && parent.body === node) || t.isExportDeclaration(parent)) {
return;
}
statementList("body", this, file);
statementList("body", this);
}
export function SwitchCase(node, parent, scope, file) {
statementList("consequent", this, file);
export function SwitchCase() {
statementList("consequent", this);
}

View File

@@ -1,5 +1,4 @@
import NodePath from "./path";
import compact from "lodash/array/compact";
import * as t from "../types";
export default class TraversalContext {
@@ -21,7 +20,7 @@ export default class TraversalContext {
return path;
}
visitMultiple(nodes, node, key) {
visitMultiple(nodes, node) {
// nothing to traverse!
if (nodes.length === 0) return false;

View File

@@ -69,12 +69,6 @@ var clearVisitor = {
exit: clearNode
};
function clearComments(comments) {
for (var i = 0; i < comments.length; i++) {
clearNode(comments[i]);
}
}
traverse.removeProperties = function (tree) {
traverse(tree, clearVisitor);
clearNode(tree);

View File

@@ -1,17 +1,6 @@
import PathHoister from "./lib/hoister";
import * as virtualTypes from "./lib/virtual-types";
import * as messages from "../../messages";
import isBoolean from "lodash/lang/isBoolean";
import isNumber from "lodash/lang/isNumber";
import isRegExp from "lodash/lang/isRegExp";
import isString from "lodash/lang/isString";
import codeFrame from "../../helpers/code-frame";
import parse from "../../helpers/parse";
import { explode } from "../visitors";
import traverse from "../index";
import includes from "lodash/collection/includes";
import assign from "lodash/object/assign";
import extend from "lodash/object/extend";
import Scope from "../scope";
import * as t from "../../types";

View File

@@ -1,5 +1,4 @@
import * as removalHooks from "./lib/removal-hooks";
import * as t from "../../types";
/**
* Description

View File

@@ -86,7 +86,7 @@ export default class Binding {
* Description
*/
isCompatibleWithType(newType): boolean {
isCompatibleWithType(): boolean {
return false;
}
}

View File

@@ -1,5 +1,4 @@
import includes from "lodash/collection/includes";
import { explode } from "../visitors";
import traverse from "../index";
import defaults from "lodash/object/defaults";
import * as messages from "../../messages";
@@ -8,7 +7,6 @@ import globals from "globals";
import flatten from "lodash/array/flatten";
import extend from "lodash/object/extend";
import object from "../../helpers/object";
import each from "lodash/collection/each";
import * as t from "../../types";
var functionVariableVisitor = {
@@ -55,7 +53,7 @@ var programReferenceVisitor = {
},
ExportDeclaration: {
exit(node, parent, scope, state) {
exit(node, parent, scope) {
var declar = node.declaration;
if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
scope.getBinding(declar.id.name).reference();
@@ -74,15 +72,15 @@ var programReferenceVisitor = {
state.addGlobal(node);
},
AssignmentExpression(node, parent, scope, state) {
AssignmentExpression(node, parent, scope) {
scope.registerConstantViolation(this.get("left"), this.get("right"));
},
UpdateExpression(node, parent, scope, state) {
UpdateExpression(node, parent, scope) {
scope.registerConstantViolation(this.get("argument"), null);
},
UnaryExpression(node, parent, scope, state) {
UnaryExpression(node, parent, scope) {
if (node.operator === "delete") scope.registerConstantViolation(this.get("left"), null);
}
};

View File

@@ -3,7 +3,6 @@ import isNumber from "lodash/lang/isNumber";
import isRegExp from "lodash/lang/isRegExp";
import isString from "lodash/lang/isString";
import traverse from "../traversal";
import each from "lodash/collection/each";
import * as t from "./index";
/**