Skip to content

Commit 816e51f

Browse files
committed
refactor(linter/plugins): shorten import of comment-related SourceCode methods
1 parent 1e67d40 commit 816e51f

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* `SourceCode` methods related to comments.
3+
*/
4+
15
import { ast, initAst, sourceText } from './source_code.js';
26

37
import type { Comment, Node, NodeOrToken } from './types.ts';

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@ import { DATA_POINTER_POS_32, SOURCE_LEN_OFFSET } from '../generated/constants.j
66
import { deserializeProgramOnly, resetBuffer } from '../../dist/generated/deserialize.js';
77

88
import visitorKeys from '../generated/keys.js';
9-
import {
10-
commentsExistBetween,
11-
getAllComments,
12-
getCommentsAfter,
13-
getCommentsBefore,
14-
getCommentsInside,
15-
} from './comments.js';
9+
import * as commentMethods from './comments.js';
1610
import {
1711
getLineColumnFromOffset,
1812
getNodeLoc,
@@ -164,12 +158,6 @@ export const SOURCE_CODE = Object.freeze({
164158
return sourceText.slice(start, end);
165159
},
166160

167-
getAllComments,
168-
getCommentsBefore,
169-
getCommentsAfter,
170-
getCommentsInside,
171-
commentsExistBetween,
172-
173161
/**
174162
* Determine if two nodes or tokens have at least one whitespace character between them.
175163
* Order does not matter. Returns `false` if the given nodes or tokens overlap.
@@ -183,6 +171,13 @@ export const SOURCE_CODE = Object.freeze({
183171
throw new Error('`sourceCode.isSpaceBetween` not implemented yet'); // TODO
184172
},
185173

174+
// Comment methods
175+
getAllComments: commentMethods.getAllComments,
176+
getCommentsBefore: commentMethods.getCommentsBefore,
177+
getCommentsAfter: commentMethods.getCommentsAfter,
178+
getCommentsInside: commentMethods.getCommentsInside,
179+
commentsExistBetween: commentMethods.commentsExistBetween,
180+
186181
// Scope methods
187182
isGlobalReference: scopeMethods.isGlobalReference,
188183
getDeclaredVariables: scopeMethods.getDeclaredVariables,

0 commit comments

Comments
 (0)