Skip to content

Commit 14324ed

Browse files
kittensheetalkamat
andcommitted
Apply code suggestions
Co-authored-by: Sheetal Nandi <[email protected]>
1 parent 046eb0b commit 14324ed

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/server/editorServices.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
DocumentRegistry,
3333
DocumentRegistryBucketKeyWithMode,
3434
emptyOptions,
35-
ensurePathIsNonModuleName,
3635
ensureTrailingDirectorySeparator,
3736
ExtendedConfigCacheEntry,
3837
FileExtensionInfo,
@@ -67,6 +66,7 @@ import {
6766
IncompleteCompletionsCache,
6867
IndentStyle,
6968
isArray,
69+
isExternalModuleNameRelative,
7070
isIgnoredFileFromWildCardWatching,
7171
isInsideNodeModules,
7272
isJsonEqual,
@@ -90,7 +90,6 @@ import {
9090
ParsedCommandLine,
9191
parseJsonSourceFileConfigFileContent,
9292
parseJsonText,
93-
parsePackageName,
9493
Path,
9594
PerformanceEvent,
9695
PluginImport,
@@ -4488,18 +4487,12 @@ export class ProjectService {
44884487
}
44894488

44904489
this.logger.info(`Enabling plugin ${pluginConfigEntry.name} from candidate paths: ${searchPaths.join(",")}`);
4491-
if (!pluginConfigEntry.name) {
4492-
this.logger.info(`Skipped loading plugin ${JSON.stringify(pluginConfigEntry)} because plugin name was not specified`);
4493-
return;
4494-
}
4495-
4496-
const parsedPackageName = parsePackageName(pluginConfigEntry.name);
44974490
if (
4498-
!parsedPackageName.packageName ||
4499-
normalizePath(parsedPackageName.rest) !== parsedPackageName.rest ||
4500-
ensurePathIsNonModuleName(parsedPackageName.rest) === parsedPackageName.rest
4491+
!pluginConfigEntry.name ||
4492+
isExternalModuleNameRelative(pluginConfigEntry.name) ||
4493+
/[\\/]\.\.?($|[\\/])/.test(pluginConfigEntry.name)
45014494
) {
4502-
this.logger.info(`Skipped loading plugin ${pluginConfigEntry.name} because only package name is allowed plugin name`);
4495+
this.logger.info(`Skipped loading plugin ${pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)} because only package name is allowed plugin name`);
45034496
return;
45044497
}
45054498

tests/baselines/reference/tsserver/plugins/With-local-plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Info seq [hh:mm:ss:mss] Skipped loading plugin myPlugin/../malicious because on
161161
Info seq [hh:mm:ss:mss] Enabling plugin myPlugin/subpath/../../malicious from candidate paths: /a/lib/tsc.js/../../..
162162
Info seq [hh:mm:ss:mss] Skipped loading plugin myPlugin/subpath/../../malicious because only package name is allowed plugin name
163163
Info seq [hh:mm:ss:mss] Enabling plugin undefined from candidate paths: /a/lib/tsc.js/../../..
164-
Info seq [hh:mm:ss:mss] Skipped loading plugin {"transform":"some-transform"} because plugin name was not specified
164+
Info seq [hh:mm:ss:mss] Skipped loading plugin {"transform":"some-transform"} because only package name is allowed plugin name
165165
Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined WatchType: Closed Script info
166166
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
167167
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms

0 commit comments

Comments
 (0)