We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bf6ff5f commit 0056f66Copy full SHA for 0056f66
lib/ast/ast.service.ts
@@ -163,15 +163,19 @@ class AstService {
163
}
164
165
public countComments(node: t.Node): number {
166
- let count = 0;
+ const seen = new Set<number>();
167
t.traverse(node, {
168
enter(node) {
169
- count += (node.leadingComments ?? []).length;
170
- count += (node.trailingComments ?? []).length;
171
- count += (node.innerComments ?? []).length;
+ for (const comment of [
+ ...(node.leadingComments ?? []),
+ ...(node.trailingComments ?? []),
172
+ ...(node.innerComments ?? []),
173
+ ]) {
174
+ seen.add(comment.start!);
175
+ }
176
},
177
});
- return count;
178
+ return seen.size;
179
180
181
public isFunction(node: t.Node): boolean {
0 commit comments