This clears the diagnostics whenever a file is about to run. For
example, what could previously occur is an error and the diagnostics
would be leftover from the previous run.
Noticed that the LSP might panic during serialization when working on a
file with a syntax error.
This PR changes the serialization so that invalid nodes are simply
serialized to the invalid node `0`. The plugin code treats the node with
id `0` as an invalid node and will ignore it during visiting.
I'm not sure how to write a test for the LSP.
This PR fixes deviations in our AST format compared to TSEStree. They
are mostly a leftover for when I first started working on it and based
it off of babel instead.
One of the key changes why the changeset is a bit bigger is that
TSEStree uses `undefined` instead of `null` as the empty value for type
nodes. This is likely influenced by `tsc` which use `undefined`
everywhere. The rest of the nodes use `null` though. It's a little
weird, but for now it might be better to align.
(extracted from https://github.com/denoland/deno/pull/27977)
Not sure what our handling of unstable properties in `deno.json` is.
This PR adds it to the config schema.
---------
Signed-off-by: Marvin Hagemeister <marvinhagemeister50@gmail.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
https://nodejs.org/api/sqlite.html#databaseapplychangesetchangeset-options
```js
const sourceDb = new DatabaseSync(':memory:');
const targetDb = new DatabaseSync(':memory:');
sourceDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');
targetDb.exec('CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)');
const session = sourceDb.createSession();
const insert = sourceDb.prepare('INSERT INTO data (key, value) VALUES (?, ?)');
insert.run(1, 'hello');
insert.run(2, 'world');
const changeset = session.changeset();
targetDb.applyChangeset(changeset);
// Now that the changeset has been applied, targetDb contains the same data as sourceDb.
```
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>