Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions eslint-plugin/src/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type { Linter } from 'eslint';

const config: Linter.Config = {
rules: {
'tsdoc/syntax': 'warn'
}
Comment on lines +6 to +9
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The new recommended config is a public entrypoint (plugin:tsdoc/recommended) but there’s no test covering that it is exported and contains the expected rule settings. Consider adding a small unit test asserting plugin.configs.recommended.rules['tsdoc/syntax'] === 'warn' so this contract doesn’t regress.

Copilot uses AI. Check for mistakes.
};

export default config;
Comment on lines +6 to +12
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

This repo appears to consistently use named exports (no other export default usages were found). Consider exporting this as a named export (e.g., export const recommended = ...) to match existing module patterns and avoid any TS interop edge cases with default imports.

Suggested change
const config: Linter.Config = {
rules: {
'tsdoc/syntax': 'warn'
}
};
export default config;
export const recommended: Linter.Config = {
rules: {
'tsdoc/syntax': 'warn'
}
};

Copilot uses AI. Check for mistakes.
93 changes: 2 additions & 91 deletions eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { TSDocConfigFile } from '@microsoft/tsdoc-config';

import { Debug } from './Debug';
import { ConfigCache } from './ConfigCache';
import recommended from './configs/recommended';

const tsdocMessageIds: { [x: string]: string } = {};

Expand All @@ -19,6 +20,7 @@ defaultTSDocConfiguration.allTsdocMessageIds.forEach((messageId: string) => {

interface IPlugin {
rules: { [x: string]: eslint.Rule.RuleModule };
configs: { [x: string]: eslint.Linter.Config };
}
Comment on lines 21 to 24
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

configs was added to IPlugin and recommended is imported, but this file currently doesn't define/export plugin.configs anywhere. To actually expose plugin:tsdoc/recommended, ensure the exported plugin object includes configs: { recommended } (and that the module exports plugin).

Copilot uses AI. Check for mistakes.

function getRootDirectoryFromContext(context: TSESLint.RuleContext<string, unknown[]>): string | undefined {
Expand Down Expand Up @@ -68,94 +70,3 @@ const plugin: IPlugin = {
const tsConfigDir: string | undefined = getRootDirectoryFromContext(
context as unknown as TSESLint.RuleContext<string, unknown[]>
);
Debug.log(`Linting: "${sourceFilePath}"`);

const tsdocConfiguration: TSDocConfiguration = new TSDocConfiguration();

try {
const tsdocConfigFile: TSDocConfigFile = ConfigCache.getForSourceFile(sourceFilePath, tsConfigDir);
if (!tsdocConfigFile.fileNotFound) {
if (tsdocConfigFile.hasErrors) {
context.report({
loc: { line: 1, column: 1 },
messageId: 'error-loading-config-file',
data: {
details: tsdocConfigFile.getErrorSummary()
}
});
}

try {
tsdocConfigFile.configureParser(tsdocConfiguration);
} catch (e) {
context.report({
loc: { line: 1, column: 1 },
messageId: 'error-applying-config',
data: {
details: e.message
}
});
}
}
} catch (e) {
context.report({
loc: { line: 1, column: 1 },
messageId: 'error-loading-config-file',
data: {
details: `Unexpected exception: ${e.message}`
}
});
}

const tsdocParser: TSDocParser = new TSDocParser(tsdocConfiguration);

const sourceCode: eslint.SourceCode = context.sourceCode ?? context.getSourceCode();
function checkCommentBlocks(): void {
for (const comment of sourceCode.getAllComments()) {
if (comment.type !== 'Block') {
continue;
}
if (!comment.range) {
continue;
}

const textRange: TextRange = TextRange.fromStringRange(
sourceCode.text,
comment.range[0],
comment.range[1]
);

// Smallest comment is "/***/"
if (textRange.length < 5) {
continue;
}
// Make sure it starts with "/**"
if (textRange.buffer[textRange.pos + 2] !== '*') {
continue;
}

const parserContext: ParserContext = tsdocParser.parseRange(textRange);
for (const message of parserContext.log.messages) {
context.report({
loc: {
start: sourceCode.getLocFromIndex(message.textRange.pos),
end: sourceCode.getLocFromIndex(message.textRange.end)
},
messageId: message.messageId,
data: {
unformattedText: message.unformattedText
}
});
}
}
}

return {
Program: checkCommentBlocks
};
}
}
}
};

export = plugin;
Loading