summaryrefslogtreecommitdiff
path: root/tests/testdata/lint
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-02-19 10:28:41 -0500
committerGitHub <noreply@github.com>2024-02-19 15:28:41 +0000
commit66424032a2c78c6010c0a1a1b22a26d081166660 (patch)
tree610e95beba5685ef1ba322375bf31a3fd6c5a187 /tests/testdata/lint
parent2b279ad630651e973d5a31586f58809f005bc925 (diff)
feat(unstable/lint): no-slow-types for JSR packages (#22430)
1. Renames zap/fast-check to instead be a `no-slow-types` lint rule. 1. This lint rule is automatically run when doing `deno lint` for packages (deno.json files with a name, version, and exports field) 1. This lint rules still occurs on publish. It can be skipped by running with `--no-slow-types`
Diffstat (limited to 'tests/testdata/lint')
-rw-r--r--tests/testdata/lint/no_slow_types/a.ts3
-rw-r--r--tests/testdata/lint/no_slow_types/b.ts5
-rw-r--r--tests/testdata/lint/no_slow_types/c.ts4
-rw-r--r--tests/testdata/lint/no_slow_types/d.ts4
-rw-r--r--tests/testdata/lint/no_slow_types/deno.json8
-rw-r--r--tests/testdata/lint/no_slow_types/deno.non-package.json2
-rw-r--r--tests/testdata/lint/no_slow_types/no_slow_types.out35
-rw-r--r--tests/testdata/lint/no_slow_types/no_slow_types_entrypoint.out35
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/a/b.ts5
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/a/d.ts4
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/a/deno.json8
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/a/mod.ts3
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/b/deno.json5
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/b/mod.ts4
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/c/deno.json5
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/c/mod_c.ts4
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/deno.json7
-rw-r--r--tests/testdata/lint/no_slow_types_workspace/output.out46
18 files changed, 187 insertions, 0 deletions
diff --git a/tests/testdata/lint/no_slow_types/a.ts b/tests/testdata/lint/no_slow_types/a.ts
new file mode 100644
index 000000000..3b399665d
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types/a.ts
@@ -0,0 +1,3 @@
+export function add(a: number, b: number) {
+ return a + b;
+}
diff --git a/tests/testdata/lint/no_slow_types/b.ts b/tests/testdata/lint/no_slow_types/b.ts
new file mode 100644
index 000000000..b96a79489
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types/b.ts
@@ -0,0 +1,5 @@
+export function addB(a: number, b: number) {
+ return a + b;
+}
+
+export * from "./d.ts";
diff --git a/tests/testdata/lint/no_slow_types/c.ts b/tests/testdata/lint/no_slow_types/c.ts
new file mode 100644
index 000000000..517aa3d21
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types/c.ts
@@ -0,0 +1,4 @@
+// this one won't error because it's not an export
+export function addC(a: number, b: number) {
+ return a + b;
+}
diff --git a/tests/testdata/lint/no_slow_types/d.ts b/tests/testdata/lint/no_slow_types/d.ts
new file mode 100644
index 000000000..babe9d81b
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types/d.ts
@@ -0,0 +1,4 @@
+// this one is re-exported via b.ts
+export function addD(a: number, b: number) {
+ return a + b;
+}
diff --git a/tests/testdata/lint/no_slow_types/deno.json b/tests/testdata/lint/no_slow_types/deno.json
new file mode 100644
index 000000000..2fd0af5f0
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types/deno.json
@@ -0,0 +1,8 @@
+{
+ "name": "@pkg/pkg",
+ "version": "1.0.0",
+ "exports": {
+ "./a": "./a.ts",
+ "./b": "./b.ts"
+ }
+}
diff --git a/tests/testdata/lint/no_slow_types/deno.non-package.json b/tests/testdata/lint/no_slow_types/deno.non-package.json
new file mode 100644
index 000000000..2c63c0851
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types/deno.non-package.json
@@ -0,0 +1,2 @@
+{
+}
diff --git a/tests/testdata/lint/no_slow_types/no_slow_types.out b/tests/testdata/lint/no_slow_types/no_slow_types.out
new file mode 100644
index 000000000..5828906e7
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types/no_slow_types.out
@@ -0,0 +1,35 @@
+error[no-slow-types]: missing explicit return type in the public API
+ --> [WILDCARD]a.ts:1:17
+ |
+1 | export function add(a: number, b: number) {
+ | ^^^ 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
+ --> [WILDCARD]b.ts:1:17
+ |
+1 | export function addB(a: number, b: number) {
+ | ^^^^ 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
+ --> [WILDCARD]d.ts:2:17
+ |
+2 | export function addD(a: number, b: number) {
+ | ^^^^ 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 3 problems
+Checked 4 files
diff --git a/tests/testdata/lint/no_slow_types/no_slow_types_entrypoint.out b/tests/testdata/lint/no_slow_types/no_slow_types_entrypoint.out
new file mode 100644
index 000000000..b8c1013bf
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types/no_slow_types_entrypoint.out
@@ -0,0 +1,35 @@
+error[no-slow-types]: missing explicit return type in the public API
+ --> [WILDCARD]a.ts:1:17
+ |
+1 | export function add(a: number, b: number) {
+ | ^^^ 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
+ --> [WILDCARD]b.ts:1:17
+ |
+1 | export function addB(a: number, b: number) {
+ | ^^^^ 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
+ --> [WILDCARD]d.ts:2:17
+ |
+2 | export function addD(a: number, b: number) {
+ | ^^^^ 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 3 problems
+Checked 1 file
diff --git a/tests/testdata/lint/no_slow_types_workspace/a/b.ts b/tests/testdata/lint/no_slow_types_workspace/a/b.ts
new file mode 100644
index 000000000..b96a79489
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/a/b.ts
@@ -0,0 +1,5 @@
+export function addB(a: number, b: number) {
+ return a + b;
+}
+
+export * from "./d.ts";
diff --git a/tests/testdata/lint/no_slow_types_workspace/a/d.ts b/tests/testdata/lint/no_slow_types_workspace/a/d.ts
new file mode 100644
index 000000000..babe9d81b
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/a/d.ts
@@ -0,0 +1,4 @@
+// this one is re-exported via b.ts
+export function addD(a: number, b: number) {
+ return a + b;
+}
diff --git a/tests/testdata/lint/no_slow_types_workspace/a/deno.json b/tests/testdata/lint/no_slow_types_workspace/a/deno.json
new file mode 100644
index 000000000..5a971cd85
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/a/deno.json
@@ -0,0 +1,8 @@
+{
+ "name": "@pkg/a",
+ "version": "1.0.0",
+ "exports": {
+ "./a": "./mod.ts",
+ "./b": "./b.ts"
+ }
+}
diff --git a/tests/testdata/lint/no_slow_types_workspace/a/mod.ts b/tests/testdata/lint/no_slow_types_workspace/a/mod.ts
new file mode 100644
index 000000000..3b399665d
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/a/mod.ts
@@ -0,0 +1,3 @@
+export function add(a: number, b: number) {
+ return a + b;
+}
diff --git a/tests/testdata/lint/no_slow_types_workspace/b/deno.json b/tests/testdata/lint/no_slow_types_workspace/b/deno.json
new file mode 100644
index 000000000..c95aeb029
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/b/deno.json
@@ -0,0 +1,5 @@
+{
+ "name": "@pkg/b",
+ "version": "1.0.0",
+ "exports": "./mod.ts"
+}
diff --git a/tests/testdata/lint/no_slow_types_workspace/b/mod.ts b/tests/testdata/lint/no_slow_types_workspace/b/mod.ts
new file mode 100644
index 000000000..fa1c068de
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/b/mod.ts
@@ -0,0 +1,4 @@
+// ok
+export function addB(a: number, b: number): number {
+ return a + b;
+}
diff --git a/tests/testdata/lint/no_slow_types_workspace/c/deno.json b/tests/testdata/lint/no_slow_types_workspace/c/deno.json
new file mode 100644
index 000000000..36d6e2e67
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/c/deno.json
@@ -0,0 +1,5 @@
+{
+ "name": "@pkg/c",
+ "version": "1.0.0",
+ "exports": "./mod_c.ts"
+}
diff --git a/tests/testdata/lint/no_slow_types_workspace/c/mod_c.ts b/tests/testdata/lint/no_slow_types_workspace/c/mod_c.ts
new file mode 100644
index 000000000..632a90b65
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/c/mod_c.ts
@@ -0,0 +1,4 @@
+// not ok
+export function addC(a: number, b: number) {
+ return a + b;
+}
diff --git a/tests/testdata/lint/no_slow_types_workspace/deno.json b/tests/testdata/lint/no_slow_types_workspace/deno.json
new file mode 100644
index 000000000..e3dd981e5
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/deno.json
@@ -0,0 +1,7 @@
+{
+ "workspaces": [
+ "./a",
+ "./b",
+ "./c"
+ ]
+}
diff --git a/tests/testdata/lint/no_slow_types_workspace/output.out b/tests/testdata/lint/no_slow_types_workspace/output.out
new file mode 100644
index 000000000..05f54099b
--- /dev/null
+++ b/tests/testdata/lint/no_slow_types_workspace/output.out
@@ -0,0 +1,46 @@
+error[no-slow-types]: missing explicit return type in the public API
+ --> [WILDCARD]b.ts:1:17
+ |
+1 | export function addB(a: number, b: number) {
+ | ^^^^ 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
+ --> [WILDCARD]d.ts:2:17
+ |
+2 | export function addD(a: number, b: number) {
+ | ^^^^ 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
+ --> [WILDCARD]mod.ts:1:17
+ |
+1 | export function add(a: number, b: number) {
+ | ^^^ 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
+ --> [WILDCARD]mod_c.ts:2:17
+ |
+2 | export function addC(a: number, b: number) {
+ | ^^^^ 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 4 problems
+Checked 5 files