Skip to content

Adding ESLint option to forbid @override TSDoc tags#475

Draft
iclanton with Copilot wants to merge 9 commits into
mainfrom
copilot/investigate-add-eslint-override-option
Draft

Adding ESLint option to forbid @override TSDoc tags#475
iclanton with Copilot wants to merge 9 commits into
mainfrom
copilot/investigate-add-eslint-override-option

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown

Pull request created by AI Agent

Comment thread eslint-plugin/src/index.ts Outdated
Program: checkCommentBlocks,
MethodDefinition: checkOverrideTags,
PropertyDefinition: checkOverrideTags
} as unknown as eslint.Rule.RuleListener;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - Why is this cast necessary?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the cast by giving the listener object an explicit eslint.Rule.RuleListener type instead of relying on the as unknown as ... assertion.

Comment thread eslint-plugin/src/index.ts Outdated
}

function hasOverrideTag(commentText: string): boolean {
return /(^|\n)\s*\*?\s*@override\b/m.test(commentText);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - This rule processes the comment as TSDoc, right? So at some point, it has the comment parsed. Can we use that instead of this regexp?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched the override-tag check to use the TSDoc parser’s parsed modifier-tag state instead of the regexp, so the rule now relies on the parsed doc comment directly.

Copilot AI requested a review from iclanton July 18, 2026 01:24
@iclanton

Copy link
Copy Markdown
Member

@copilot - take a look at my comments.

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Author

@copilot - take a look at my comments.

I reviewed the existing review comments and updated the rule to use the parsed TSDoc modifier-tag state instead of the regexp, and I removed the unnecessary cast. No further code changes are needed.

@iclanton

Copy link
Copy Markdown
Member

@copilot- this needs a changefile.

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Author

@copilot- this needs a changefile.

Added the requested changefile at common/changes/eslint-plugin-tsdoc/add-forbid-override-tag-option_2026-07-18-01-39.json.

Comment thread eslint-plugin/src/index.ts Outdated
typeof node === 'object' &&
node !== null &&
'override' in node &&
Boolean((node as { override?: boolean }).override)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - Is this cast actually necessary?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the helper parameter as unknown and used a narrow node as never cast only at the context.report call site, which satisfies the compiler without relying on a broader AST type import.

Comment thread eslint-plugin/src/index.ts Outdated
return {
Program: checkCommentBlocks
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function checkOverrideTags(node: any): void {

@iclanton iclanton Jul 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - What type should this be instead of any?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the helper to unknown and kept the actual AST node handling inside the existing runtime guard, so the function is typed to the data it receives rather than forcing an incompatible ESTree type.

Comment thread eslint-plugin/README.md Outdated
},
rules: {
"tsdoc/syntax": "warn"
"tsdoc/syntax": "warn"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - Fix this indentation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the indentation in the README example to match the surrounding code block formatting.

Copilot AI requested a review from iclanton July 18, 2026 01:48
iclanton added 3 commits July 18, 2026 22:59
Reuse the ParserContext already produced for each doc comment instead of
re-parsing it in a separate visitor, and fix the autofix and test setup so
the forbidOverrideTag option actually works.
Locate the @OverRide tag via TSDoc's recorded token range instead of regex,
remove the whole comment when it holds nothing else, and drop trailing empty
comment lines. Also narrow the ESLint node union to remove several casts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants