Re-enable the max-len ESLint rule. (#5265)

This commit is contained in:
Logan Smyth
2017-02-04 08:07:15 -08:00
committed by Henry Zhu
parent 4d411ef83e
commit b845f2b69d
63 changed files with 317 additions and 223 deletions

View File

@@ -1,4 +1,3 @@
/* eslint max-len: 0 */
// This file contains methods responsible for replacing a node with another.
import codeFrame from "babel-code-frame";
@@ -114,22 +113,30 @@ export function replaceWith(replacement) {
}
if (Array.isArray(replacement)) {
throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`");
throw new Error(
"Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`");
}
if (typeof replacement === "string") {
throw new Error("Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`");
throw new Error(
"Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`");
}
if (this.isNodeType("Statement") && t.isExpression(replacement)) {
if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) {
if (
!this.canHaveVariableDeclarationOrExpression() &&
!this.canSwapBetweenExpressionAndStatement(replacement)
) {
// replacing a statement with an expression so wrap it in an expression statement
replacement = t.expressionStatement(replacement);
}
}
if (this.isNodeType("Expression") && t.isStatement(replacement)) {
if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) {
if (
!this.canHaveVariableDeclarationOrExpression() &&
!this.canSwapBetweenExpressionAndStatement(replacement)
) {
// replacing an expression with a statement so let's explode it
return this.replaceExpressionWithStatements([replacement]);
}