0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-12 16:59:32 -05:00
denoland-deno/runtime/js
Bartek Iwańczuk f08ca6414b
feat(lint): add JavaScript plugin support (#27203)
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>
2025-02-05 16:59:24 +01:00
..
01_errors.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
01_version.ts chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
06_util.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
10_permissions.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
11_workers.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
40_fs_events.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
40_tty.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
41_prompt.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
90_deno_ns.js feat: implement process.cpuUsage (Deno.cpuUsage) (#27217) 2025-01-30 17:23:05 +05:30
98_global_scope_shared.js feat(unstable): WebTransport (#27431) 2025-01-29 14:39:12 +00:00
98_global_scope_window.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
98_global_scope_worker.js chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
99_main.js feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
README.md chore: fix outdated note in runtime/js/README.md (#23673) 2024-05-05 01:30:53 +00:00

Runtime JavaScript Code

This directory contains Deno runtime code written in plain JavaScript.

Each file is an ES module and is prefixed with a number, telling in which order scripts should be loaded into V8 isolate.

Deno Web APIs

This directory facilities Web APIs that are available in Deno.

Please note, that some implementations might not be completely aligned with specification.

Some Web APIs are using ops under the hood, eg. console, performance.

Implemented Web APIs