Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kaicataldo authored and btmills committed Nov 25, 2019
1 parent c644b54 commit dd1e9f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 449 deletions.
30 changes: 2 additions & 28 deletions lib/rules/key-spacing.js
Expand Up @@ -42,30 +42,6 @@ function isSingleLine(node) {
return (node.loc.end.line === node.loc.start.line);
}

/**
* Checks whether both nodes are on the same line.
* @param {ASTNode} nodeA AST Node being evaluated.
* @param {ASTNode} nodeB AST Node being evaluated.
* @returns {boolean} True if both nodes are on the same line.
*/
function isOnSameLine(nodeA, nodeB) {
return (nodeA.loc.end.line === nodeB.loc.end.line);
}

/**
* Checks whether the properties of a node on the same line.
* @param {ASTNode} node node
* @returns {boolean} True if the properties of a node are on the same line.
*/
function isPropertiesOnSameLine(node) {
if (node.properties.length <= 1) {
return true;
}
const [firstProperty] = node.properties;

return node.properties.every(property => isOnSameLine(firstProperty, property));
}

/**
* Initializes a single option property from the configuration with defaults for undefined values
* @param {Object} toOptions Object to be initialized
Expand Down Expand Up @@ -654,7 +630,7 @@ module.exports = {

return {
ObjectExpression(node) {
if (isSingleLine(node) || isPropertiesOnSameLine(node)) {
if (isSingleLine(node)) {
verifyListSpacing(node.properties.filter(isKeyValueProperty));
} else {
verifyAlignment(node);
Expand All @@ -667,9 +643,7 @@ module.exports = {
// Obey beforeColon and afterColon in each property as configured
return {
Property(node) {
const option = (isSingleLine(node.parent) || isPropertiesOnSameLine(node.parent)) ? singleLineOptions : multiLineOptions;

verifySpacing(node, option);
verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
}
};

Expand Down

0 comments on commit dd1e9f4

Please sign in to comment.