0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-15 01:57:09 -05:00
denoland-deno/cli/lsp
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
..
testing refactor: create deno_lib crate (#27673) 2025-01-15 09:35:46 -05:00
analysis.rs feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
cache.rs refactor: add WorkspaceFactory and ResolverFactory (#27766) 2025-01-23 18:52:55 -05:00
capabilities.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
client.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
code_lens.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
completions.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
config.rs feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
diagnostics.rs feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
documents.rs perf: node resolution cache (#27838) 2025-02-03 20:25:10 -05:00
jsr.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
language_server.rs Revert "fix(lsp): silence debug error for 'move to a new file' action (#27780)" (#27903) 2025-02-01 02:53:24 +00:00
logging.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
lsp_custom.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
mod.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
npm.rs refactor: add WorkspaceFactory and ResolverFactory (#27766) 2025-01-23 18:52:55 -05:00
parent_process_checker.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
path_to_regex.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
performance.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
README.md docs: fix broken deno manual link (#20667) 2023-09-25 14:09:27 +02:00
refactor.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
registries.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
repl.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
resolver.rs perf: node resolution cache (#27838) 2025-02-03 20:25:10 -05:00
search.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
semantic_tokens.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
text.rs refactor: extract out utf16 map from lsp to cli::util module (#27950) 2025-02-03 20:24:26 -05:00
tsc.rs perf: node resolution cache (#27838) 2025-02-03 20:25:10 -05:00
urls.rs refactor: use DataUrl from deno_media_type (#27783) 2025-01-22 20:35:16 +00:00

Deno Language Server

The Deno Language Server provides a server implementation of the Language Server Protocol which is specifically tailored to provide a Deno view of code. It is integrated into the command line and can be started via the lsp sub-command.

This documentation has been moved to the Deno manual.