From 2d360d97130bd4f66a25789823ef41bb502ec0cc Mon Sep 17 00:00:00 2001 From: Mark Skelton Date: Thu, 21 Mar 2024 21:09:03 -0500 Subject: [PATCH] feat!: Update minimum supported ESLint version to 8 --- bun.lockb | Bin 363573 -> 363573 bytes package.json | 2 +- src/rules/imports.ts | 14 +++++++++----- src/utils.ts | 5 ++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bun.lockb b/bun.lockb index 4b8554c43ca0361193d2998e6bc324c8a7060987..2f59a50000c71bdbe1565c8454e1565d5371d30a 100755 GIT binary patch delta 2676 zcmXZec~F&A9LDkY<$!34)}SVkg{V-CjLu}aAc|XBT8gHbEmMEEW8yAu7XtxPQ#3hO z0mZ^>tWhh7Y%ynAv~1JVFQ?s&iv@)mf@AABJ5ASn7=Xc)wzUQ6;G)6l%MmrXl zhNW>0uDC4!rl9#48y5s2u>~zVvDxxv_O`cdoUA35DH|_qg=P6;WiEN(t?HVfuGVyQ zkWIvR1#M`ln0@Rd)g_VJCHjnVcP8>Q*^Zg&OCkSg#T>I_spOw9yX^wZaZaPP&}Yq2 zojvApitM%vRo9t3J%Jw_^D*nYnKq-@BEd3{S8xk$rV3Zc(y;=}o;iZqeRZMDR$Z|y z0~<}YV-;tMU1?isHYp{5jqOI;CM%5@PtYBx@!=YmoUn_S)ReNujR_+Y$#(43*uLbk zF$scwvVOcj%Y|*y_G30N{b?sKo3z(dmqR`!Ymg1VzGbp((i&yC7sBjRrM0P-yhZV`*)Y!q;QrX+GA=on6L5&@XEtkC;Grr$pV6pHJXiqnsR_<4= zb;*%+>Uv+-7(v%Y*$1+bSf%Vk**#d5?6B-!Y^&^uY!p_F*$VndHkw@9To(yG7TyQ$ z(BPw(-RJ$ZowCnVHwJrN_PNZy(R$ezvV3fp?3ipEwgt??vpvY#EoO(&nmY-wMR%^=USUkDt(%4U*RVz!Kb zlg%QpZMI18yRZN}0@~8PD4R{56CVV&wEvJjN!~_X9_K%0bIAQMJO09KG7D)r*kI0= zRX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(KUSJnJH*`}}AHQ99XCCsM#FR~frBKyu_yDpnaUXIz+{#7=Myhiq$tN=TW zJ2TQ0!*l_ltY$hTb<2iW#pdp zv&Gq>!6Lyb4!VH0I$Nq^IXMlp)!9l`K~BMJYb{$%PL;L6>{VA%>13PZZDsZyZVSd% zaXXD&LoRhZwyoIq!nNcRdNoP1by#n*Z5?DUlQU$=vh~<}jqNDgfZ2s@6{pBHlI=!p zA*T8z8{O#KX~ZsSt|oh)$re~wnJ3$6Y%z6{)yN8bxXC5v+Vbh4Ci@dNf>YR1Nt10S zkCgS4*(v|yjthN0rwHfyX`5Vndzg2fHSz+#$9gREN3Dm==1le2OSbbA`#`D`vDu~PMmZdyru}NN8I~=3LsrT@NA{+y%x~Px6<2XMP)!Ha zRL*{o>@D&ca)m$36~nc$Tbo^W=rgNa@34iRTIJGxyJ~Wl&#iXpz1lVof<&qvW&cZc zppvPMR4Ubqvj3fuePxyF?hjVEKK^IU<)hWE&R_6uSX@EilWJU%f5y8^zs0+}*y%Eyw+Xy3wF95VX3d$>4y5coo-&Z z-jCYlcKI8-+_40kOZk4^ZugL{+wD$;<72gZoD1XcvBmbj;_h?~`&QJRbg|l#@im|S E4=6" + "eslint": ">=8" }, "dependencies": { "@typescript-eslint/experimental-utils": "^5.54.1", diff --git a/src/rules/imports.ts b/src/rules/imports.ts index 86f5f68..f4d1117 100644 --- a/src/rules/imports.ts +++ b/src/rules/imports.ts @@ -92,7 +92,6 @@ export default { const groups = options?.groups ?? [] const separator = options?.separator ?? "" const sorter = getSorter(options) - const source = context.getSourceCode() return { Program(program) { @@ -145,15 +144,19 @@ export default { *fix(fixer) { for (const [node, complement] of enumerate(nodes, sorted)) { yield fixer.replaceTextRange( - getNodeRange(source, node, !isFirst(node)), - getNodeText(source, complement, !isFirst(complement)) + getNodeRange(context.sourceCode, node, !isFirst(node)), + getNodeText( + context.sourceCode, + complement, + !isFirst(complement) + ) ) } }, }) } - const text = source.getText() + const text = context.sourceCode.getText() for (let i = 1; i < nodes.length; i++) { const node = nodes[i] const prevNode = nodes[i - 1] @@ -161,7 +164,8 @@ export default { // If the node has preceding comments, we want to use the first // comment as the starting position for both determining what the // current separator is as well as the location for the report. - const nodeOrComment = source.getCommentsBefore(node)[0] ?? node + const nodeOrComment = + context.sourceCode.getCommentsBefore(node)[0] ?? node // Find the range between nodes (including comments) so we can pull // the text and apply fixes to newlines between imports. diff --git a/src/utils.ts b/src/utils.ts index 5f97357..23c20bc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -138,7 +138,6 @@ export function report( nodes: Node[], sorted: Node[] ) { - const source = context.getSourceCode() const firstUnsortedNode = isUnsorted(nodes, sorted) if (firstUnsortedNode) { @@ -148,8 +147,8 @@ export function report( *fix(fixer) { for (const [node, complement] of enumerate(nodes, sorted)) { yield fixer.replaceTextRange( - getNodeRange(source, node), - getNodeText(source, complement) + getNodeRange(context.sourceCode, node), + getNodeText(context.sourceCode, complement) ) } },