Commit Graph

1 Commits

Author SHA1 Message Date
overlookmotel 67f8c5d959 fix(linter/plugins): get correct plugin name in all cases (#17033)
A couple of changes to how plugin names are dealt with:

### Package names

Don't use package name if the specifier used to load the plugin is a relative path.

If your project is called `super-server`, and you load a plugin from `../plugins/no-foo.js`, that plugin shouldn't be called `super-server` - that's the name of the project, not the plugin.

Now it throws an error, telling you to give the plugin a name.

### Ensure `context.id` matches the plugin name

Previously `context.id` might not match the actual plugin name (it could include e.g. `eslint-plugin-` prefix, for example). Now it always matches.

This required re-implementing `normalize_plugin_name` on JS side too.

### Tests

Add a bunch of tests for every combination I could imagine of `plugin.meta.name`, package name, and alias. Those tests make sure `context.id` is same as the plugin name on Rust side.

### Incomplete

There's 2 things remaining to get naming completely correct:

1. Support plugin names with slashes in them e.g. `@scope/eslint-plugin-name` (#14557).

2. It's possible for the same plugin to have different names in different places, because you can alias the same plugin twice with different names in a config, and an override. Plugin names (in `context.id`, and in `// oxlint-disable` comments) should reflect the plugin name *as it is in the config which enabled that rule*.

I'm leaving those 2 for now.
2025-12-18 08:58:33 +00:00