From 8b7c4fc06ff5bbc34215585965e66301c476d107 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. Backport-PR-URL: https://github.com/nodejs/node/pull/14835 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 2b0e4875670101..1e30f5a55463ff 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -166,7 +166,6 @@ rules: template-curly-spacing: 2 # Custom rules in tools/eslint-rules - align-multiline-assignment: 2 assert-throws-arguments: [2, { requireTwo: true }] # Global scoped method and vars 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) - }; -};