Browse Source

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.

PR-URL: https://github.com/nodejs/node/pull/14079
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
v6
Rich Trott 8 years ago
parent
commit
a965067f74
  1. 1
      .eslintrc.yaml
  2. 67
      tools/eslint-rules/align-multiline-assignment.js

1
.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

67
tools/eslint-rules/align-multiline-assignment.js

@ -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)
};
};
Loading…
Cancel
Save