1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00
Commit graph

6694 commits

Author SHA1 Message Date
Leo Kettmeir
bb45446fa7
fix: don't include extensionless files in file collection for lint & fmt by default (#25721)
When using the `ext` flag, it will still attempt formatting them with
the provided extension
2024-09-19 11:25:48 +02:00
Yusuke Tanaka
0ea71abdef
fix(cli): handle edge cases around exports in doc tests and default export (#25720)
This commit fixes issues with the pseudo test file generation logic,
namely:

- `export`s declared in snippets
- auto import insertion for `default export`

## Case 1: `export`s declared in snippets

In the previous implementation, `export`s declared in snippets were
moved to the top level of the module in the generated pseudo test file.
This is required because `export` must be at the top level.

This becomes a problem if such a `export` has a body, containing a
reference to a local variable. Suppose we extract this snippet from
JSDoc:

```ts
const logger = createLogger("my-awesome-module");

export function sum(a: number, b: number): number {
  logger.debug("sum called");
  return a + b;
}
```

This gets converted into the following invalid code (note that `export
function sum` is moved to the top level, but its body references
`logger` variable which can't be referenced from here):

```ts
export function sum(a: number, b: number): number {
  logger.debug("sum called");
  return a + b;
}

Deno.test("./base.ts$1-7.ts", async () => {
  const logger = createLogger("my-awesome-module");
});
```

To resolve this issue, this commit adds a logic to remove the `export`
keyword, allowing the exported items to stay in the `Deno.test` block
scope, like so:

```ts
Deno.test("./base.ts$1-7.ts", async () => {
  const logger = createLogger("my-awesome-module");

  function sum(a: number, b: number): number {
    logger.debug("sum called");
    return a + b;
  }
});
```

## Case 2: default export

Previously `default export foo` was not captured by the export
collector, so auto import insertion didn't work for this case. To put it
concretely, the following code snippet didn't work when run with `deno
test --doc` because `import foo from "file:///path/to/mod.ts"` didn't
get inserted automatically:

```ts
/**
 * ```ts
 * console.log(foo);
 * ```
 * 
 * @module
 */

const foo = 42;
export default foo;
```

This commit fixes this issue and the above example works fine.

---

Fixes #25718
2024-09-19 00:19:40 -07:00
Bartek Iwańczuk
c3bc692842
v2.0.0-rc.3 (#25704) 2024-09-18 23:21:45 +02:00
Marvin Hagemeister
28dd928962
fix: update nodeModulesDir config JSON schema (#25653)
Ref https://github.com/denoland/deno/issues/25380
2024-09-18 22:38:09 +02:00
Asher Gomez
5057f58145
feat: suggest deno install --entrypoint instead of deno cache (#25228)
Hides `deno cache` from `--help` output.

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-09-18 19:55:50 +00:00
Leo Kettmeir
a1d0a427e8
feat: default to TS for file extension and support ext flag in more scenarios (#25472)
Closes #11220
Currently does lint, fmt, and repl
2024-09-18 21:15:13 +02:00
Bartek Iwańczuk
5b14c71daf
feat: improve warnings for deprecations and lifecycle script for npm packages (#25694)
This commit improves warning messages for deprecated npm packages
and packages that rely on lifecycle script.
2024-09-18 19:04:25 +00:00
Divy Srivastava
fd860260ad
feat(lint): add no-process-global lint rule (#25709)
Closes https://github.com/denoland/deno/issues/25679
2024-09-18 20:50:42 +02:00
Marvin Hagemeister
f347e779e0
fix: error on unsupported compiler options (#25714)
Update the config schema to error when adding unsupported
`compilerOptions`.

Fixes https://github.com/denoland/deno/issues/25696
2024-09-18 20:49:16 +02:00
Leo Kettmeir
ec86089c4e
feat: require jsr prefix for deno install and deno add (#25698) 2024-09-18 20:38:22 +02:00
Leo Kettmeir
c90b074579
fix(flags): don't treat empty run command as task subcommand (#25708) 2024-09-18 20:36:37 +02:00
HasanAlrimawi
49a0b7ab93
fix: remove --allow-run warning when using deno without args or subcommand (#25684)
Closes #25676 

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-09-18 17:05:11 +02:00
David Sherret
3dd83fdbdb
Revert "feat(fmt): sort type-only named import/exports last" (#25705)
Reverts #25690

This was not an issue with the ts compiler anymore. Discussion here:
https://github.com/dprint/dprint-plugin-typescript/pull/664#issuecomment-2357000053
2024-09-18 13:54:52 +00:00
Yazan AbdAl-Rahman
bed46474b2
fix: do not panic running invalid file specifier (#25530)
Co-authored-by: Bedis Nbiba <bedisnbiba@gmail.com>
2024-09-18 14:51:39 +01:00
Bartek Iwańczuk
48ea4e3c92
feat(check): turn on noImplicitOverride (#25695)
Closes https://github.com/denoland/deno/issues/11836

Ref https://github.com/denoland/deno/issues/25162
2024-09-18 14:49:30 +01:00
Yusuke Tanaka
f88a9e7467
fix(dts): stabilize fetch declaration for use with Deno.HttpClient (#25683)
This commit stabilizes the `fetch` function declaration for use with
`Deno.HttpClient` and moves it from `lib.deno.unstable.d.ts` to
`lib.deno.shared_globals.d.ts`.

`Deno.HttpClient` was stabilized in #25569, but the associated override
declaration for `fetch` is still marked as experimental. This should
also be stabilized now and moved to a different d.ts file.
2024-09-17 23:38:21 -07:00
Yusuke Tanaka
d5c00ef50e
feat(cli): evaluate code snippets in JSDoc and markdown (#25220)
This commit lets `deno test --doc` command actually evaluate code snippets in
JSDoc and markdown files.

## How it works

1. Extract code snippets from JSDoc or code fences
2. Convert them into pseudo files by wrapping them in `Deno.test(...)`
3. Register the pseudo files as in-memory files
4. Run type-check and evaluation

We apply some magic at the step 2 - let's say we have the following file named
`mod.ts` as an input:

````ts
/**
 * ```ts
 * import { assertEquals } from "jsr:@std/assert/equals";
 *
 * assertEquals(add(1, 2), 3);
 * ```
 */
export function add(a: number, b: number) {
  return a + b;
}
````

This is virtually transformed into:

```ts
import { assertEquals } from "jsr:@std/assert/equals";
import { add } from "files:///path/to/mod.ts";

Deno.test("mod.ts$2-7.ts", async () => {
  assertEquals(add(1, 2), 3);
});
```

Note that a new import statement is inserted here to make `add` function
available. In a nutshell, all items exported from `mod.ts` become available in
the generated pseudo file with this automatic import insertion.

The intention behind this design is that, from library user's standpoint, it
should be very obvious that this `add` function is what this example code is
attached to. Also, if there is an explicit import statement like
`import { add } from "./mod.ts"`, this import path `./mod.ts` is not helpful for
doc readers because they will need to import it in a different way.

The automatic import insertion has some edge cases, in particular where there is
a local variable in a snippet with the same name as one of the exported items.
This case is addressed by employing swc's scope analysis (see test cases for
more details).

## "type-checking only" mode stays around

This change will likely impact a lot of existing doc tests in the ecosystem
because some doc tests rely on the fact that they are not evaluated - some cause
side effects if executed, some throw errors at runtime although they do pass the
type check, etc. To help those tests gradually transition to the ones runnable
with the new `deno test --doc`, we will keep providing the ability to run
type-checking only via `deno check --doc`. Additionally there is a `--doc-only`
option added to the `check` subcommand too, which is useful when you want to
type-check on code snippets in markdown files, as normal `deno check` command
doesn't accept markdown.

## Demo

https://github.com/user-attachments/assets/47e9af73-d16e-472d-b09e-1853b9e8f5ce

---

Closes #4716
2024-09-17 21:35:48 -07:00
Asher Gomez
3731591762
chore: bump deno_lint to 0.66.0 (#25697) 2024-09-18 01:48:37 +00:00
Bartek Iwańczuk
a7d67e3a7a
feat: update warning message for --allow-run with no list (#25693)
Ref https://github.com/denoland/deno/pull/25215#discussion_r1762064605
2024-09-18 00:32:52 +02:00
Nayeem Rahman
f360cae9dd
fix(lsp): properly resolve jsxImportSource for caching (#25688) 2024-09-17 18:29:19 +01:00
Nayeem Rahman
d4a06251c5
feat(lsp): auto-import types with 'import type' (#25662) 2024-09-17 18:28:51 +01:00
David Sherret
a14e9f55b4
feat(fmt): sort type-only named import/exports last (#25690)
Closes #22583
2024-09-17 18:26:23 +01:00
Bartek Iwańczuk
aaf2bf4bfb
chore: upgrade deno_core (#25674)
No functional changes, just removes dead code.
2024-09-17 01:13:34 +00:00
Asher Gomez
01b5dfd9ea
chore: remove warnOnDeprecatedApi() (#25673) 2024-09-16 23:43:36 +00:00
David Sherret
b0525edd6f
feat: warn when using --allow-run with no allow list (#25215) 2024-09-16 23:08:02 +00:00
Asher Gomez
51d926ac30
chore(fs): undeprecate Deno.FsWatcher.prototype.return() (#25623) 2024-09-17 07:57:53 +10:00
David Sherret
8fe90d2861
fix(npm): better error handling for remote npm deps (#25670)
* https://github.com/denoland/deno_npm/pull/68
2024-09-16 21:23:40 +00:00
David Sherret
62e952559f
refactor(permissions): split up Descriptor into Allow, Deny, and Query (#25508)
This makes the permission system more versatile.
2024-09-16 21:39:37 +01:00
Luca Casonato
8fa92228bb
fix(types): simplify mtls related types (#25658)
Instead of two overloads for `Deno.connectTls` and
`Deno.createHttpClient`, there is now just one.
2024-09-16 14:35:55 +02:00
Aapo Alasuutari
f8547e2617
BREAKING(ext/ffi): remove deprecated UnsafeFnPointer constructor type with untyped Deno.PointerObject parameter (#25577) 2024-09-16 22:08:36 +10:00
Divy Srivastava
a666c8c9f9
fix(cli): deno task exit with status 0 (#25637)
Fixes https://github.com/denoland/deno/issues/25632

Exit code 1 indiciates some sort of failure but `deno task` (without
arguments) is used to list available commands.

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
2024-09-15 11:29:24 +05:30
David Sherret
af2d992ecd
feat: TypeScript 5.6 and npm:@types/node@22 (#25614) 2024-09-14 11:58:47 +01:00
David Sherret
1270d9bc93
fix(check): move is cjs check from resolving to loading (#25597)
This is required to do when loading because TypeScript handles and
resolves `/// <reference path="..." />` internally.
2024-09-13 14:36:26 +01:00
Leo Kettmeir
f2b53d42ac
feat(flags): support user provided args in repl subcommand (#25605)
closes https://github.com/denoland/deno/issues/11547
2024-09-13 05:17:46 -07:00
Nathan Whitaker
7477c2d706
feat(serve): Support second parameter in deno serve (#25606)
Closes #24099
2024-09-12 23:32:28 +00:00
Luca Casonato
018329a4d3
fix: no cmd prefix in help output go links (#25459) 2024-09-12 22:44:43 +00:00
David Sherret
c9c2531ff0
feat(upgrade): support LTS release channel (#25123)
Signed-off-by: David Sherret <dsherret@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-09-12 23:52:39 +02:00
Asher Gomez
0a4a8c730b
BREAKING(io): remove Deno.Seeker[Sync] (#25551)
Towards #22079

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-09-12 13:07:16 +00:00
Asher Gomez
9e8f84214f
refactor: cleanup unstable checks for WebGPU, FFI and FS APIs (#25586)
Continuation of work in #25488.

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-09-12 12:27:16 +00:00
Bartek Iwańczuk
57556ade8c
v2.0.0-rc.2 (#25583) 2024-09-12 03:20:45 +02:00
Victor Turansky
025e4bdaac
fix(ext/webgpu): sync category comment (#25580)
Signed-off-by: Victor Turansky <victor.turansky@gmail.com>
2024-09-12 10:59:05 +10:00
Asher Gomez
8476bbff9a
feat: stabilize Deno.createHttpClient() (#25569)
Closes #25518
2024-09-12 10:46:48 +10:00
Asher Gomez
5e0b2aa473
chore: remove prevent_v8_code_cache from CliModuleLoaderInner (#25566) 2024-09-11 19:06:11 +00:00
Bartek Iwańczuk
c64aa50c0e
feat(upgrade): better error message on failure (#25503)
Co-authored-by: crowlkats <crowlkats@toaxl.com>
2024-09-11 17:19:45 +02:00
Nayeem Rahman
ad30703e8e
fix(lsp): encode url parts before parsing as uri (#25509) 2024-09-11 11:11:39 +01:00
Nayeem Rahman
f959297dcd
feat(lsp): unstable setting as list (#25552) 2024-09-11 00:20:03 +01:00
Asher Gomez
ace1202227
BREAKING(net): remove Deno.ConnectTlsOptions.{certChain,certFile,privateKey} and Deno.ListenTlsOptions.certChain,certFile,keyFile} (#25525)
Towards #22079
2024-09-10 21:55:42 +00:00
Kenta Moriuchi
e522f4b65a
BREAKING(temporal/unstable): Remove obsoleted Temporal APIs part 2 (#25505)
Mainly I removed `Temporal.Calendar` and `Temporal.TimeZone` and
replaced them to APIs that handle calendar and timezone as strings.
https://github.com/tc39/proposal-temporal/pull/2925

Related #24836
2024-09-10 21:36:43 +00:00
Asher Gomez
a69b1e699e
BREAKING(fs): remove Deno.FsFile.prototype.rid (#25499)
Towards #22079

---------

Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-09-11 07:19:34 +10:00
Luca Casonato
7bfcb4dd10
feat(cli): use NotCapable error for permission errors (#25431)
Closes #7394

---------

Co-authored-by: snek <snek@deno.com>
2024-09-10 11:12:24 -07:00