This commit adds an unstable lint plugin API.
Plugins are specified in the `deno.json` file under
`lint.plugins` option like so:
```
{
"lint": {
"plugins": [
"./plugins/my-plugin.ts",
"jsr:@deno/lint-plugin1",
"npm:@deno/lint-plugin2"
]
}
}
```
The API is considered unstable and might be subject
to changes in the future.
Plugin API was modelled after ESLint API for the
most part, but there are no guarantees for compatibility.
The AST format exposed to plugins is closely modelled
after the AST that `typescript-eslint` uses.
Lint plugins use the visitor pattern and can add
diagnostics like so:
```
export default {
name: "lint-plugin",
rules: {
"plugin-rule": {
create(context) {
return {
Identifier(node) {
if (node.name === "a") {
context.report({
node,
message: "should be b",
fix(fixer) {
return fixer.replaceText(node, "_b");
},
});
}
},
};
},
},
},
} satisfies Deno.lint.Plugin;
```
Besides reporting errors (diagnostics) plugins can provide
automatic fixes that use text replacement to apply changes.
---------
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
Co-authored-by: David Sherret <dsherret@gmail.com>
interactively select which packages to upgrade. a future improvement
could be to add a way to select the version as well, though not sure how
valuable that would be.
This PR adds the `--permit-no-files` cli options to the `bench`
subcommand. This will cause `deno bench --permit-no-files` to not return
an error when no bench files where found.
Implements the `readOnly` option for `DatabaseSync`.
Permissions:
`--allow-read=test.db --allow-write=test.db` => all works
`--allow-read=test.db` => only `readOnly` dbs work, cannot create new db
Shows directory import and missing extension suggestions in error
messages similar but not exactly to node.
Closes #26802
Co-authored-by: Hajime-san <Hajime-san@users.noreply.github.com>
Fixes `gcp-metadata@6.1.1`
```
% deno eval "import 'npm:gcp-metadata@6.1.1'" # main
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'GOOGLE_SDK_NODE_LOGGING')
at Object.log (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/google-logging-utils/0.0.2/build/src/logging-utils.js:356:36)
at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:52:20)
at Object.<anonymous> (file:///Users/divy/Library/Caches/deno/npm/registry.npmjs.org/gcp-metadata/6.1.1/build/src/index.js:409:4)
at Module._compile (node:module:745:34)
at loadMaybeCjs (node:module:770:10)
at Object.Module._extensions..js (node:module:755:12)
at Module.load (node:module:662:32)
at Function.Module._load (node:module:534:12)
at Module.require (node:module:681:19)
at require (node:module:812:16)
% target/debug/deno eval "import 'npm:gcp-metadata@6.1.1'" # this PR
```
---------
Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
This is the release commit being forwarded back to main for 2.1.9
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This is the release commit being forwarded back to main for 2.1.8
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This PR adds support for passing wildcard tasks. All matched tasks are
sorted in case they have dependencies. Tasks already in the dependency
tree will be pruned so that every task only runs once.
```json
{
"tasks": {
"foo-1": "echo 'foo-1'",
"foo-2": "echo 'foo-2'"
}
}
```
```sh
$ deno task "foo-*"
Task foo-1 echo 'foo-1'
foo-1
Task foo-2 echo 'foo-2'
foo-2
```
The changes in the PR look a little bigger than they really are due to
formatting. For the most part, I've only needed to hoist up the task
matching logic.
Closes https://github.com/denoland/deno/issues/26944
Closes https://github.com/denoland/deno/issues/21530
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This makes it so imports of ambient modules (e.g. `$app/environment` in
svelte, any virtual module in vite, or other module provided by a
bundler) don't error in the LSP.
The way this works is that when we request diagnostics from TSC, we also
respond with the list of ambient modules. Then, in the diagnostics code,
we save diagnostics (produced by deno) that may be invalidated as an
ambient module and wait to publish the diagnostics until we've received
the ambient modules from TSC.
The actual ambient modules you get from TSC can contain globs, e.g.
`*.css`. So when we get new ambient modules, we compile them all into a
regex and check erroring imports against that regex. Ambient modules
should change rarely, so in most cases we should be using a pre-compiled
regex, which executes in linear time (wrt the specifier length).
TODO:
- Ideally we should only publish once, right now we publish with the
filtered specifiers and then the TSC ones
- deno check (#27633)
Initial implementation of WebTransport client and server!
This is very unstable because the interface should eventually shift to
use hyper (h3 is on the [2025
roadmap](https://hyper.rs/contrib/roadmap/)) instead of manually messing
with the the protocol, which will enable integration with
Deno.serveHttp/etc and allow WebTransport over h2. This will also let us
expose multiplexing.
WebTransport stats will be a followup due to their complexity.
Fixes: https://github.com/denoland/deno/issues/9017
1. Allows resolving to `.ts` files for type checking.
2. Probes for `.ts` files to use for type checking.
To emphasize, this is only for type checking.
Adds references and examples to the documentation of the URL properties
which surface here:
https://docs.deno.com/api/web/~/URL✅ `./tools/lint.js`
✅ `./tools/format.js`
---------
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>