Update prettier, eslint + plugins, flow, husky and lint-staged (#6183)

This commit is contained in:
Daniel Tschinder
2017-08-31 22:56:29 +02:00
committed by GitHub
parent 6108bee4f9
commit 44f6ff5e85
15 changed files with 519 additions and 452 deletions

View File

@@ -72,77 +72,81 @@ function getType(validator) {
err.validator = validator;
throw err;
}
Object.keys(types.BUILDER_KEYS).sort().forEach(function(key) {
readme.push("### " + key[0].toLowerCase() + key.substr(1));
readme.push("```javascript");
readme.push(
"t." +
key[0].toLowerCase() +
key.substr(1) +
"(" +
types.BUILDER_KEYS[key].join(", ") +
")"
);
readme.push("```");
readme.push("");
readme.push(
"See also `t.is" +
key +
"(node, opts)` and `t.assert" +
key +
"(node, opts)`."
);
readme.push("");
if (types.ALIAS_KEYS[key] && types.ALIAS_KEYS[key].length) {
Object.keys(types.BUILDER_KEYS)
.sort()
.forEach(function(key) {
readme.push("### " + key[0].toLowerCase() + key.substr(1));
readme.push("```javascript");
readme.push(
"Aliases: " +
types.ALIAS_KEYS[key]
.map(function(key) {
return "`" + key + "`";
})
.join(", ")
"t." +
key[0].toLowerCase() +
key.substr(1) +
"(" +
types.BUILDER_KEYS[key].join(", ") +
")"
);
readme.push("```");
readme.push("");
readme.push(
"See also `t.is" +
key +
"(node, opts)` and `t.assert" +
key +
"(node, opts)`."
);
readme.push("");
}
Object.keys(types.NODE_FIELDS[key])
.sort(function(fieldA, fieldB) {
const indexA = types.BUILDER_KEYS[key].indexOf(fieldA);
const indexB = types.BUILDER_KEYS[key].indexOf(fieldB);
if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
if (indexA === -1) return 1;
if (indexB === -1) return -1;
return indexA - indexB;
})
.forEach(function(field) {
const defaultValue = types.NODE_FIELDS[key][field].default;
const fieldDescription = ["`" + field + "`"];
const validator = types.NODE_FIELDS[key][field].validate;
if (customTypes[key] && customTypes[key][field]) {
fieldDescription.push(`: ${customTypes[key][field]}`);
} else if (validator) {
try {
fieldDescription.push(": `" + getType(validator) + "`");
} catch (ex) {
if (ex.code === "UNEXPECTED_VALIDATOR_TYPE") {
console.log("Unrecognised validator type for " + key + "." + field);
console.dir(ex.validator, { depth: 10, colors: true });
if (types.ALIAS_KEYS[key] && types.ALIAS_KEYS[key].length) {
readme.push(
"Aliases: " +
types.ALIAS_KEYS[key]
.map(function(key) {
return "`" + key + "`";
})
.join(", ")
);
readme.push("");
}
Object.keys(types.NODE_FIELDS[key])
.sort(function(fieldA, fieldB) {
const indexA = types.BUILDER_KEYS[key].indexOf(fieldA);
const indexB = types.BUILDER_KEYS[key].indexOf(fieldB);
if (indexA === indexB) return fieldA < fieldB ? -1 : 1;
if (indexA === -1) return 1;
if (indexB === -1) return -1;
return indexA - indexB;
})
.forEach(function(field) {
const defaultValue = types.NODE_FIELDS[key][field].default;
const fieldDescription = ["`" + field + "`"];
const validator = types.NODE_FIELDS[key][field].validate;
if (customTypes[key] && customTypes[key][field]) {
fieldDescription.push(`: ${customTypes[key][field]}`);
} else if (validator) {
try {
fieldDescription.push(": `" + getType(validator) + "`");
} catch (ex) {
if (ex.code === "UNEXPECTED_VALIDATOR_TYPE") {
console.log(
"Unrecognised validator type for " + key + "." + field
);
console.dir(ex.validator, { depth: 10, colors: true });
}
}
}
}
if (defaultValue !== null || types.NODE_FIELDS[key][field].optional) {
fieldDescription.push(
" (default: `" + util.inspect(defaultValue) + "`)"
);
} else {
fieldDescription.push(" (required)");
}
readme.push(" - " + fieldDescription.join(""));
});
if (defaultValue !== null || types.NODE_FIELDS[key][field].optional) {
fieldDescription.push(
" (default: `" + util.inspect(defaultValue) + "`)"
);
} else {
fieldDescription.push(" (required)");
}
readme.push(" - " + fieldDescription.join(""));
});
readme.push("");
readme.push("---");
readme.push("");
});
readme.push("");
readme.push("---");
readme.push("");
});
readme.push(
"",

View File

@@ -137,7 +137,10 @@ for (const type in t.FLIPPED_ALIAS_KEYS) {
}
code += `\ndeclare module "babel-types" {
${lines.join("\n").replace(/\n/g, "\n ").trim()}
${lines
.join("\n")
.replace(/\n/g, "\n ")
.trim()}
}\n`;
//