From bbf541dcd0f61d4ec477bf4ac75ed5bbae53e995 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 4 Jul 2017 20:44:40 -0700 Subject: [PATCH] tools: remove align-multiline-assignment lint rule In preparation for stricter indentation linting, remove the align-multiline-assignment custom rule, as it may conflict with the ESLint stricter indentation linting. --- .eslintrc.yaml | 1 - .../align-multiline-assignment.js | 67 ------------------- 2 files changed, 68 deletions(-) delete mode 100644 tools/eslint-rules/align-multiline-assignment.js diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 96f07d7564f754..133bd67e71651d 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 8e2f5ed1ee7e90..00000000000000 --- 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) - }; -};