-
-
Notifications
You must be signed in to change notification settings - Fork 31
feat: Add new rule no-meta-replaced-by
#518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add new rule no-meta-replaced-by
#518
Conversation
Co-authored-by: Bryan Mishkin <698306+bmish@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be appropriate to write
## When Not To Use It
If you need to support versions of ESLint prior to v9.
|
||
/** @type {import('eslint').Rule.RuleModule} */ | ||
module.exports = { | ||
meta: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also add an autofixer to this rule to move meta.replacedBy
to meta.deprecated.replacedBy
. A follow-up to do that would be fine since it could be tricky to get it right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thought so too. But I'd have to get down to the nitty-gritty of eslint and ASTs. The autofixer should be added in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another fix in a follow-up might be to remove replacedBy
from the defaultOrder
in meta-property-order
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also thinking about the neccessity and possibilities so that the autofixer is able to add the property plugin
to the replacement rule according to ReplacedByInfo
If this is not the desired behaviour of the autofixer it would simply convert the items of the old replacedBy
array to the new format e.g. [{ rule: { name: 'the-new-rule' } }]
If it is the desired behaviour one would have to determine and compare the prefix of the plugin. This could be achieved by either providing an option in no-meta-replaced-by
or reading the value of an exported flat config which might be trickier and not reliable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another fix in a follow-up might be to remove
replacedBy
from thedefaultOrder
inmeta-property-order
, right?
I think we can leave it. Doesn't hurt to continue to support the older rule properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the autofixer, it would be nice if the autofixer can work without any configuration. But if there's an option that can be provided to the rule to improve the autofixer further, I'm open to that as an added bonus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be appropriate to write
## When Not To Use It If you need to support versions of ESLint prior to v9.
Regarding when not to use it, I don't think we necessarily need to include this section. In fact, anyone can use this rule regardless of ESLint version. As far as I know, ESLint itself does not validate nor use the meta.deprecated
property. So anybody can use the object format for meta.deprecated
.
Note that if someone is using TypeScript to define their rules, they would want to make sure they have up-to-date rule types (which I believe come from @types/eslint or typescript-eslint). And rule authors would want to make sure they are using up-to-date versions of any third-party tooling like eslint-doc-generator that use this property.
OR, you could include the section and just state the context I've mentioned here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
no-meta-replaced-by
no-meta-replaced-by
Hey there,
This pull request introduces a new rule,
no-meta-replaced-by
to disallow the use of thereplacedBy
property at the top level of rulemeta
.I'd appreciate any improvements to the non-generated sections in the docs.
Closes #517