@stylistic/eslint-plugin-jsx
Advanced tools
Comparing version 2.9.0 to 2.10.0
@@ -189,22 +189,17 @@ 'use strict'; | ||
} | ||
function getOpeningElementId(node) { | ||
return node.range.join(":"); | ||
} | ||
const lastAttributeNode = {}; | ||
return { | ||
JSXAttribute(node) { | ||
lastAttributeNode[getOpeningElementId(node.parent)] = node; | ||
}, | ||
JSXSpreadAttribute(node) { | ||
lastAttributeNode[getOpeningElementId(node.parent)] = node; | ||
}, | ||
"JSXOpeningElement:exit": function(node) { | ||
const attributeNode = lastAttributeNode[getOpeningElementId(node)]; | ||
const cachedLastAttributeEndPos = attributeNode ? attributeNode.range[1] : null; | ||
const lastAttributeNode = node.attributes.at(-1); | ||
const cachedLastAttributeEndPos = lastAttributeNode ? lastAttributeNode.range[1] : null; | ||
let expectedNextLine; | ||
const tokens = getTokensLocations(node); | ||
const expectedLocation = getExpectedLocation(tokens); | ||
let expectedLocation = getExpectedLocation(tokens); | ||
let usingSameIndentation = true; | ||
if (expectedLocation === "tag-aligned") | ||
usingSameIndentation = tokens.isTab.openTab === tokens.isTab.closeTab; | ||
const lastComment = context.sourceCode.getCommentsInside(node).at(-1); | ||
const hasTrailingComment = lastComment && lastComment.range[0] > (lastAttributeNode ?? node.name).range[1]; | ||
if ((expectedLocation === "after-props" || expectedLocation === "after-tag") && !(hasCorrectLocation(tokens, expectedLocation) && usingSameIndentation) && hasTrailingComment) { | ||
expectedLocation = "line-aligned"; | ||
} | ||
if (hasCorrectLocation(tokens, expectedLocation) && usingSameIndentation) | ||
@@ -237,5 +232,7 @@ return; | ||
case "tag-aligned": | ||
case "line-aligned": | ||
return fixer.replaceTextRange([cachedLastAttributeEndPos, node.range[1]], ` | ||
case "line-aligned": { | ||
const rangeStart = hasTrailingComment ? lastComment.range[1] : cachedLastAttributeEndPos; | ||
return fixer.replaceTextRange([rangeStart, node.range[1]], ` | ||
${getIndentation(tokens, expectedLocation, correctColumn)}${closingTag}`); | ||
} | ||
} | ||
@@ -242,0 +239,0 @@ return null; |
{ | ||
"name": "@stylistic/eslint-plugin-jsx", | ||
"type": "commonjs", | ||
"version": "2.9.0", | ||
"version": "2.10.0", | ||
"author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
@@ -61,4 +61,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"eslint-visitor-keys": "^4.1.0", | ||
"espree": "^10.2.0", | ||
"eslint-visitor-keys": "^4.2.0", | ||
"espree": "^10.3.0", | ||
"estraverse": "^5.3.0", | ||
@@ -65,0 +65,0 @@ "picomatch": "^4.0.2" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154099
4344
Updatedeslint-visitor-keys@^4.2.0
Updatedespree@^10.3.0