diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-08-17 12:14:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-17 16:14:22 +0000 |
commit | f343391a9f97d29ad287f247c06aa370eb7cab50 (patch) | |
tree | eeed398c9506fde5c20d3e552edd8a432bc5a2ae /cli/tests/integration/lsp_tests.rs | |
parent | 6082e51094e0b5835d7c83586766cc611da2a382 (diff) |
fix(unstable): disable importing from the vendor directory (#20067)
Some people might get think they need to import from this directory,
which could cause confusion and duplicate dependencies. Additionally,
the `vendor` directory has special behaviour in the language server, so
importing from the folder will definitely cause confusion and issues
there.
Diffstat (limited to 'cli/tests/integration/lsp_tests.rs')
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index d540c5f37..d2cb36806 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -8958,5 +8958,47 @@ fn lsp_vendor_dir() { ); assert_eq!(diagnostics.all().len(), 2); + // now try doing a relative import into the vendor directory + client.write_notification( + "textDocument/didChange", + json!({ + "textDocument": { + "uri": local_file_uri, + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { "line": 0, "character": 0 }, + "end": { "line": 2, "character": 0 }, + }, + "text": "import { returnsHi } from './vendor/subdir/mod1.ts';\nconst test: string = returnsHi();\nconsole.log(test);" + } + ] + }), + ); + + let diagnostics = client.read_diagnostics(); + + assert_eq!( + json!( + diagnostics + .messages_with_file_and_source(local_file_uri.as_str(), "deno") + .diagnostics + ), + json!([ + { + "range": { + "start": { "line": 0, "character": 26 }, + "end": { "line": 0, "character": 51 } + }, + "severity": 1, + "code": "resolver-error", + "source": "deno", + "message": "Importing from the vendor directory is not permitted. Use a remote specifier instead or disable vendoring." + } + ]), + ); + client.shutdown(); } |