From 230d9963fb909ac94068e2d49ef654717901169c Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Sun, 5 Oct 2025 13:47:32 +0000 Subject: [PATCH] refactor(linter/plugins): `SourceCode#getText` use `range` (#14352) `sourceCode.getText` use AST node's `range` field instead of `start` and `end`. This is what ESLint does. --- apps/oxlint/src-js/plugins/source_code.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/oxlint/src-js/plugins/source_code.ts b/apps/oxlint/src-js/plugins/source_code.ts index 6902118e50897..0e88f86b5076b 100644 --- a/apps/oxlint/src-js/plugins/source_code.ts +++ b/apps/oxlint/src-js/plugins/source_code.ts @@ -149,7 +149,8 @@ export const SOURCE_CODE = Object.freeze({ if (!node) return sourceText; // ESLint ignores falsy values for `beforeCount` and `afterCount` - let { start, end } = node; + const { range } = node; + let start = range[0], end = range[1]; if (beforeCount) start = max(start - beforeCount, 0); if (afterCount) end += afterCount; return sourceText.slice(start, end);