Skip to content

Commit 230d996

Browse files
committed
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.
1 parent 6e52bbd commit 230d996

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

apps/oxlint/src-js/plugins/source_code.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ export const SOURCE_CODE = Object.freeze({
149149
if (!node) return sourceText;
150150

151151
// ESLint ignores falsy values for `beforeCount` and `afterCount`
152-
let { start, end } = node;
152+
const { range } = node;
153+
let start = range[0], end = range[1];
153154
if (beforeCount) start = max(start - beforeCount, 0);
154155
if (afterCount) end += afterCount;
155156
return sourceText.slice(start, end);

0 commit comments

Comments
 (0)