From 0993c017bace34cbcbf8a19b830b22db95676ca4 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 8 Nov 2022 16:35:10 -0800 Subject: [PATCH] Fix JSDoc eslint rule for properties and methods (#51462) --- scripts/eslint/rules/jsdoc-format.cjs | 2 + src/server/editorServices.ts | 41 +++++++++++------ src/server/project.ts | 44 +++++++++++++------ src/server/scriptInfo.ts | 7 ++- .../reference/api/tsserverlibrary.d.ts | 2 - 5 files changed, 65 insertions(+), 31 deletions(-) diff --git a/scripts/eslint/rules/jsdoc-format.cjs b/scripts/eslint/rules/jsdoc-format.cjs index fe4bf64fb96..d8d78b97970 100644 --- a/scripts/eslint/rules/jsdoc-format.cjs +++ b/scripts/eslint/rules/jsdoc-format.cjs @@ -172,6 +172,8 @@ module.exports = createRule({ TSIndexSignature: checkDeclaration, TSMethodSignature: checkDeclaration, TSParameterProperty: checkDeclaration, + PropertyDefinition: checkDeclaration, + MethodDefinition: checkDeclaration, }; }, }); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index b3e91f685ef..cad89c3a351 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -718,8 +718,9 @@ export class ProjectService { /** * Container of all known scripts + * + * @internal */ - /** @internal */ readonly filenameToScriptInfo = new Map(); private readonly nodeModulesWatchers = new Map(); /** @@ -733,8 +734,9 @@ export class ProjectService { /** * Map to the real path of the infos + * + * @internal */ - /** @internal */ readonly realpathToScriptInfos: MultiMap | undefined; /** * maps external project file name to list of config files that were the part of this project @@ -786,8 +788,11 @@ export class ProjectService { * In this case the exists could be true/false based on config file is present or not * - Or it is present if we have configured project open with config file at that location * In this case the exists property is always true + * + * + * @internal */ - /** @internal */ readonly configFileExistenceInfoCache = new Map(); + readonly configFileExistenceInfoCache = new Map(); /** @internal */ readonly throttledOperations: ThrottledOperations; private readonly hostConfiguration: HostConfiguration; @@ -1344,8 +1349,9 @@ export class ProjectService { /** * This is to watch whenever files are added or removed to the wildcard directories + * + * @internal */ - /** @internal */ private watchWildcardDirectory(directory: Path, flags: WatchDirectoryFlags, configFileName: NormalizedPath, config: ParsedConfig) { return this.watchFactory.watchDirectory( directory, @@ -1774,8 +1780,9 @@ export class ProjectService { /** * Close the config file watcher in the cached ConfigFileExistenceInfo * if there arent any open files that are root of inferred project and there is no parsed config held by any project + * + * @internal */ - /** @internal */ private closeConfigFileWatcherOnReleaseOfOpenFile(configFileExistenceInfo: ConfigFileExistenceInfo) { // Close the config file watcher if there are no more open files that are root of inferred project // or if there are no projects that need to watch this config file existence info @@ -1822,8 +1829,9 @@ export class ProjectService { /** * This is called by inferred project whenever script info is added as a root + * + * @internal */ - /** @internal */ startWatchingConfigFilesForInferredProjectRoot(info: ScriptInfo) { Debug.assert(info.isScriptOpen()); this.forEachConfigFileLocation(info, (canonicalConfigFilePath, configFileName) => { @@ -1852,8 +1860,9 @@ export class ProjectService { /** * This is called by inferred project whenever root script info is removed from it + * + * @internal */ - /** @internal */ stopWatchingConfigFilesForInferredProjectRoot(info: ScriptInfo) { this.forEachConfigFileLocation(info, canonicalConfigFilePath => { const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); @@ -2168,8 +2177,9 @@ export class ProjectService { /** * Read the config file of the project, and update the project root file names. + * + * @internal */ - /** @internal */ private loadConfiguredProject(project: ConfiguredProject, reason: string) { tracing?.push(tracing.Phase.Session, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); this.sendProjectLoadingStartEvent(project, reason); @@ -2434,8 +2444,9 @@ export class ProjectService { /** * Reload the file names from config file specs and update the project graph + * + * @internal */ - /** @internal */ reloadFileNamesOfConfiguredProject(project: ConfiguredProject) { const fileNames = this.reloadFileNamesOfParsedConfig(project.getConfigFilePath(), this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath)!.config!); project.updateErrorOnNoInputFiles(fileNames); @@ -2466,8 +2477,9 @@ export class ProjectService { /** * Read the config file of the project again by clearing the cache and update the project graph + * + * @internal */ - /** @internal */ reloadConfiguredProject(project: ConfiguredProject, reason: string, isInitialLoad: boolean, clearSemanticCache: boolean) { // At this point, there is no reason to not have configFile in the host const host = project.getCachedDirectoryStructureHost(); @@ -2632,8 +2644,9 @@ export class ProjectService { /** * Returns the projects that contain script info through SymLink * Note that this does not return projects in info.containingProjects + * + * @internal */ - /** @internal */ getSymlinkedProjects(info: ScriptInfo): MultiMap | undefined { let projects: MultiMap | undefined; if (this.realpathToScriptInfos) { @@ -4149,8 +4162,9 @@ export class ProjectService { /** * Waits for any ongoing plugin enablement requests to complete. + * + * @internal */ - /** @internal */ async waitForPendingPlugins() { while (this.currentPluginEnablementPromise) { await this.currentPluginEnablementPromise; @@ -4159,8 +4173,9 @@ export class ProjectService { /** * Starts enabling any requested plugins without waiting for the result. + * + * @internal */ - /** @internal */ enableRequestedPlugins() { if (this.pendingPluginEnablements) { void this.enableRequestedPluginsAsync(); diff --git a/src/server/project.ts b/src/server/project.ts index 64bd6a6c5c7..72a3064212d 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -175,14 +175,15 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo private missingFilesMap: ESMap | undefined; private generatedFilesMap: GeneratedFileWatcherMap | undefined; - /*@internal*/ + /** @internal */ protected readonly plugins: PluginModuleWithName[] = []; - /** @internal */ /** * This is map from files to unresolved imports in it * Maop does not contain entries for files that do not have unresolved imports * This helps in containing the set of files to invalidate + * + * @internal */ cachedUnresolvedImportsPerFile = new Map(); @@ -1642,7 +1643,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName); } - /*@internal*/ + /** @internal */ protected getGlobalPluginSearchPaths() { // Search any globally-specified probe paths, then our peer node_modules return [ @@ -1679,8 +1680,9 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo /** * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'. + * + * @internal */ - /** @internal */ beginEnablePluginSync(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): BeginEnablePluginResult { Debug.assertIsDefined(this.projectService.host.require); @@ -1696,8 +1698,9 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo /** * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`. + * + * @internal */ - /** @internal */ async beginEnablePluginAsync(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): Promise { Debug.assertIsDefined(this.projectService.host.importPlugin); @@ -1719,8 +1722,9 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo /** * Performs the remaining steps of enabling a plugin after its module has been instantiated. + * + * @internal */ - /** @internal */ endEnablePlugin({ pluginConfigEntry, pluginConfigOverrides, resolvedModule, errorLogs }: BeginEnablePluginResult) { if (resolvedModule) { const configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name); @@ -2015,8 +2019,11 @@ export class InferredProject extends Project { /** this is canonical project root path */ readonly projectRootPath: string | undefined; - /** @internal */ - /** stored only if their is no projectRootPath and this isnt single inferred project */ + /** + * stored only if their is no projectRootPath and this isnt single inferred project + * + * @internal + */ readonly canonicalCurrentDirectory: string | undefined; /** @internal */ @@ -2412,8 +2419,11 @@ export class ConfiguredProject extends Project { private projectReferences: readonly ProjectReference[] | undefined; - /** Potential project references before the project is actually loaded (read config file) */ - /** @internal */ + /** + * Potential project references before the project is actually loaded (read config file) + * + * @internal + */ potentialProjectReferences: Set | undefined; /** @internal */ @@ -2630,8 +2640,11 @@ export class ConfiguredProject extends Project { !this.canConfigFileJsonReportNoInputFiles; } - /** @internal */ - /** Find the configured project from the project references in project which contains the info directly */ + /** + * Find the configured project from the project references in project which contains the info directly + * + * @internal + */ getDefaultChildProjectFromProjectWithReferences(info: ScriptInfo) { return forEachResolvedProjectReferenceProject( this, @@ -2643,8 +2656,11 @@ export class ConfiguredProject extends Project { ); } - /** Returns true if the project is needed by any of the open script info/external project */ - /** @internal */ + /** + * Returns true if the project is needed by any of the open script info/external project + * + * @internal + */ hasOpenRef() { if (!!this.externalProjectRefCount) { return true; diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 25c77fe3d4d..4591bc07d71 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -317,8 +317,11 @@ export class ScriptInfo { /** @internal */ readonly isDynamic: boolean; - /** @internal */ - /** Set to real path if path is different from info.path */ + /** + * Set to real path if path is different from info.path + * + * @internal + */ private realpath: Path | undefined; /** @internal */ diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 6a93d33726e..c62807f4dbb 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3127,7 +3127,6 @@ declare namespace ts { private externalFiles; private missingFilesMap; private generatedFilesMap; - protected readonly plugins: PluginModuleWithName[]; protected languageService: LanguageService; languageServiceEnabled: boolean; readonly trace?: (s: string) => void; @@ -3252,7 +3251,6 @@ declare namespace ts { setTypeAcquisition(newTypeAcquisition: TypeAcquisition | undefined): void; getTypeAcquisition(): ts.TypeAcquisition; protected removeRoot(info: ScriptInfo): void; - protected getGlobalPluginSearchPaths(): string[]; protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map | undefined): void; protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map | undefined): void; private enableProxy;