summaryrefslogtreecommitdiff
path: root/tests/integration/lsp_tests.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-07-25 09:07:59 -0400
committerGitHub <noreply@github.com>2024-07-25 09:07:59 -0400
commit763f05e74dfd0032b238603f625893a52e363591 (patch)
treec6a71559472755919358afa53eecac206cad80a9 /tests/integration/lsp_tests.rs
parentef78d317f084ffe633253acd138a48a425113fa7 (diff)
fix(unstable): move sloppy-import warnings to lint rule (#24710)
Adds a new `no-sloppy-imports` lint rule and cleans up the lint code. Closes #22844 Closes https://github.com/denoland/deno_lint/issues/1293
Diffstat (limited to 'tests/integration/lsp_tests.rs')
-rw-r--r--tests/integration/lsp_tests.rs90
1 files changed, 86 insertions, 4 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index e8904942d..cbc175ec6 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -14459,7 +14459,67 @@ fn lsp_sloppy_imports() {
},
}));
- assert_eq!(json!(diagnostics.all()), json!([]));
+ assert_eq!(
+ json!(diagnostics.all()),
+ json!([{
+ "range": {
+ "start": { "line": 0, "character": 19 },
+ "end": { "line": 0, "character": 24 }
+ },
+ "severity": 2,
+ "code": "no-sloppy-imports",
+ "source": "deno-lint",
+ "message": "Sloppy imports are not allowed.",
+ "data": [{
+ "description": "Add a '.ts' extension.",
+ "changes": [{
+ "range": {
+ "start": { "line": 0, "character": 19 },
+ "end": { "line": 0, "character": 24 },
+ },
+ "new_text": "'./a.ts'"
+ }]
+ }]
+ }, {
+ "range": {
+ "start": { "line": 1, "character": 19 },
+ "end": { "line": 1, "character": 27 }
+ },
+ "severity": 2,
+ "code": "no-sloppy-imports",
+ "source": "deno-lint",
+ "message": "Sloppy imports are not allowed.",
+ "data": [{
+ "description": "Change the extension to '.ts'.",
+ "changes": [{
+ "range": {
+ "start": { "line": 1, "character": 19 },
+ "end": { "line": 1, "character": 27 },
+ },
+ "new_text": "'./b.ts'"
+ }]
+ }]
+ }, {
+ "range": {
+ "start": { "line": 2, "character": 19 },
+ "end": { "line": 2, "character": 27 }
+ },
+ "severity": 2,
+ "code": "no-sloppy-imports",
+ "source": "deno-lint",
+ "message": "Sloppy imports are not allowed.",
+ "data": [{
+ "description": "Change the extension to '.d.ts'.",
+ "changes": [{
+ "range": {
+ "start": { "line": 2, "character": 19 },
+ "end": { "line": 2, "character": 27 },
+ },
+ "new_text": "'./c.d.ts'"
+ }]
+ }]
+ }])
+ );
client.shutdown();
}
@@ -14488,11 +14548,33 @@ fn lsp_sloppy_imports_prefers_dts() {
"import { foo } from './a.js';\nconsole.log(foo);",
);
let diagnostics = client.did_open_file(&file);
- // no warnings because "a.js" exists
- assert_eq!(diagnostics.all().len(), 0);
+ // no other warnings because "a.js" exists
+ assert_eq!(
+ json!(diagnostics.all()),
+ json!([{
+ "range": {
+ "start": { "line": 0, "character": 20 },
+ "end": { "line": 0, "character": 28 }
+ },
+ "severity": 2,
+ "code": "no-sloppy-imports",
+ "source": "deno-lint",
+ "message": "Sloppy imports are not allowed.",
+ "data": [{
+ "description": "Change the extension to '.d.ts'.",
+ "changes": [{
+ "range": {
+ "start": { "line": 0, "character": 20 },
+ "end": { "line": 0, "character": 28 },
+ },
+ "new_text": "'./a.d.ts'"
+ }]
+ }]
+ }])
+ );
let diagnostics = client.did_open_file(&a_dts);
- assert_eq!(diagnostics.all().len(), 0, "Got {:#?}", diagnostics.all());
+ assert_eq!(json!(diagnostics.for_file(&a_dts.uri())), json!([]));
let response = client.write_request(
"textDocument/references",