From a965067f7475d1816f1a0a7f94ff1dcacf183e0a 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In preparation for stricter indentation linting, remove the align-multiline-assignment custom rule, as it may conflict with the ESLint stricter indentation linting. PR-URL: https://github.com/nodejs/node/pull/14079 Reviewed-By: Refael Ackermann Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson --- .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 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) - }; -};