diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 96f07d7564..133bd67e71 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -167,7 +167,6 @@ rules: template-curly-spacing: error # Custom rules in tools/eslint-rules - align-multiline-assignment: error assert-throws-arguments: [error, { requireTwo: true }] no-unescaped-regexp-dot: error diff --git a/tools/eslint-rules/align-multiline-assignment.js b/tools/eslint-rules/align-multiline-assignment.js deleted file mode 100644 index 8e2f5ed1ee..0000000000 --- a/tools/eslint-rules/align-multiline-assignment.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @fileoverview Align multiline variable assignments - * @author Rich Trott - */ -'use strict'; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ -function getBinaryExpressionStarts(binaryExpression, starts) { - function getStartsFromOneSide(side, starts) { - starts.push(side.loc.start); - if (side.type === 'BinaryExpression') { - starts = getBinaryExpressionStarts(side, starts); - } - return starts; - } - - starts = getStartsFromOneSide(binaryExpression.left, starts); - starts = getStartsFromOneSide(binaryExpression.right, starts); - return starts; -} - -function checkExpressionAlignment(expression) { - if (!expression) - return; - - var msg = ''; - - switch (expression.type) { - case 'BinaryExpression': - var starts = getBinaryExpressionStarts(expression, []); - var startLine = starts[0].line; - const startColumn = starts[0].column; - starts.forEach((loc) => { - if (loc.line > startLine) { - startLine = loc.line; - if (loc.column !== startColumn) { - msg = 'Misaligned multiline assignment'; - } - } - }); - break; - } - return msg; -} - -function testAssignment(context, node) { - const msg = checkExpressionAlignment(node.right); - if (msg) - context.report(node, msg); -} - -function testDeclaration(context, node) { - node.declarations.forEach((declaration) => { - const msg = checkExpressionAlignment(declaration.init); - if (msg) - context.report(node, msg); - }); -} - -module.exports = function(context) { - return { - 'AssignmentExpression': (node) => testAssignment(context, node), - 'VariableDeclaration': (node) => testDeclaration(context, node) - }; -};