Skip to content

Commit dd1e9f4

Browse files
Kai Cataldobtmills
authored andcommitted
Fix: revert changes to key-spacing due to regression (#12598)
Revert "Update: Fix uglified object align in key-spacing (fixes #11414) (#12472)" This reverts commit 6503cb8.
1 parent c644b54 commit dd1e9f4

2 files changed

Lines changed: 2 additions & 449 deletions

File tree

lib/rules/key-spacing.js

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,6 @@ function isSingleLine(node) {
4242
return (node.loc.end.line === node.loc.start.line);
4343
}
4444

45-
/**
46-
* Checks whether both nodes are on the same line.
47-
* @param {ASTNode} nodeA AST Node being evaluated.
48-
* @param {ASTNode} nodeB AST Node being evaluated.
49-
* @returns {boolean} True if both nodes are on the same line.
50-
*/
51-
function isOnSameLine(nodeA, nodeB) {
52-
return (nodeA.loc.end.line === nodeB.loc.end.line);
53-
}
54-
55-
/**
56-
* Checks whether the properties of a node on the same line.
57-
* @param {ASTNode} node node
58-
* @returns {boolean} True if the properties of a node are on the same line.
59-
*/
60-
function isPropertiesOnSameLine(node) {
61-
if (node.properties.length <= 1) {
62-
return true;
63-
}
64-
const [firstProperty] = node.properties;
65-
66-
return node.properties.every(property => isOnSameLine(firstProperty, property));
67-
}
68-
6945
/**
7046
* Initializes a single option property from the configuration with defaults for undefined values
7147
* @param {Object} toOptions Object to be initialized
@@ -654,7 +630,7 @@ module.exports = {
654630

655631
return {
656632
ObjectExpression(node) {
657-
if (isSingleLine(node) || isPropertiesOnSameLine(node)) {
633+
if (isSingleLine(node)) {
658634
verifyListSpacing(node.properties.filter(isKeyValueProperty));
659635
} else {
660636
verifyAlignment(node);
@@ -667,9 +643,7 @@ module.exports = {
667643
// Obey beforeColon and afterColon in each property as configured
668644
return {
669645
Property(node) {
670-
const option = (isSingleLine(node.parent) || isPropertiesOnSameLine(node.parent)) ? singleLineOptions : multiLineOptions;
671-
672-
verifySpacing(node, option);
646+
verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
673647
}
674648
};
675649

0 commit comments

Comments
 (0)