* normalize npmignores

* fixup eslint ignore, etc

* lint

* remove unused

* rm from gitignore

* use strict
This commit is contained in:
Henry Zhu
2017-03-25 21:46:16 -04:00
committed by GitHub
parent cff1c8db39
commit 7a1ccf076c
122 changed files with 249 additions and 309 deletions

View File

@@ -1,9 +1,11 @@
var fs = require("fs");
var t = require("../packages/babel-types");
"use strict";
var NODE_PREFIX = "BabelNode";
const fs = require("fs");
const t = require("../packages/babel-types");
var code = `// NOTE: This file is autogenerated. Do not modify.
const NODE_PREFIX = "BabelNode";
let code = `// NOTE: This file is autogenerated. Do not modify.
// See scripts/generate-interfaces.js for script used.
declare class ${NODE_PREFIX}Comment {
@@ -44,23 +46,23 @@ declare class ${NODE_PREFIX} {
//
var lines = [];
const lines = [];
for (var type in t.NODE_FIELDS) {
var fields = t.NODE_FIELDS[type];
for (const type in t.NODE_FIELDS) {
const fields = t.NODE_FIELDS[type];
var struct = ['type: "' + type + '";'];
var args = [];
const struct = ["type: \"" + type + "\";"];
const args = [];
for (var fieldName in fields) {
var field = fields[fieldName];
for (const fieldName in fields) {
const field = fields[fieldName];
var suffix = "";
let suffix = "";
if (field.optional || field.default != null) suffix += "?";
var typeAnnotation = "any";
let typeAnnotation = "any";
var validate = field.validate;
const validate = field.validate;
if (validate) {
if (validate.oneOf) {
typeAnnotation = validate.oneOf.map(function (val) {
@@ -77,7 +79,7 @@ for (var type in t.NODE_FIELDS) {
}
if (validate.oneOfNodeTypes) {
var types = validate.oneOfNodeTypes.map(type => `${NODE_PREFIX}${type}`);
const types = validate.oneOfNodeTypes.map((type) => `${NODE_PREFIX}${type}`);
typeAnnotation = types.join(" | ");
if (suffix === "?") typeAnnotation = "?" + typeAnnotation;
}
@@ -97,18 +99,20 @@ for (var type in t.NODE_FIELDS) {
}\n\n`;
// Flow chokes on super() :/
if (type !== 'Super') {
lines.push(`declare function ${type[0].toLowerCase() + type.slice(1)}(${args.join(", ")}): ${NODE_PREFIX}${type};`);
if (type !== "Super") {
lines.push(
`declare function ${type[0].toLowerCase() + type.slice(1)}(${args.join(", ")}): ${NODE_PREFIX}${type};`
);
}
}
for (var i = 0; i < t.TYPES.length; i++) {
for (let i = 0; i < t.TYPES.length; i++) {
lines.push(`declare function is${t.TYPES[i]}(node: Object, opts?: Object): boolean;`);
}
for (var type in t.FLIPPED_ALIAS_KEYS) {
var types = t.FLIPPED_ALIAS_KEYS[type];
code += `type ${NODE_PREFIX}${type} = ${types.map(type => `${NODE_PREFIX}${type}`).join(" | ")};\n`;
for (const type in t.FLIPPED_ALIAS_KEYS) {
const types = t.FLIPPED_ALIAS_KEYS[type];
code += `type ${NODE_PREFIX}${type} = ${types.map((type) => `${NODE_PREFIX}${type}`).join(" | ")};\n`;
}
code += `\ndeclare module "babel-types" {