0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-20 20:33:42 -05:00
denoland-deno/tests/specs/lint
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
..
all chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
bom fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
compact chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
default_ts fix: don't include extensionless files in file collection for lint & fmt by default (#25721) 2024-09-19 11:25:48 +02:00
gitignore fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
glob chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
ignore chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
ignore_unexplicit_files chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
json feat(lint): Add checked files list to the JSON output(#26936) 2024-11-20 20:59:43 +01:00
jsr_pkg_no_version fix(lint): support linting jsr pkg without version field (#25230) 2024-08-30 18:05:44 -04:00
jsr_tag fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
jsx fix(check): compiler options from workspace members (#27785) 2025-01-28 10:49:58 -05:00
lint_fix feat(lint): deno lint --fix and lsp quick fixes (#22615) 2024-03-21 14:18:59 -07:00
lint_plugin feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
lint_plugin_fix_error feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
lint_plugin_infinite_edits feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
lint_plugin_utf16 feat(lint): add JavaScript plugin support (#27203) 2025-02-05 16:59:24 +01:00
no_slow_types chore(lint): add .out file reference checker (#27078) 2024-11-26 20:53:20 -08:00
no_slow_types_workspace feat: npm workspace and better Deno workspace support (#24334) 2024-07-04 00:54:33 +00:00
node_globals_no_duplicate_imports fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
opt_out_top_level_exclude_via_lint_inexclude fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
quiet fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
rules chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
rules_quiet chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
sloppy_imports_dts fix(unstable): move sloppy-import warnings to lint rule (#24710) 2024-07-25 09:07:59 -04:00
sloppy_imports_no_incremental_cache fix(unstable): move sloppy-import warnings to lint rule (#24710) 2024-07-25 09:07:59 -04:00
stdin fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
stdin_json feat(lint): Add checked files list to the JSON output(#26936) 2024-11-20 20:59:43 +01:00
syntax_error_reporting fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
with_config fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
with_config_and_flags fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
with_config_without_args fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
with_glob_config fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
with_glob_config_and_flags fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
with_malformed_config refactor: deno_config 0.45 (#27660) 2025-01-14 13:00:31 +01:00
with_malformed_config2 refactor: deno_config 0.45 (#27660) 2025-01-14 13:00:31 +01:00
with_report_config chore: deprecate lint itests (#25655) 2024-09-16 17:45:25 +00:00
with_report_config_override feat(lint): Add checked files list to the JSON output(#26936) 2024-11-20 20:59:43 +01:00
workspace fix(lint): update jsx/react related rules and names (#27836) 2025-01-27 16:54:35 +00:00
workspace_no_slow_types feat: npm workspace and better Deno workspace support (#24334) 2024-07-04 00:54:33 +00:00