Skip to content

Conversation

@kraenhansen
Copy link

@kraenhansen kraenhansen commented Aug 30, 2024

This fixes #348 and #349 by adding a new "no-undefined-types" rule to the eslint-plugin-tsdoc package.

NOTE: This is currently in draft as I want a bit of feedback before sinking more time into this.

I see two issues with the implementation as is:

Incorrect scoping

Comment are read using sourceCode.getAllComments(), which means the node to which the comment related gets lost and this entails that any identifiers used in {@link } tags gets resolved relative to the global scope (and its decedents). I am contemplating adding more granular "visitors" to to the RuleListener returned from the rule's create method, but that would probably elevate the complexity quite a bit.

Determining if a type is defined, means running the TypeScript type-checker

Take this example

foo.ts

class MyClass {
    foo() {}
}

bar.ts

/**
 * A {@link MyClass.foo} referencing a member of a class which can't be read out of the AST of the file itself.
 */
const bar = "whatever";

The easiest way would probably be to take an optional peer dependency on @typescript-eslint/utils and implement a typed rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant