0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-15 01:57:09 -05:00
denoland-deno/cli/util
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
..
progress_bar chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
sync refactor(npm): split some resolution from installation (#27595) 2025-01-08 23:46:37 +00:00
v8 chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
archive.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
collections.rs fix(check): compiler options from workspace members (#27785) 2025-01-28 10:49:58 -05:00
console.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
diff.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
display.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
draw_thread.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
extract.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
file_watcher.rs refactor: move denort to separate crate (#27688) 2025-01-17 20:39:29 +00:00
fs.rs refactor: update deno_core for error refactor (#26867) 2025-01-08 14:52:32 -08:00
mod.rs fix(check): compiler options from workspace members (#27785) 2025-01-28 10:49:58 -05:00
path.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
retry.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
text_encoding.rs feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
unix.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00
v8.rs refactor: move denort to separate crate (#27688) 2025-01-17 20:39:29 +00:00
windows.rs chore: Happy New Year 2025 (#27509) 2024-12-31 19:12:39 +00:00