diff --git a/.eslintrc.js b/.eslintrc.js index b3b4d755f..4f9231b90 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -38,6 +38,9 @@ module.exports = { "error", // `!foo === bar` and `!foo !== bar` 'BinaryExpression[operator=/^[!=]==$/] > UnaryExpression.left[operator="!"]', + // `(() => (foo ? bar : baz))()` + // TODO: Remove this when https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1730 get implemented + 'CallExpression[callee.type="ArrowFunctionExpression"][callee.body.type="ConditionalExpression"]', ], "no-return-await": "error", "no-unneeded-ternary": "error", diff --git a/src/language-yaml/utils.js b/src/language-yaml/utils.js index b1fde2d26..39b768fcc 100644 --- a/src/language-yaml/utils.js +++ b/src/language-yaml/utils.js @@ -253,12 +253,15 @@ function getBlockValueLineContents( // exclude open line `>` or `|` .match(/^[^\n]*\n(.*)$/s)[1]; - const leadingSpaceCount = - node.indent === null - ? ((match) => (match ? match[1].length : Number.POSITIVE_INFINITY))( - content.match(/^( *)[^\n\r ]/m) - ) - : node.indent - 1 + parentIndent; + let leadingSpaceCount; + if (node.indent === null) { + const matches = content.match(/^(? *)[^\n\r ]/m); + leadingSpaceCount = matches + ? matches.groups.leadingSpace.length + : Number.POSITIVE_INFINITY; + } else { + leadingSpaceCount = node.indent - 1 + parentIndent; + } const rawLineContents = content .split("\n")