summaryrefslogtreecommitdiff
path: root/tests/specs/lint
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-07-03 20:54:33 -0400
committerGitHub <noreply@github.com>2024-07-04 00:54:33 +0000
commit147411e64b22fe74cb258125acab83f9182c9f81 (patch)
treea1f63dcbf0404c20534986b10f02b649df5a3ad5 /tests/specs/lint
parentdd6d19e12051fac2ea5639f621501f4710a1b8e1 (diff)
feat: npm workspace and better Deno workspace support (#24334)
Adds much better support for the unstable Deno workspaces as well as support for npm workspaces. npm workspaces is still lacking in that we only install packages into the root node_modules folder. We'll make it smarter over time in order for it to figure out when to add node_modules folders within packages. This includes a breaking change in config file resolution where we stop searching for config files on the first found package.json unless it's in a workspace. For the previous behaviour, the root deno.json needs to be updated to be a workspace by adding `"workspace": ["./path-to-pkg-json-folder-goes-here"]`. See details in https://github.com/denoland/deno_config/pull/66 Closes #24340 Closes #24159 Closes #24161 Closes #22020 Closes #18546 Closes #16106 Closes #24160
Diffstat (limited to 'tests/specs/lint')
-rw-r--r--tests/specs/lint/no_slow_types_workspace/deno.json2
-rw-r--r--tests/specs/lint/workspace/__test__.jsonc15
-rw-r--r--tests/specs/lint/workspace/a.out32
-rw-r--r--tests/specs/lint/workspace/deno.json11
-rw-r--r--tests/specs/lint/workspace/package-a/a.ts11
-rw-r--r--tests/specs/lint/workspace/package-a/deno.json12
-rw-r--r--tests/specs/lint/workspace/package-b/b.ts11
-rw-r--r--tests/specs/lint/workspace/package-b/deno.json9
-rw-r--r--tests/specs/lint/workspace/root.out82
-rw-r--r--tests/specs/lint/workspace/root.ts11
-rw-r--r--tests/specs/lint/workspace_no_slow_types/__test__.jsonc27
-rw-r--r--tests/specs/lint/workspace_no_slow_types/a.out14
-rw-r--r--tests/specs/lint/workspace_no_slow_types/a/a.ts3
-rw-r--r--tests/specs/lint/workspace_no_slow_types/a/deno.json5
-rw-r--r--tests/specs/lint/workspace_no_slow_types/b.out14
-rw-r--r--tests/specs/lint/workspace_no_slow_types/b/b.ts9
-rw-r--r--tests/specs/lint/workspace_no_slow_types/b/deno.json5
-rw-r--r--tests/specs/lint/workspace_no_slow_types/c/c.ts6
-rw-r--r--tests/specs/lint/workspace_no_slow_types/c/deno.json5
-rw-r--r--tests/specs/lint/workspace_no_slow_types/deno.json7
-rw-r--r--tests/specs/lint/workspace_no_slow_types/root.out26
21 files changed, 316 insertions, 1 deletions
diff --git a/tests/specs/lint/no_slow_types_workspace/deno.json b/tests/specs/lint/no_slow_types_workspace/deno.json
index e3dd981e5..499731c1e 100644
--- a/tests/specs/lint/no_slow_types_workspace/deno.json
+++ b/tests/specs/lint/no_slow_types_workspace/deno.json
@@ -1,5 +1,5 @@
{
- "workspaces": [
+ "workspace": [
"./a",
"./b",
"./c"
diff --git a/tests/specs/lint/workspace/__test__.jsonc b/tests/specs/lint/workspace/__test__.jsonc
new file mode 100644
index 000000000..6581222c9
--- /dev/null
+++ b/tests/specs/lint/workspace/__test__.jsonc
@@ -0,0 +1,15 @@
+{
+ "tests": {
+ "root": {
+ "args": "lint",
+ "exitCode": 1,
+ "output": "root.out"
+ },
+ "subdir": {
+ "args": "lint",
+ "cwd": "package-a",
+ "exitCode": 1,
+ "output": "a.out"
+ }
+ }
+}
diff --git a/tests/specs/lint/workspace/a.out b/tests/specs/lint/workspace/a.out
new file mode 100644
index 000000000..52f05af99
--- /dev/null
+++ b/tests/specs/lint/workspace/a.out
@@ -0,0 +1,32 @@
+error[no-eval]: `eval` call is not allowed
+ --> [WILDLINE]a.ts:1:1
+ |
+1 | eval("");
+ | ^^^^^^^^
+ = hint: Remove the use of `eval`
+
+ docs: https://lint.deno.land/rules/no-eval
+
+
+error[no-await-in-loop]: Unexpected `await` inside a loop.
+ --> [WILDLINE]a.ts:4:3
+ |
+4 | await Deno.open("test");
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ = hint: Remove `await` in loop body, store all promises generated and then `await Promise.all(storedPromises)` after the loop
+
+ docs: https://lint.deno.land/rules/no-await-in-loop
+
+
+error[no-explicit-any]: `any` type is not allowed
+ --> [WILDLINE]a.ts:9:25
+ |
+9 | export function test(): any {
+ | ^^^
+ = hint: Use a specific type other than `any`
+
+ docs: https://lint.deno.land/rules/no-explicit-any
+
+
+Found 3 problems
+Checked 1 file
diff --git a/tests/specs/lint/workspace/deno.json b/tests/specs/lint/workspace/deno.json
new file mode 100644
index 000000000..2dab3a4ec
--- /dev/null
+++ b/tests/specs/lint/workspace/deno.json
@@ -0,0 +1,11 @@
+{
+ "workspace": [
+ "./package-a",
+ "./package-b"
+ ],
+ "lint": {
+ "rules": {
+ "include": ["no-eval"]
+ }
+ }
+}
diff --git a/tests/specs/lint/workspace/package-a/a.ts b/tests/specs/lint/workspace/package-a/a.ts
new file mode 100644
index 000000000..52bd0cbc0
--- /dev/null
+++ b/tests/specs/lint/workspace/package-a/a.ts
@@ -0,0 +1,11 @@
+eval("");
+
+for (let i = 0; i < 10; i++) {
+ await Deno.open("test");
+}
+
+const unused = 1;
+
+export function test(): any {
+ return {};
+}
diff --git a/tests/specs/lint/workspace/package-a/deno.json b/tests/specs/lint/workspace/package-a/deno.json
new file mode 100644
index 000000000..34130b647
--- /dev/null
+++ b/tests/specs/lint/workspace/package-a/deno.json
@@ -0,0 +1,12 @@
+{
+ "lint": {
+ "rules": {
+ "include": [
+ "no-await-in-loop"
+ ],
+ "exclude": [
+ "no-unused-vars"
+ ]
+ }
+ }
+}
diff --git a/tests/specs/lint/workspace/package-b/b.ts b/tests/specs/lint/workspace/package-b/b.ts
new file mode 100644
index 000000000..52bd0cbc0
--- /dev/null
+++ b/tests/specs/lint/workspace/package-b/b.ts
@@ -0,0 +1,11 @@
+eval("");
+
+for (let i = 0; i < 10; i++) {
+ await Deno.open("test");
+}
+
+const unused = 1;
+
+export function test(): any {
+ return {};
+}
diff --git a/tests/specs/lint/workspace/package-b/deno.json b/tests/specs/lint/workspace/package-b/deno.json
new file mode 100644
index 000000000..93fdf6ca7
--- /dev/null
+++ b/tests/specs/lint/workspace/package-b/deno.json
@@ -0,0 +1,9 @@
+{
+ "lint": {
+ "rules": {
+ "exclude": [
+ "no-explicit-any"
+ ]
+ }
+ }
+}
diff --git a/tests/specs/lint/workspace/root.out b/tests/specs/lint/workspace/root.out
new file mode 100644
index 000000000..1d892a93f
--- /dev/null
+++ b/tests/specs/lint/workspace/root.out
@@ -0,0 +1,82 @@
+error[no-eval]: `eval` call is not allowed
+ --> [WILDLINE]root.ts:1:1
+ |
+1 | eval("");
+ | ^^^^^^^^
+ = hint: Remove the use of `eval`
+
+ docs: https://lint.deno.land/rules/no-eval
+
+
+error[no-unused-vars]: `unused` is never used
+ --> [WILDLINE]root.ts:7:7
+ |
+7 | const unused = 1;
+ | ^^^^^^
+ = hint: If this is intentional, prefix it with an underscore like `_unused`
+
+ docs: https://lint.deno.land/rules/no-unused-vars
+
+
+error[no-explicit-any]: `any` type is not allowed
+ --> [WILDLINE]root.ts:9:25
+ |
+9 | export function test(): any {
+ | ^^^
+ = hint: Use a specific type other than `any`
+
+ docs: https://lint.deno.land/rules/no-explicit-any
+
+
+error[no-eval]: `eval` call is not allowed
+ --> [WILDLINE]package-a[WILDCHAR]a.ts:1:1
+ |
+1 | eval("");
+ | ^^^^^^^^
+ = hint: Remove the use of `eval`
+
+ docs: https://lint.deno.land/rules/no-eval
+
+
+error[no-await-in-loop]: Unexpected `await` inside a loop.
+ --> [WILDLINE]package-a[WILDCHAR]a.ts:4:3
+ |
+4 | await Deno.open("test");
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ = hint: Remove `await` in loop body, store all promises generated and then `await Promise.all(storedPromises)` after the loop
+
+ docs: https://lint.deno.land/rules/no-await-in-loop
+
+
+error[no-explicit-any]: `any` type is not allowed
+ --> [WILDLINE]package-a[WILDCHAR]a.ts:9:25
+ |
+9 | export function test(): any {
+ | ^^^
+ = hint: Use a specific type other than `any`
+
+ docs: https://lint.deno.land/rules/no-explicit-any
+
+
+error[no-eval]: `eval` call is not allowed
+ --> [WILDLINE]package-b[WILDCHAR]b.ts:1:1
+ |
+1 | eval("");
+ | ^^^^^^^^
+ = hint: Remove the use of `eval`
+
+ docs: https://lint.deno.land/rules/no-eval
+
+
+error[no-unused-vars]: `unused` is never used
+ --> [WILDLINE]b.ts:7:7
+ |
+7 | const unused = 1;
+ | ^^^^^^
+ = hint: If this is intentional, prefix it with an underscore like `_unused`
+
+ docs: https://lint.deno.land/rules/no-unused-vars
+
+
+Found 8 problems
+Checked 3 files
diff --git a/tests/specs/lint/workspace/root.ts b/tests/specs/lint/workspace/root.ts
new file mode 100644
index 000000000..52bd0cbc0
--- /dev/null
+++ b/tests/specs/lint/workspace/root.ts
@@ -0,0 +1,11 @@
+eval("");
+
+for (let i = 0; i < 10; i++) {
+ await Deno.open("test");
+}
+
+const unused = 1;
+
+export function test(): any {
+ return {};
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/__test__.jsonc b/tests/specs/lint/workspace_no_slow_types/__test__.jsonc
new file mode 100644
index 000000000..489ee52ab
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/__test__.jsonc
@@ -0,0 +1,27 @@
+{
+ "tests": {
+ "root": {
+ "args": "lint",
+ "exitCode": 1,
+ "output": "root.out"
+ },
+ "package_a": {
+ "args": "lint",
+ "cwd": "a",
+ "exitCode": 1,
+ "output": "a.out"
+ },
+ "package_b": {
+ "args": "lint",
+ "cwd": "b",
+ "exitCode": 1,
+ "output": "b.out"
+ },
+ "package_c": {
+ "args": "lint",
+ "cwd": "c",
+ "exitCode": 0,
+ "output": "Checked 1 file\n"
+ }
+ }
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/a.out b/tests/specs/lint/workspace_no_slow_types/a.out
new file mode 100644
index 000000000..12c6715be
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/a.out
@@ -0,0 +1,14 @@
+error[no-slow-types]: missing explicit return type in the public API
+ --> [WILDLINE]a.ts:1:17
+ |
+1 | export function noReturnType() {
+ | ^^^^^^^^^^^^ this function is missing an explicit return type
+ |
+ = hint: add an explicit return type to the function
+
+ info: all functions in the public API must have an explicit return type
+ docs: https://jsr.io/go/slow-type-missing-explicit-return-type
+
+
+Found 1 problem
+Checked 1 file
diff --git a/tests/specs/lint/workspace_no_slow_types/a/a.ts b/tests/specs/lint/workspace_no_slow_types/a/a.ts
new file mode 100644
index 000000000..6db944d6c
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/a/a.ts
@@ -0,0 +1,3 @@
+export function noReturnType() {
+ return Math.random();
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/a/deno.json b/tests/specs/lint/workspace_no_slow_types/a/deno.json
new file mode 100644
index 000000000..9547d1bd9
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/a/deno.json
@@ -0,0 +1,5 @@
+{
+ "name": "@scope/a",
+ "version": "1.0.0",
+ "exports": "./a.ts"
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/b.out b/tests/specs/lint/workspace_no_slow_types/b.out
new file mode 100644
index 000000000..e3e2d575d
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/b.out
@@ -0,0 +1,14 @@
+error[no-slow-types]: missing explicit return type in the public API
+ --> [WILDLINE]b.ts:7:17
+ |
+7 | export function doesNotHaveReturnType() {
+ | ^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
+ |
+ = hint: add an explicit return type to the function
+
+ info: all functions in the public API must have an explicit return type
+ docs: https://jsr.io/go/slow-type-missing-explicit-return-type
+
+
+Found 1 problem
+Checked 1 file
diff --git a/tests/specs/lint/workspace_no_slow_types/b/b.ts b/tests/specs/lint/workspace_no_slow_types/b/b.ts
new file mode 100644
index 000000000..05cb08628
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/b/b.ts
@@ -0,0 +1,9 @@
+import { noReturnType } from "@scope/a";
+
+export function hasReturnType(): number {
+ return noReturnType();
+}
+
+export function doesNotHaveReturnType() {
+ return noReturnType();
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/b/deno.json b/tests/specs/lint/workspace_no_slow_types/b/deno.json
new file mode 100644
index 000000000..a27c1e5cd
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/b/deno.json
@@ -0,0 +1,5 @@
+{
+ "name": "@scope/b",
+ "version": "1.0.0",
+ "exports": "./b.ts"
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/c/c.ts b/tests/specs/lint/workspace_no_slow_types/c/c.ts
new file mode 100644
index 000000000..3f5f46171
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/c/c.ts
@@ -0,0 +1,6 @@
+import { noReturnType } from "@scope/a";
+import { hasReturnType } from "@scope/b";
+
+export function myExport(): number {
+ return noReturnType() + hasReturnType();
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/c/deno.json b/tests/specs/lint/workspace_no_slow_types/c/deno.json
new file mode 100644
index 000000000..618250b98
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/c/deno.json
@@ -0,0 +1,5 @@
+{
+ "name": "@scope/c",
+ "version": "1.0.0",
+ "exports": "./c.ts"
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/deno.json b/tests/specs/lint/workspace_no_slow_types/deno.json
new file mode 100644
index 000000000..499731c1e
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/deno.json
@@ -0,0 +1,7 @@
+{
+ "workspace": [
+ "./a",
+ "./b",
+ "./c"
+ ]
+}
diff --git a/tests/specs/lint/workspace_no_slow_types/root.out b/tests/specs/lint/workspace_no_slow_types/root.out
new file mode 100644
index 000000000..50fda50c3
--- /dev/null
+++ b/tests/specs/lint/workspace_no_slow_types/root.out
@@ -0,0 +1,26 @@
+error[no-slow-types]: missing explicit return type in the public API
+ --> [WILDLINE]a.ts:1:17
+ |
+1 | export function noReturnType() {
+ | ^^^^^^^^^^^^ this function is missing an explicit return type
+ |
+ = hint: add an explicit return type to the function
+
+ info: all functions in the public API must have an explicit return type
+ docs: https://jsr.io/go/slow-type-missing-explicit-return-type
+
+
+error[no-slow-types]: missing explicit return type in the public API
+ --> [WILDLINE]b.ts:7:17
+ |
+7 | export function doesNotHaveReturnType() {
+ | ^^^^^^^^^^^^^^^^^^^^^ this function is missing an explicit return type
+ |
+ = hint: add an explicit return type to the function
+
+ info: all functions in the public API must have an explicit return type
+ docs: https://jsr.io/go/slow-type-missing-explicit-return-type
+
+
+Found 2 problems
+Checked 3 files