Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
no-redundant-jsdoc: only check nodes that can have JSDoc (#3355)
Browse files Browse the repository at this point in the history
[no-log] just a performance optimization
  • Loading branch information
ajafff authored and adidahiya committed Oct 20, 2017
1 parent 10e6c9c commit fff81e7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/rules/noRedundantJsdocRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { getJsDoc } from "tsutils";
import { canHaveJsDoc, getJsDoc } from "tsutils";
import * as ts from "typescript";

import * as Lint from "../index";
Expand Down Expand Up @@ -49,15 +49,18 @@ export class Rule extends Lint.Rules.AbstractRule {

function walk(ctx: Lint.WalkContext<void>): void {
const { sourceFile } = ctx;
ts.forEachChild(sourceFile, function cb(node) {
for (const { tags } of getJsDoc(node, sourceFile)) {
if (tags !== undefined) {
for (const tag of tags) {
checkTag(tag);
// Intentionally exclude EndOfFileToken: it can have JSDoc, but it is only relevant in JavaScript files
return sourceFile.statements.forEach(function cb(node: ts.Node): void {
if (canHaveJsDoc(node)) {
for (const { tags } of getJsDoc(node, sourceFile)) {
if (tags !== undefined) {
for (const tag of tags) {
checkTag(tag);
}
}
}
}
ts.forEachChild(node, cb);
return ts.forEachChild(node, cb);
});

function checkTag(tag: ts.JSDocTag): void {
Expand Down

0 comments on commit fff81e7

Please sign in to comment.