diff --git a/README.md b/README.md index 1aa287c..8f5a15f 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,7 @@ In the absence of `typescript.moduleRoot`, the plugin will mirror the method JSD 1. Parse the referenced module for an `@module` tag. 2. If a tag is found and it has an explicit id, use that. -3. If a tag is found, but it doesn't have an explicit id, use the module's file path relative to the root directory, and remove the file extension. - -**NOTE:** The root directory will be `process.cwd()` unless any source files are outside it, in which case, the root folder is considered the nearest shared parent directory of all source files. +3. If a tag is found, but it doesn't have an explicit id, use the module's file path relative to the nearest shared parent directory, and remove the file extension. ## What this plugin does @@ -44,6 +42,7 @@ TypeScript and JSDoc use a different syntax for imported types. This plugin conv ### TypeScript **Named export:** + ```js /** * @type {import("./path/to/module").exportName} @@ -51,6 +50,7 @@ TypeScript and JSDoc use a different syntax for imported types. This plugin conv ``` **Default export:** + ```js /** * @type {import("./path/to/module").default} @@ -58,6 +58,7 @@ TypeScript and JSDoc use a different syntax for imported types. This plugin conv ``` **typeof type:** + ```js /** * @type {typeof import("./path/to/module").exportName} @@ -65,10 +66,12 @@ TypeScript and JSDoc use a different syntax for imported types. This plugin conv ``` **Template literal type** + ```js /** * @type {`static:${dynamic}`} */ +``` **@override annotations** @@ -77,6 +80,7 @@ are removed because they make JSDoc stop inheritance ### JSDoc **Named export:** + ```js /** * @type {module:path/to/module.exportName} @@ -84,6 +88,7 @@ are removed because they make JSDoc stop inheritance ``` **Default export assigned to a variable in the exporting module:** + ```js /** * @type {module:path/to/module~variableOfDefaultExport} @@ -93,6 +98,7 @@ are removed because they make JSDoc stop inheritance This syntax is also used when referring to types of `@typedef`s and `@enum`s. **Anonymous default export:** + ```js /** * @type {module:path/to/module} @@ -100,6 +106,7 @@ This syntax is also used when referring to types of `@typedef`s and `@enum`s. ``` **typeof type:** + ```js /** * @type {Class} @@ -107,6 +114,7 @@ This syntax is also used when referring to types of `@typedef`s and `@enum`s. ``` **Template literal type** + ```js /** * @type {'static:${dynamic}'} diff --git a/index.js b/index.js index e3d9655..6665b96 100644 --- a/index.js +++ b/index.js @@ -35,8 +35,7 @@ const fileNodes = {}; let implicitModuleRoot; /** - * Without explicit module ids, JSDoc will use `process.cwd()` if all source files are within cwd. - * If any source files are outside cwd, JSDoc will use the nearest shared parent directory. + * Without explicit module ids, JSDoc will use the nearest shared parent directory. * @return {string} The implicit root path with which to resolve all module ids against. */ function getImplicitModuleRoot() { @@ -44,12 +43,7 @@ function getImplicitModuleRoot() { return implicitModuleRoot; } - if ( - !env.sourceFiles || - env.sourceFiles.length === 0 || - // If all files are in cwd - env.sourceFiles.every((f) => f.startsWith(process.cwd())) - ) { + if (!env.sourceFiles || env.sourceFiles.length === 0) { return process.cwd(); }