enable prefer const (#5113)

This commit is contained in:
Henry Zhu
2017-01-14 09:48:52 -05:00
committed by GitHub
parent 982850731e
commit 672adba9a1
177 changed files with 1862 additions and 1863 deletions

View File

@@ -16,14 +16,14 @@ export default function ({ types: t }) {
visitor: {
TypeCastExpression(path) {
let { node } = path;
const { node } = path;
path.get("expression").addComment("trailing", generateComment(path.get("typeAnnotation")));
path.replaceWith(t.parenthesizedExpression(node.expression));
},
// support function a(b?) {}
Identifier(path) {
let { node } = path;
const { node } = path;
if (!node.optional || node.typeAnnotation) {
return;
}
@@ -45,13 +45,13 @@ export default function ({ types: t }) {
// support for `class X { foo: string }` - #4622
ClassProperty(path) {
let { node, parent } = path;
const { node, parent } = path;
if (!node.value) wrapInFlowComment(path, parent);
},
// support `export type a = {}` - #8 Error: You passed path.replaceWith() a falsy node
"ExportNamedDeclaration|Flow"(path) {
let { node, parent } = path;
const { node, parent } = path;
if (t.isExportNamedDeclaration(node) && !t.isFlow(node.declaration)) {
return;
}
@@ -60,7 +60,7 @@ export default function ({ types: t }) {
// support `import type A` and `import typeof A` #10
ImportDeclaration(path) {
let { node, parent } = path;
const { node, parent } = path;
if (t.isImportDeclaration(node) && node.importKind !== "type" && node.importKind !== "typeof") {
return;
}