@fimbul/mimir
Advanced tools
Comparing version 0.7.0-dev.20180405 to 0.7.0
{ | ||
"name": "@fimbul/mimir", | ||
"version": "0.7.0-dev.20180405", | ||
"version": "0.7.0", | ||
"description": "Core rules of the Fimbullinter project", | ||
@@ -28,3 +28,3 @@ "main": "recommended.yaml", | ||
"dependencies": { | ||
"@fimbul/ymir": "0.6.0", | ||
"@fimbul/ymir": "^0.6.0", | ||
"chalk": "^2.3.2", | ||
@@ -31,0 +31,0 @@ "debug": "^3.1.0", |
@@ -8,2 +8,3 @@ "use strict"; | ||
const typescriptPre270 = /^2\.[456]\./.test(ts.version); | ||
const typescriptPre290 = typescriptPre270 || /^2\.[78]\./.test(ts.version); | ||
let Rule = class Rule extends ymir_1.TypedRule { | ||
@@ -24,3 +25,4 @@ constructor() { | ||
} | ||
else if ((node.kind === ts.SyntaxKind.JsxOpeningElement || node.kind === ts.SyntaxKind.JsxSelfClosingElement) && | ||
else if (!typescriptPre290 && | ||
(node.kind === ts.SyntaxKind.JsxOpeningElement || node.kind === ts.SyntaxKind.JsxSelfClosingElement) && | ||
node.typeArguments === undefined) { | ||
@@ -27,0 +29,0 @@ this.checkCallExpression(node); |
@@ -14,4 +14,6 @@ "use strict"; | ||
const { node } = tsutils_1.getWrappedNodeAtPosition(wrappedAst || (wrappedAst = this.context.getWrappedAst()), match.index); | ||
if ((tsutils_1.isSpreadElement(node) && node.expression.kind === ts.SyntaxKind.ArrayLiteralExpression || | ||
tsutils_1.isSpreadAssignment(node) && node.expression.kind === ts.SyntaxKind.ObjectLiteralExpression) && | ||
if (((tsutils_1.isSpreadElement(node) && | ||
tsutils_1.isArrayLiteralExpression(node.expression) && | ||
(!node.expression.elements.some(tsutils_1.isOmittedExpression) || tsutils_1.isReassignmentTarget(node))) || | ||
(tsutils_1.isSpreadAssignment(node) && tsutils_1.isObjectLiteralExpression(node.expression))) && | ||
node.expression.pos - 3 === match.index) | ||
@@ -27,7 +29,21 @@ this.addFailureAtNode(node, FAILURE_STRING, removeUselessSpread(node)); | ||
function removeUselessSpread(node) { | ||
return [ | ||
const list = tsutils_1.isArrayLiteralExpression(node.expression) | ||
? node.expression.elements | ||
: node.expression.properties; | ||
if (tsutils_1.isSpreadElement(node) && tsutils_1.isArrayLiteralExpression(node.expression) && list.length === 0) | ||
return removeUselessSpreadOfEmptyArray(node); | ||
const replacements = [ | ||
ymir_1.Replacement.delete(node.getStart(), node.expression.getStart() + 1), | ||
ymir_1.Replacement.delete(node.expression.end - 1, node.expression.end), | ||
]; | ||
if (list.hasTrailingComma) | ||
replacements.push(ymir_1.Replacement.delete(list.end - 1, list.end)); | ||
return replacements; | ||
} | ||
function removeUselessSpreadOfEmptyArray(node) { | ||
const parent = node.parent; | ||
const list = parent.kind === ts.SyntaxKind.ArrayLiteralExpression ? parent.elements : parent.arguments; | ||
const index = list.findIndex((listItem) => listItem === node); | ||
return ymir_1.Replacement.delete(node.pos, index === list.length - 1 ? list.end : list[index + 1].pos); | ||
} | ||
//# sourceMappingURL=no-useless-spread.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237181
2790
Updated@fimbul/ymir@^0.6.0