Skip to content
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: introduce new deprecated types for rules #19238

Open
wants to merge 48 commits into
base: main
Choose a base branch
from

Conversation

DMartens
Copy link
Contributor

@DMartens DMartens commented Dec 11, 2024

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[x] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

This implements the additional deprecated metadata RFC and closes #18061.

The checklist from the RFC:
Internal Changes:

  • Mention the new schema in the custom rule documentation
  • Add any additional information to these properties in core rules as desired (such as in Docs: Mention Stylistic as the source of replacement rules for all the stylistic rules that got deprecated #18053)
  • Update ESLint's website generator to take into account the additional information for rule doc deprecation notices
  • Update LintResult.usedDeprecatedRules by normalizing the old and new format for the existing replacedBy property and adding a new property with the name info for rules using the new deprecated format
  • Update the types in eslint

External Changes:

I also investigated the impact for third-party plugins.
Generally there are only a few deprecated rules and most are stylistic rules.
An overview for plugins with some deprecated rules:

Plugins without deprecated rules:

Is there anything you'd like reviewers to focus on?

Some notes for the changes:

  • I did not know where the put the documentation for DeprecateInfo as it is part of the rule but its documentation has no type anywhere and the type documentation is required for usedDeprecatedRules in NodeJS API Documentation. I chose to use a separate page with a short intro about the deprecated format and detailing the new format. This document could also detail future tools using the deprecated information.
  • meta.deprecated property for the rule indent-legacy is not updated as it is used for a test case in legacy-eslint and CLIEngine which I assume to be frozen (but I still updated it for other frozen rules)
  • the replacements only mentions the latest replacement in eslint-stylistic (e.g. rules replaced by padding-line-between-statements)

@DMartens DMartens requested a review from a team as a code owner December 11, 2024 21:12
@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Dec 11, 2024
@github-actions github-actions bot added rule Relates to ESLint's core rules cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features labels Dec 11, 2024
Copy link

netlify bot commented Dec 11, 2024

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 3183761
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/67b8a3549654e20008736e25

@DMartens DMartens changed the title feat: introduce new deprecated types feat: introduce new deprecated types for rules Dec 11, 2024
@mdjermanovic mdjermanovic added the accepted There is consensus among the team that this change meets the criteria for inclusion label Dec 19, 2024
@mdjermanovic
Copy link
Member

  • Update ESLint's website generator to take into account the additional information for rule doc deprecation notices

It doesn't seem that this is implemented?

@mdjermanovic
Copy link
Member

This implements the additional deprecated metadata RFC and closes #18053.

I think this closes #18061 but not #18053.

@DMartens
Copy link
Contributor Author

I updated the OP with the correct issue and corrected the messages in the rules.
Regarding the ESLint website update:
As noted in the notes I did not need to update the website code to keep working (it looks the same as without the changes).
Which additional details should be shown on the rule pages?

@aladdin-add aladdin-add self-requested a review December 24, 2024 16:28
@nzakas
Copy link
Member

nzakas commented Dec 31, 2024

I think what we're looking for is something to autogenerate the comment at the top of this page:
https://eslint.org/docs/latest/rules/comma-style

This rule was deprecated in ESLint v8.53.0. Please use the corresponding rule in @stylistic/eslint-plugin-js.

Right now, these are hardcoded into the docs.

@mdjermanovic
Copy link
Member

As noted in the notes I did not need to update the website code to keep working (it looks the same as without the changes).
Which additional details should be shown on the rule pages?

Sorry for the delay, I somehow missed a notification for this comment.

My understanding of the "Update ESLint's website generator to take into account the additional information" task mentioned in the original issue and the RFC was that we'll use the new metadata to autogenerate deprecation text on rule pages instead of hardcoding it in each rule's docs source .md file, just as @nzakas said in the comment above.

@DMartens
Copy link
Contributor Author

Sorry for the delay. I added the deprecated rule notice and removed the manually added ones.
I chose an important alert to make it consistent with the removed rules (e.g. require-jsdoc).

@mdjermanovic
Copy link
Member

@DMartens can you please resolve merge conflicts?

@mdjermanovic
Copy link
Member

Verify Files check is failing:

Validating rules
Missing deprecated information in yield-star-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in wrap-regex rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in wrap-iife rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in template-tag-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in template-curly-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in switch-colon-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in spaced-comment rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in space-unary-ops rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in space-infix-ops rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in space-in-parens rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in space-before-function-paren rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in space-before-blocks rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in semi rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in semi-style rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in semi-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in rest-spread-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in quotes rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in quote-props rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in prefer-reflect rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in padding-line-between-statements rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in padded-blocks rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in operator-linebreak rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in one-var-declaration-per-line rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in object-property-newline rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in object-curly-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in object-curly-newline rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in nonblock-statement-body-position rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-whitespace-before-property rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-trailing-spaces rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-tabs rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-sync rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-spaced-func rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-return-await rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-restricted-modules rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-process-exit rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-process-env rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-path-concat rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-new-symbol rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-new-require rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-negated-in-lhs rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-native-reassign rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-multiple-empty-lines rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-multi-spaces rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-mixed-spaces-and-tabs rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-mixed-requires rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-mixed-operators rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-floating-decimal rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-extra-semi rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-extra-parens rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-confusing-arrow rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-catch-shadow rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in no-buffer-constructor rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in newline-per-chained-call rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in newline-before-return rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in newline-after-var rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in new-parens rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in multiline-ternary rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in multiline-comment-style rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in max-statements-per-line rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in max-len rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in lines-between-class-members rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in lines-around-directive rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in lines-around-comment rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in linebreak-style rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in line-comment-position rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in keyword-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in key-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in jsx-quotes rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in indent rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in indent-legacy rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in implicit-arrow-linebreak rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in id-blacklist rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in handle-callback-err rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in global-require rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in generator-star-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in function-paren-newline rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in function-call-argument-newline rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in func-call-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in eol-last rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in dot-location rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in computed-property-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in comma-style rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in comma-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in comma-dangle rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in callback-return rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in brace-style rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in block-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in arrow-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in arrow-parens rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in array-element-newline rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in array-bracket-spacing rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Missing deprecated information in array-bracket-newline rule code or README.md. Please write @deprecated tag in code and「This rule was deprecated in ESLint ...」 in README.md.
Error: Process completed with exit code 1.

Looks like we should remove checking for deprecated info in rule docs source files.

eslint/Makefile.js

Lines 752 to 757 in 17f2aae

function hasDeprecatedInfo() {
const deprecatedTagRegExp = /@deprecated in ESLint/u;
const deprecatedInfoRegExp = /This rule was .+deprecated.+in ESLint/u;
return deprecatedTagRegExp.test(ruleCode) && deprecatedInfoRegExp.test(docText);
}


retv.push({
ruleId,
replacedBy: usesNewFormat ? meta.deprecated.replacedBy?.map(replacement => `${replacement.plugin?.name !== void 0 ? `${replacement.plugin.name}/` : ""}${replacement.rule?.name ?? ""}`) ?? [] : meta.replacedBy || [],
Copy link
Member

Choose a reason for hiding this comment

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

I checked again the RFC and it's not indicated how normalizing rule names for usedDeprecatedRules should work in the case of external rules. With this logic, the replacement rule names would look like "@stylistic/eslint-plugin-js/semi", but the standard notation for such a rule in a configuration object is "@stylistic/js/semi". Shall we use this format instead? Or something else? @eslint/eslint-tsc

The short form of the plugin prefix can be retrieved with naming.getShorthandName like here: https://github.com/eslint/eslint/blob/e89a54a3090f3503daf5e36b02b0035c993e3fd1/lib/eslint/eslint.js#L499C25-L499C66

Copy link
Member

Choose a reason for hiding this comment

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

I think we should use the name as it would likely appear in the config, so @stylistic/js/semi would be my choice.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also in favor of normalizing to @stylistic/js/semi.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should the shorthand name also be used when displaying the replacement rules in the documentation?

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a strong preference, but I think it's fine to be more descriptive in the documentation. The current format "Replaced by semi in @stylistic/eslint-plugin-js" sounds good to me.

fasttime
fasttime previously approved these changes Feb 19, 2025
Copy link
Member

@fasttime fasttime left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Leaving open for other reviews.

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
DMartens and others added 3 commits February 21, 2025 15:48
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
@DMartens
Copy link
Contributor Author

Thanks for the helpful code review, all of these should be fixed now.
Also fixed the if condition if there are no replacement rules (e.g. valid-jsdoc),

* `name` (`string`)<br>
The package name for `plugin` and the rule id for `rule`.
* `url` (`string`)<br>
An URL pointing to additional information, for example an announcement post or migration guide.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
An URL pointing to additional information, for example an announcement post or migration guide.
An URL pointing to documentation for the plugin / rule..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion cli Relates to ESLint's command-line interface contributor pool core Relates to ESLint's core APIs and features feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
Status: Second Review Needed
Development

Successfully merging this pull request may close these issues.

Change Request: Support additional rule metadata for deprecations
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy