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

454 commits

Author SHA1 Message Date
David Sherret
90edca21a2
fix: surface package.json location on dep parse failure (#26665)
Related: https://github.com/denoland/deno/issues/26653
2024-10-31 15:35:17 +00:00
Bartek Iwańczuk
484f8ca9c3
fix: provide hints in terminal errors for Node.js globals (#26610)
Add info/hint for terminal errors related to Node.js globals:
- __filename
- __dirname
- Buffer
- global
- setImmediate
- clearImmediate

Closes https://github.com/denoland/deno/issues/17494
2024-10-29 00:55:51 +01:00
David Sherret
0e641632c3
fix(check): expose more globals from @types/node (#26603)
Extracted out of https://github.com/denoland/deno/pull/26558

Closes https://github.com/denoland/deno/issues/26578
2024-10-28 17:43:41 -04:00
snek
4e38fbd0a3
fix: report exceptions from nextTick (#26579)
Fixes: https://github.com/denoland/deno/issues/24713
Fixes: https://github.com/denoland/deno/issues/25855
2024-10-28 18:16:43 +01:00
David Sherret
f61af864df
fix(compile): regression handling redirects (#26586)
Closes https://github.com/denoland/deno/issues/26583
2024-10-28 09:31:58 -04:00
Marvin Hagemeister
5389972ba5
fix(npm): match npm bearer token generation (#26544)
Spend some time stepping through the npm client code and noticed that
the bearer token was different from ours. They do some double encoding
and @dsherret helped me in matching the encoding behavior.

Fixes https://github.com/denoland/deno/issues/26033
2024-10-28 12:08:51 +01:00
Nathan Whitaker
ec968aa5ae
fix(install): cache json exports of JSR packages (#26552)
Fixes https://github.com/denoland/deno/issues/26509.

Ended up being a `deno_graph` bug causing the error to surface. This PR
updates `deno_graph` to pick up the fix and reverts the temporary
workaround that skipped JSON exports.
2024-10-25 20:19:03 +00:00
David Sherret
e70341e65e
fix(check): ignore resolving jsxImportSource when jsx is not used in graph (#26548) 2024-10-25 17:56:40 +00:00
David Sherret
eedf243b5e
perf(compile): pass module source data from binary directly to v8 (#26494)
This changes denort to pass a static reference of the moude source bytes found in the binary to v8 instead of copying it.
2024-10-24 19:48:48 +00:00
Marvin Hagemeister
5f0bb3c6f4
fix: .npmrc settings not being passed to install/add command (#26473)
We weren't passing the resolved npmrc settings to the install commands.
This lead us to always fall back to the default registry url instead of
using the one from npmrc.

Fixes https://github.com/denoland/deno/issues/26139
Fixes https://github.com/denoland/deno/issues/26033
Fixes https://github.com/denoland/deno/issues/25924
Fixes https://github.com/denoland/deno/issues/25822
Fixes https://github.com/denoland/deno/issues/26152

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-10-24 20:03:56 +02:00
Nathan Whitaker
7c57105cc4
fix(ext/node): only set our end of child process pipe to nonblocking mode (#26495)
Fixes playwright on linux, as reported in
https://github.com/denoland/deno/issues/16899#issuecomment-2378268454.

The issue was that we were opening the socket in nonblocking mode, which
meant that subprocesses trying to use it would get a `EWOULDBLOCK` error
(unexpectedly). The fix here is to only set nonblocking mode on our end
(which we need to use asynchronously)
2024-10-23 21:13:30 -07:00
Nathan Whitaker
6d587cbfc8
fix(install): cache all exports of JSR packages listed in deno.json (#26501)
Fixes #26498.

This was a sort of intentional decision originally, as I wanted to avoid
caching extra files that may not be needed. It seems like that behavior
is unintuitive, so I propose we cache all of the exports of listed jsr
packages when you run a bare `deno install`.
2024-10-23 20:12:52 -07:00
Nathan Whitaker
69e1d7a4ed
fix(install): cache type only module deps in deno install (#26497)
Fixes https://github.com/denoland/deno/issues/26180.
2024-10-23 15:01:45 -07:00
Nathan Whitaker
5e020ebc35
fix(check): support --frozen on deno check (#26479)
Fixes https://github.com/denoland/deno/issues/26391
2024-10-22 21:15:00 +00:00
Bartek Iwańczuk
28b5640657
refactor: add 'docs' suggestion (#26463)
Adds another kind to `FixSuggestionKind` specifically for links
documentation pages.
2024-10-22 22:22:26 +02:00
Bartek Iwańczuk
67280f8b55
fix(install): update lockfile when using package.json (#26458)
This commit makes sure that `deno add`, `deno install` and `deno remove`
update the lockfile if only `package.json` file is present.

Fixes https://github.com/denoland/deno/issues/26270
2024-10-22 01:08:45 +02:00
David Sherret
39fb55096e
fix(install): better json editing (#26450)
1. Respects the formatting of the file (ex. keeps four space indents or
tabs).
2. Handles editing of comments.
3. Handles trailing commas.
4. Code is easier to maintain.
2024-10-21 14:17:08 -04:00
Marvin Hagemeister
0e60bb9cf7
fix(info): resolve workspace member mappings (#26350)
This PR fixes the issue where mapped specifiers in a workspace member
would never be found. Only mapped paths from the workspace root would
resolve.

This was caused by always passing the workspace root url to the import
map resolver instead of the workspace member one.

Fixes https://github.com/denoland/deno/issues/26138
Fixes https://github.com/denoland/fresh/issues/2615

---------

Signed-off-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2024-10-18 21:45:05 +02:00
Marvin Hagemeister
4b99cde504
fix(npm): ensure scoped package name is encoded in URLs (#26390)
Fixes https://github.com/denoland/deno/issues/26385
2024-10-18 20:38:57 +02:00
Nathan Whitaker
50724d014a
fix(install): don't attempt to cache specifiers that point to directories (#26369)
Fixes https://github.com/denoland/deno/issues/26162
2024-10-17 22:25:22 +00:00
Marvin Hagemeister
e515f3dd0e
fix(add): exact version should not have range ^ specifier (#26302)
Fixes https://github.com/denoland/deno/issues/26299
2024-10-16 18:34:33 +02:00
Satya Rohith
2929d583d2
fix(cli): consolidate pkg parser for install & remove (#26298)
Closes https://github.com/denoland/deno/issues/26283
2024-10-16 09:20:41 +00:00
Bartek Iwańczuk
40b1c42138
fix: improve suggestions and hints when using CommonJS modules (#26287)
Ref https://github.com/denoland/deno/issues/26225
2024-10-15 23:25:24 +00:00
Bartek Iwańczuk
ee904ec06c
fix: add hint for missing document global in terminal error (#26218)
This came up on Discord as a question so I thought it's worth adding a
hint for this as it might be a common pitfall.

---------

Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
2024-10-15 21:51:39 +00:00
Nathan Whitaker
797405fc61
fix(add): create deno.json when running deno add jsr:<pkg> (#26275)
Fixes https://github.com/denoland/deno/issues/26119.

Originally I wanted to put them in package.json if there's no deno.json,
but on second thought it makes more sense to just create a deno.json
2024-10-15 16:38:42 +00:00
David Sherret
ae6a2b23ba
fix: do not panic running remote cjs module (#26259)
Instead error.
2024-10-15 03:57:31 +00:00
David Sherret
1a0cb5b531
feat(unstable): --unstable-detect-cjs for respecting explicit "type": "commonjs" (#26149)
When using the `--unstable-detect-cjs` flag or adding `"unstable":
["detect-cjs"]` to a deno.json, it will make a JS file CJS if the
closest package.json contains `"type": "commonjs"` and the file is not
an ESM module (no TLA, no `import.meta`, no `import`/`export`).
2024-10-14 20:48:39 -04:00
Mohammad Sulaiman
8dbe77dd29
fix(console/ext/repl): support using parseFloat() (#25900)
Fixes #21428

Co-authored-by: tannal <tannal2409@gmail.com>
2024-10-14 15:04:18 -07:00
David Sherret
c5449d71da
fix(install): support installing npm package with alias (#26246)
Just tried this out today and it wasn't properly implemented in
https://github.com/denoland/deno/pull/24156
2024-10-14 19:35:52 +00:00
Luca Casonato
3eda179220
feat(cli): improve deno info output for npm packages (#25906) 2024-10-14 14:29:50 +02:00
Nathan Whitaker
7a990d9d42
feat(npm): support --allow-scripts on deno run (and deno add, deno test, etc) (#26075)
Fixes https://github.com/denoland/deno/issues/25533. Fixes
https://github.com/denoland/deno/issues/25396.

Previously we only supported it on `deno install` and `deno cache`,
which is annoying if you're using `nodeModulesDir: auto`.

Also changes from printing output of lifecycle scripts directly to
capturing the output and only printing it on error.
2024-10-12 12:14:32 -07:00
Marvin Hagemeister
ccdbeb433b
fix(install): duplicate dependencies in package.json (#26128)
Fixes https://github.com/denoland/deno/issues/26120
2024-10-10 21:31:45 +02:00
David Sherret
66929de3ba
fix(unstable/worker): ensure import permissions are passed (#26101)
We only had integration tests for this and not an integration test.

Closes #26074
2024-10-10 14:01:42 +01:00
Satya Rohith
7b509e492e
tests: enable package_json_node_modules_none (#25825)
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-10-04 09:56:13 +00:00
David Sherret
edac916604
fix(install): surface package.json dependency errors (#26023) 2024-10-04 07:52:00 +00:00
David Sherret
b8a9a4a862
Revert "feat: warn when using --allow-run with no allow list" (#26021)
Although using `--allow-run` without an allow list gives basically no
security, I think we should remove this warning because it gets in the
way and the only way to disable it is via --quiet.
2024-10-04 08:16:35 +01:00
Satya Rohith
779a98cd39
tests: enable specs::run::package_json::invalid_value (#25826)
Towards https://github.com/denoland/deno/issues/25241

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-10-03 16:26:55 +00:00
Nathan Whitaker
275418473e
fix(install): store tags associated with package in node_modules dir (#26000)
Fixes #25998. Fixes https://github.com/denoland/deno/issues/25928.

Originally I was just going to make this an error message instead of a
panic, but once I got to a minimal repro I felt that this really should
work.

The panic occurs when you have `nodeModulesDir: manual` (or a
package.json present), and you have an npm package with a tag in your
deno.json (see the spec test that illustrates this).

This code path only actually executes when trying to choose an
appropriate package version from `node_modules/.deno`, so we should be
able to fix it by storing some extra data at install time.

The fix proposed here is to repurpose the `.initialized` file that we
store in `node_modules` to store the tags associated with a package.
Basically, if you have a version requirement with a tag (e.g.
`npm:chalk@latest`), when we set up the node_modules folder for that
package, we store the tag (`latest`) in `.initialized`. Then, when doing
BYONM resolution, if we have a version requirement with a tag, we read
that file and check if the tag is present.

The downside is that we do more work when setting up `node_modules`. We
_could_ do this only when BYONM is enabled, but that would have the
downside of needing to re-run `deno install` when you switch from auto
-> manual, though maybe that's not a big deal.
2024-10-02 17:16:46 -07:00
Nathan Whitaker
cb74975ab2
fix(install): compare versions directly to decide whether to create a child node_modules dir for a workspace member (#26001)
Fixes #25861.

Previously we were attempting to match the version requirement against
the version already present in `node_modules` root, and if they didn't
match we would create a node_modules dir in the workspace member's
directory with the dependency.

Aside from the fact that this caused the panic, on second thought it
just doesn't make sense in general. We shouldn't be semver matching, as
resolution has already occurred and decided what package versions are
required. Instead, we can just compare the versions directly.
2024-10-02 15:11:43 -07:00
David Sherret
cac28b5262
feat(byonm): support deno run npm:<package> when package is not in package.json (#25981)
Closes https://github.com/denoland/deno/issues/25905
2024-10-02 21:17:39 +01:00
Mohammad Sulaiman
3c193aef98
chore: deprecate check itests (#25963) 2024-10-02 09:22:35 +00:00
David Sherret
d116709d06
chore: remove unnecessary envs in spec tests (#25982) 2024-10-02 10:14:38 +01:00
Nayeem Rahman
3881b71734
feat(lsp): quick fix for @deno-types="npm:@types/*" (#25954) 2024-10-01 22:55:02 +01:00
David Sherret
4c8d57db03
BREAKING: rename "deps" remote cache folder to "remote" (#25969)
Closes https://github.com/denoland/deno/issues/25967
Closes #25968
2024-10-01 14:05:40 -04:00
David Sherret
d7b787792c
fix(info): error instead of panic for npm specifiers when using byonm (#25947) 2024-09-30 19:46:43 +00:00
Marvin Hagemeister
c5c1869992
fix: precompile preserve SVG camelCase attributes (#25945)
See https://github.com/denoland/deno_ast/pull/278

Fixes https://github.com/denoland/deno/issues/25810
2024-09-30 21:25:30 +02:00
David Sherret
a8d1ab5276
fix(flags): --allow-all should conflict with lower permissions (#25909)
Using `--allow-all` with other `--allow-x` permission flags should cause
an error since `--allow-all` is a superset of `--allow-x`.

Closes #25901
2024-09-27 16:49:43 +00:00
Luca Casonato
6f0fbceaf2
fix(lint): correctly handle old jsx in linter (#25902)
Previously the CLI was incorrectly reporting `React` as unused in a JSX
file that uses the "old" transform.

The LSP was already handling this correctly.
2024-09-27 14:14:17 +00:00
Bartek Iwańczuk
09a7cc4723
refactor(fmt): rewrite HTML syntax error handling (#25892) 2024-09-26 20:44:36 -04:00
David Sherret
7cccb7422b
fix(info): move "version" field to top of json output (#25890) 2024-09-26 15:57:12 -04:00
Nathan Whitaker
543c687c34
feat(install): warn repeatedly about not-run lifecycle scripts on explicit installs (#25878)
Currently we only warn once. With this PR, we continue to warn about
not-run scripts on explicit `deno install` (or cache). For `run` (or
other subcommands) we only warn the once, as we do currently.
2024-09-26 17:13:33 +00:00
Nathan Whitaker
13c53d9727
fix(installl): make bin entries executable even if not put in node_modules/.bin (#25873)
Fixes https://github.com/denoland/deno/issues/25862.

npm only makes bin entries executable if they get linked into `.bin`, as
we did before this PR. So this PR actually deviates from npm, because
it's the only reasonable way to fix this that I can think of.

---

The reason this was broken in moment is the following:

Moment has dependencies on two typescript versions: 1.8 and 3.1

If you have two packages with conflicting bin entries (i.e. two
typescript versions which both have a bin entry `tsc`), in npm it is
non-deterministic and undefined which one will end up in `.bin`.

npm, due to implementation differences, chooses to put typescript 1.8
into the `.bin` directory, and so `node_modules/typescript/bin/tsc` ends
up getting marked executable. We, however, choose typescript 3.2, and so
we end up making `node_modules/typescript3/bin/tsc` executable.

As part of its tests, moment executes `node_modules/typescript/bin/tsc`.
Because we didn't make it executable, this fails.

Since the conflict resolution is undefined in npm, instead of trying to
match it, I think it makes more sense to just make bin entries
executable even if they aren't chosen in the case of a conflict.
2024-09-26 09:36:25 -07:00
David Sherret
7437f9d944
fix(doc): surface graph errors as warnings (#25888) 2024-09-26 12:31:03 -04:00
Bartek Iwańczuk
5504acea67
feat: add --allow-import flag (#25469)
This replaces `--allow-net` for import permissions and makes the
security sandbox stricter by also checking permissions for statically
analyzable imports.

By default, this has a value of
`--allow-import=deno.land:443,jsr.io:443,esm.sh:443,raw.githubusercontent.com:443,gist.githubusercontent.com:443`,
but that can be overridden by providing a different set of hosts.

Additionally, when no value is provided, import permissions are inferred
from the CLI arguments so the following works because
`fresh.deno.dev:443` will be added to the list of allowed imports:

```ts
deno run -A -r https://fresh.deno.dev
```

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
2024-09-26 01:50:54 +00:00
Mohammad Sulaiman
c232ecc6af
chore: deprecate npm itests (#25804) 2024-09-25 18:46:18 +00:00
David Sherret
8cdb309ffd
fix(check): properly surface dependency errors in types file of js file (#25860)
We weren't surfacing dependency errors in types files of js files.
2024-09-25 09:04:57 -04:00
Nathan Whitaker
5c40b47629
fix(add/install): default to "latest" tag for npm packages in deno add npm:pkg (#25858)
Fixes #25813.

I initially tried doing this in `deno_semver`, where it's a cleaner
change, but that caused breakage in deno in places where we don't expect
a tag (see https://github.com/denoland/deno/issues/25857).

This does not fix wildcard requirements failing to choose pre-release
versions. That's a little more involved and I'll do a separate PR.
2024-09-25 01:10:01 +00:00
Bartek Iwańczuk
6c26c1ed96
feat(fmt): better error on malfored HTML files (#25853)
Improves syntax errors for HTML formatter.

`broken.html`

```html
<div class=container > content 
```

```
$ deno fmt broken.html
Error formatting: /Users/ib/dev/deno/tests/specs/fmt/html/broken.html
   syntax error 'expect close tag' at line 3, column 0
Checked 1 file
```

```
$ ./target/debug/deno fmt broken.html
Error formatting: /Users/ib/dev/deno/tests/specs/fmt/html/broken.html
   Syntax error (expect close tag) at file:///Users/ib/dev/deno/tests/specs/fmt/html/broken.html:3:0

Checked 1 file
```
2024-09-25 01:00:16 +00:00
David Sherret
c4f7b2ac00
fix(check): ignore noImplicitOverrides in remote modules (#25854) 2024-09-24 20:49:44 -04:00
Nathan Whitaker
36ebc03f17
fix(cli): Warn on not-run lifecycle scripts with global cache (#25786)
Refactors the lifecycle scripts code to extract out the common
functionality and then uses that to provide a warning in the global
resolver.

While ideally we would still support them with the global cache, for now
a warning is at least better than the status quo (where people are
unaware why their packages aren't working).
2024-09-24 19:23:57 +00:00
Bartek Iwańczuk
3242550f5f
fix(fmt): --check was broken for CSS, YAML and HTML (#25848)
`deno fmt --check` was broken for CSS, YAML and HTML files.

Before this PR, formatting any of these file types would return a
string, even though the contract in `cli/tools/fmt.rs` is to only return a
string if the formatting changed. This causes wrong flagging of these files
as being badly formatted even though diffs showed nothing (because
they were in fact formatted properly).

Closes https://github.com/denoland/deno/issues/25840
2024-09-24 15:54:48 +02:00
Nathan Whitaker
1e261c9756
fix: Update deno_npm to fix deno install with crossws (#25837)
Partially addresses https://github.com/denoland/deno/issues/25648.

This allows packages that use `crossws` to be installed with `deno
install`. `crossws` specifies an optional peer dependency on
`uWebSockets`, but `uWebSockets` is not on npm (it is used with `git:`
or `github:` specifiers). Previously we would error on this, now we
don't error on non-existent optional peer dependencies.
2024-09-24 02:12:48 +00:00
Bartek Iwańczuk
74e294c8c1
refactor: reenable more tests after DENO_FUTURE migration (#25752)
Rewrites and reenables following tests:
- `task::task_both_package_json_selected`
2024-09-24 03:33:03 +02:00
Óscar Otero
1287739ddf
feat(fmt): support vto and njk extensions (#25831)
Fixes #25802

markup_fmt plugin supports some HTML-like formats like Angular, Jinja,
Twig, Nunjucks or Vento, that are not supported by `deno fmt`. This PR
adds support for the extensions `njk` (Nunjucks) and `vto` (Vento).
Angular doesn't have a custom extension (it uses `html` afaik) and Jinja
and Twig are template engines written in Python and PHP respectively so
it doesn't make sense to be supported by Deno.
2024-09-23 14:27:58 -04:00
Bartek Iwańczuk
a7ac89935b
feat(fmt): stabilize CSS, HTML and YAML formatters (#25753)
This commits stabilizes CSS, HTML and YAML formatters
in `deno fmt`.

It is no longer required to use either of these flags:
- `--unstable-css`
- `--unstable-html`
- `--unstable-yaml`
Or these `unstable` options in the config file:
- `fmt-css`
- `fmt-html`
- `html-yaml`
2024-09-23 18:01:04 +02:00
Satya Rohith
cab3363026
tests: update specs::cache::package_json (#25827)
Towards https://github.com/denoland/deno/issues/25241
2024-09-23 20:17:43 +05:30
Satya Rohith
b1550842d9
tests: enable auto_discovered tests of run/no_deno_json (#25821)
Towards https://github.com/denoland/deno/issues/25241
2024-09-23 15:37:35 +02:00
Bartek Iwańczuk
08d3f17110
feat: make 'globalThis.location' a configurable property (#25812)
This commit changes `globalThis.location` property to be configurable
so that packages wanting to override it (or delete it) work properly.

Towards https://github.com/denoland/deno/issues/23882

This change makes reproduction from
https://github.com/denoland/deno/issues/23882#issuecomment-2340783437
pass properly.
2024-09-23 14:18:07 +02:00
Bartek Iwańczuk
ef3e4a8f74
feat: Show hints when using window global (#25805)
This commit adds better handling for terminal errors when
`window` global is used. This global is removed in Deno 2,
and while we have lints to help with that, an information and
hints are helpful to guide users to working code.

Ref https://github.com/denoland/deno/issues/25797
2024-09-23 00:05:42 +02:00
Nathan Whitaker
9be8dce0c7
fix(node): Include "node" condition during CJS re-export analysis (#25785)
Fixes #25777.

We were missing the "node" condition, so we were resolving to the wrong
conditional export, causing our analysis to be incorrect.
2024-09-21 16:10:38 -07:00
Satya Rohith
94bdebe399
refactor(tests): migrate npm itests to specs (#25764)
Towards https://github.com/denoland/deno/issues/25241
2024-09-20 22:38:32 +02:00
Bartek Iwańczuk
471a15ecff
test: make specs::test::doc_success less flaky (#25765)
Missed this line in https://github.com/denoland/deno/pull/25726
2024-09-20 13:14:02 +00:00
Yoshiya Hinosawa
66fb81ea85
fix(coverage): ignore urls from doc testing (#25736) 2024-09-20 15:04:22 +09:00
snek
a01dce3a25
fix: cjs resolution cases (#25739)
Fixes cjs modules being loaded as esm.
2024-09-19 21:10:34 -07:00
Nathan Whitaker
f1ba266613
fix(node): Don't error out if we fail to statically analyze CJS re-export (#25748)
Fixes rsbuild running in deno.

You can look at the test to see what was failing, the gist is that we
were trying to statically analyze the re-exports of a CJS script, and if
we couldn't find the source for the re-exported file we would fail.

Instead, we should just treat these as if they were too dynamic to
analyze, and let it fail (or succeed) at runtime. This aligns with
node's behavior.
2024-09-19 18:37:36 -07:00
Bartek Iwańczuk
d7aafda243
test: make specs::test::doc_success less flaky (#25726)
On Windows some of these steps were taking more than 1s
2024-09-19 13:47:52 +02:00
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
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
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
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
Luca Casonato
7533492a78
tests: fix upgrade canary test (#25706) 2024-09-18 13:43:50 +00:00
Luca Casonato
42e3a49cc7
tests: re-enable upgrade tests (#25680) 2024-09-18 14:08:21 +02: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
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
David Sherret
b0525edd6f
feat: warn when using --allow-run with no allow list (#25215) 2024-09-16 23:08:02 +00: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
HasanAlrimawi
e0b9c745c1
chore: deprecate test itests (#25512)
This PR is part of #22907

---------

Signed-off-by: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-09-16 19:38:40 +00:00
HasanAlrimawi
36a1a79f17
chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
Mohammad Sulaiman
acc32e1cee
chore: move info itests (#25659) 2024-09-16 17:08:00 +00:00
Bartek Iwańczuk
968f441da3
test: rewrite some ignored tests to spec tests (#25652)
Ref https://github.com/denoland/deno/issues/25241

Rewritten these tests:
- check::package_json_basic
- check::package_json_fail_check
- check::package_json_with_deno_json
- info::package_json_basic
- test::package_json_basic
- run::package_json_auto_discovered_for_npm_binary
- run::package_json_with_deno_json
2024-09-16 15:39:58 +02:00
Mohammad Sulaiman
eb8ee95f08
chore: deprecate node compat itests (#25573) 2024-09-16 09:53:20 +01:00
Asher Gomez
e4ea9be874
chore: cleanup remaining internals.future code (#25624) 2024-09-16 09:28:35 +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
Asher Gomez
394a620da3
chore: enable specs::run::workspaces::explicit_import_map test (#25611)
Towards #25241
2024-09-13 11:52:48 +02:00