Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions designs/2021-plugin-rule-replacements/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
- Repo: eslint/eslint, eslint/eslintrc
- Start Date: 2021-01-23
- RFC PR: (to be filled in)
- Authors: mykhalov

# Allow plugins to define rule replacements

## Summary

Provide better error message for removed rules by allowing plugins to define rule replacements.

## Motivation

ESLint provides great developer experience around removed rules:

```
1:1 error Rule 'generator-star' was removed and replaced by: generator-star-spacing generator-star
```

Until now this hasn't been the case with plugins:

```
1:1 error Definition for rule '@typescript-eslint/camelcase' was not found @typescript-eslint/camelcase
```

Although `@typescript-eslint/camelcase` [has been removed in favour of another rule](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/camelcase.md), there is no way for the plugin to explain this.

## Detailed Design

When reading plugin definition, look for `"replacements"` property next to `"rules"`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section should explain how you plan to implement this. Please look at the ESLint code and figure out which files would need to change. There are plenty of examples of already-merged RFCs in this repo to see what is expected.


```
module.exports = {
rules,
replacements: {
rules: {
foo: ['bar']
}
}
}
```

If exists, propagate this property to error reporting. When constructing error message, look into plugin replacements before looking into to ESLint replacements.

## Documentation

This should be documented in [Developer Guide](https://eslint.org/docs/developer-guide/working-with-plugins).

## Drawbacks

None at the moment.

## Backwards Compatibility Analysis

No effect on backwards compatibility.

## Alternatives

None at the moment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s really no other alternatives? What about plug-ins themselves continuing to ship a rule that always reports that the rule is replaced by another rule?


## Open Questions

None at the moment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None?


## Help Needed

None at the moment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean you already know how to implement this change?


## Frequently Asked Questions

None at the moment.

## Related Discussions

Adding deprecation message to ESLint itself ([#1549](https://github.com/eslint/eslint/issues/1549)).